protected long doUpdate(final File root, final SVNUpdateClient client) throws SVNException {
      final SvnConfiguration svnConfig = SvnConfiguration.getInstance(myVcs.getProject());

      MergeRootInfo info = svnConfig.getMergeRootInfo(root, myVcs);
      if (info.getUrlString1().equals(info.getUrlString2())
          && info.getRevision1().equals(info.getRevision2())) {
        return 0;
      }

      SVNDiffClient diffClient = myVcs.createDiffClient();
      diffClient.setEventHandler(myHandler);
      diffClient.doMerge(
          info.getUrl1(),
          info.getRevision1(),
          info.getUrl2(),
          info.getRevision2(),
          root,
          svnConfig.UPDATE_DEPTH,
          svnConfig.MERGE_DIFF_USE_ANCESTRY,
          false,
          svnConfig.MERGE_DRY_RUN,
          false);

      svnConfig.LAST_MERGED_REVISION = getLastMergedRevision(info.getRevision2(), info.getUrl2());
      return info.getResultRevision();
    }
 public SVNLogClient createLogClient() {
   final SVNLogClient client = new SVNLogClient(getPool(), myConfiguration.getOptions(myProject));
   client
       .getOperationsFactory()
       .setAuthenticationManager(myConfiguration.getAuthenticationManager(this));
   return client;
 }
 public SVNStatusClient createStatusClient() {
   SVNStatusClient client = new SVNStatusClient(getPool(), myConfiguration.getOptions(myProject));
   client
       .getOperationsFactory()
       .setAuthenticationManager(myConfiguration.getAuthenticationManager(this));
   client.setIgnoreExternals(false);
   return client;
 }
  public void refreshSSLProperty() {
    if (isSSLProtocolExplicitlySet()) return;

    if (SvnConfiguration.SSLProtocols.all.equals(myConfiguration.getSslProtocols())) {
      System.clearProperty(SVNKIT_HTTP_SSL_PROTOCOLS);
    } else if (SvnConfiguration.SSLProtocols.sslv3.equals(myConfiguration.getSslProtocols())) {
      System.setProperty(SVNKIT_HTTP_SSL_PROTOCOLS, "SSLv3");
    } else if (SvnConfiguration.SSLProtocols.tlsv1.equals(myConfiguration.getSslProtocols())) {
      System.setProperty(SVNKIT_HTTP_SSL_PROTOCOLS, "TLSv1");
    }
  }
  private boolean getAddedFilesPlaceOption() {
    final SvnConfiguration configuration = SvnConfiguration.getInstance(myVcs.getProject());
    boolean add = Boolean.TRUE.equals(configuration.isKeepNewFilesAsIsForTreeConflictMerge());
    if (configuration.isKeepNewFilesAsIsForTreeConflictMerge() != null) {
      return add;
    }
    if (!containAdditions(myTheirsChanges) && !containAdditions(myTheirsBinaryChanges)) {
      return false;
    }
    return Messages.YES
        == MessageDialogBuilder.yesNo(
                TreeConflictRefreshablePanel.TITLE,
                "Keep newly created file(s) in their original place?")
            .yesText("Keep")
            .noText("Move")
            .doNotAsk(
                new DialogWrapper.DoNotAskOption() {
                  @Override
                  public boolean isToBeShown() {
                    return true;
                  }

                  @Override
                  public void setToBeShown(boolean value, int exitCode) {
                    if (!value) {
                      if (exitCode == 0) {
                        // yes
                        configuration.setKeepNewFilesAsIsForTreeConflictMerge(true);
                      } else {
                        configuration.setKeepNewFilesAsIsForTreeConflictMerge(false);
                      }
                    }
                  }

                  @Override
                  public boolean canBeHidden() {
                    return true;
                  }

                  @Override
                  public boolean shouldSaveOptionsOnCancel() {
                    return true;
                  }

                  @NotNull
                  @Override
                  public String getDoNotShowMessage() {
                    return CommonBundle.message("dialog.options.do.not.ask");
                  }
                })
            .show();
  }
 private void createPool() {
   if (myPool != null) return;
   final String property = System.getProperty(KEEP_CONNECTIONS_KEY);
   final boolean keep;
   boolean unitTestMode = ApplicationManager.getApplication().isUnitTestMode();
   // pool variant by default
   if (StringUtil.isEmptyOrSpaces(property) || unitTestMode) {
     keep = !unitTestMode; // default
   } else {
     keep = Boolean.getBoolean(KEEP_CONNECTIONS_KEY);
   }
   myPool =
       new SvnIdeaRepositoryPoolManager(
           false,
           myConfiguration.getAuthenticationManager(this),
           myConfiguration.getOptions(myProject));
 }
 protected void showProgressMessage(final ProgressIndicator progress, final File root) {
   if (SvnConfiguration.getInstance(myVcs.getProject()).MERGE_DRY_RUN) {
     progress.setText(
         SvnBundle.message("progress.text.merging.dry.run.changes", root.getAbsolutePath()));
   } else {
     progress.setText(
         SvnBundle.message("progress.text.merging.changes", root.getAbsolutePath()));
   }
 }
 private MyItem(
     Project project,
     FilePath path,
     SVNDepth depth,
     SVNStatusClient client,
     boolean isInnerCopyRoot) {
   myProject = project;
   myConfiguration17 = SvnConfiguration.getInstance(myProject);
   myPath = path;
   myDepth = depth;
   myClient = client;
   mySvnClient = new SvnkitSvnStatusClient(client);
   myIsInnerCopyRoot = isInnerCopyRoot;
 }
  public boolean needsInteraction(final UpdatedFiles updatedFiles) {
    if (myChangesUnderProjectRoot) {
      refreshChangeListsFindConflicts(updatedFiles);
    } else {
      final FileGroup conflictedGroup =
          updatedFiles.getGroupById(FileGroup.MERGED_WITH_CONFLICT_ID);
      for (String filename : conflictedGroup.getFiles()) {
        final VirtualFile vf = SvnUtil.getVirtualFile(filename);
        myConflictedVirtualFiles.add(vf);
      }
    }

    return ((!myConflictedVirtualFiles.isEmpty()) || (!haveUnresolvedConflicts(updatedFiles)))
        && (!SvnConfiguration.getInstance(myProject).MERGE_DRY_RUN);
  }
    public void detectCopyRoots(final VirtualFile[] roots, final boolean clearState) {
      final Getter<Boolean> cancelGetter =
          new Getter<Boolean>() {
            public Boolean get() {
              return myVcs.getProject().isDisposed();
            }
          };

      for (final VirtualFile vcsRoot : roots) {
        final List<Real> foundRoots =
            ForNestedRootChecker.getAllNestedWorkingCopies(vcsRoot, myVcs, false, cancelGetter);
        if (foundRoots.isEmpty()) {
          myLonelyRoots.add(vcsRoot);
        }
        // filter out bad(?) items
        for (Real foundRoot : foundRoots) {
          final SVNURL repoRoot = foundRoot.getInfo().getRepositoryRootURL();
          if (repoRoot == null) {
            LOG.info(
                "Error: cannot find repository URL for versioned folder: "
                    + foundRoot.getFile().getPath());
          } else {
            myRepositoryRoots.register(repoRoot);
            myTopRoots.add(
                new RootUrlInfo(
                    repoRoot,
                    foundRoot.getInfo().getURL(),
                    SvnFormatSelector.getWorkingCopyFormat(foundRoot.getInfo().getFile()),
                    foundRoot.getFile(),
                    vcsRoot));
          }
        }
      }

      if (!SvnConfiguration.getInstance(myVcs.getProject()).DETECT_NESTED_COPIES) {
        myApplier.apply(myVcs, myTopRoots, myLonelyRoots);
      } else {
        addNestedRoots(clearState);
      }
    }
  public void postStartup() {
    if (myProject.isDefault()) return;
    myCopiesRefreshManager =
        new SvnCopiesRefreshManager((SvnFileUrlMappingImpl) getSvnFileUrlMapping());
    if (!myConfiguration.isCleanupRun()) {
      ApplicationManager.getApplication()
          .invokeLater(
              new Runnable() {
                @Override
                public void run() {
                  cleanup17copies();
                  myConfiguration.setCleanupRun(true);
                }
              },
              ModalityState.NON_MODAL,
              myProject.getDisposed());
    } else {
      invokeRefreshSvnRoots();
    }

    myWorkingCopiesContent.activate();
  }
 public SVNWCClient createWCClient(@NotNull ISVNAuthenticationManager manager) {
   final SVNWCClient client = new SVNWCClient(getPool(), myConfiguration.getOptions(myProject));
   client.getOperationsFactory().setAuthenticationManager(manager);
   return client;
 }
 @Override
 protected boolean isDryRun() {
   return SvnConfiguration.getInstance(myVcs.getProject()).MERGE_DRY_RUN;
 }
 public ISVNAuthenticationManager getSvnAuthenticationManager() {
   return myConfiguration.getAuthenticationManager(this);
 }
Beispiel #15
0
  public void reportAppendableHistory(
      FilePath path,
      final VcsAppendableHistorySessionPartner partner,
      @Nullable final SVNRevision from,
      @Nullable final SVNRevision to,
      final int limit,
      SVNRevision peg,
      final boolean forceBackwards)
      throws VcsException {
    FilePath committedPath = path;
    Change change = ChangeListManager.getInstance(myVcs.getProject()).getChange(path);
    if (change != null) {
      final ContentRevision beforeRevision = change.getBeforeRevision();
      final ContentRevision afterRevision = change.getAfterRevision();
      if (beforeRevision != null
          && afterRevision != null
          && !beforeRevision.getFile().equals(afterRevision.getFile())
          && afterRevision.getFile().equals(path)) {
        committedPath = beforeRevision.getFile();
      }
      // revision can be VcsRevisionNumber.NULL
      if (peg == null
          && change.getBeforeRevision() != null
          && change.getBeforeRevision().getRevisionNumber() instanceof SvnRevisionNumber) {
        peg = ((SvnRevisionNumber) change.getBeforeRevision().getRevisionNumber()).getRevision();
      }
    }

    final boolean showMergeSources =
        SvnConfiguration.getInstance(myVcs.getProject()).isShowMergeSourcesInAnnotate();
    final LogLoader logLoader;
    if (path.isNonLocal()) {
      logLoader =
          new RepositoryLoader(
              myVcs, committedPath, from, to, limit, peg, forceBackwards, showMergeSources);
    } else {
      logLoader = new LocalLoader(myVcs, committedPath, from, to, limit, peg, showMergeSources);
    }

    try {
      logLoader.preliminary();
    } catch (SVNCancelException e) {
      throw new VcsException(e);
    } catch (SVNException e) {
      throw new VcsException(e);
    }
    logLoader.check();
    if (showMergeSources) {
      logLoader.initSupports15();
    }

    final SvnHistorySession historySession =
        new SvnHistorySession(
            myVcs,
            Collections.<VcsFileRevision>emptyList(),
            committedPath,
            showMergeSources && Boolean.TRUE.equals(logLoader.mySupport15),
            null,
            false,
            !path.isNonLocal());

    final Ref<Boolean> sessionReported = new Ref<Boolean>();
    final ProgressIndicator indicator = ProgressManager.getInstance().getProgressIndicator();
    if (indicator != null) {
      indicator.setText(SvnBundle.message("progress.text2.collecting.history", path.getName()));
    }
    final Consumer<VcsFileRevision> consumer =
        new Consumer<VcsFileRevision>() {
          @Override
          public void consume(VcsFileRevision vcsFileRevision) {
            if (!Boolean.TRUE.equals(sessionReported.get())) {
              partner.reportCreatedEmptySession(historySession);
              sessionReported.set(true);
            }
            partner.acceptRevision(vcsFileRevision);
          }
        };

    logLoader.setConsumer(consumer);
    logLoader.load();
    logLoader.check();
  }
 @NotNull
 public ISVNOptions getSvnOptions() {
   return myConfiguration.getOptions(myProject);
 }
  public SvnVcs(
      final Project project,
      MessageBus bus,
      SvnConfiguration svnConfiguration,
      final SvnLoadedBrachesStorage storage) {
    super(project, VCS_NAME);
    myLoadedBranchesStorage = storage;
    LOG.debug("ct");
    myRootsToWorkingCopies = new RootsToWorkingCopies(this);
    myConfiguration = svnConfiguration;
    myAuthNotifier = new SvnAuthenticationNotifier(this);

    dumpFileStatus(FileStatus.ADDED);
    dumpFileStatus(FileStatus.DELETED);
    dumpFileStatus(FileStatus.MERGE);
    dumpFileStatus(FileStatus.MODIFIED);
    dumpFileStatus(FileStatus.NOT_CHANGED);
    dumpFileStatus(FileStatus.UNKNOWN);

    dumpFileStatus(SvnFileStatus.REPLACED);
    dumpFileStatus(SvnFileStatus.EXTERNAL);
    dumpFileStatus(SvnFileStatus.OBSTRUCTED);

    refreshSSLProperty();

    final ProjectLevelVcsManager vcsManager = ProjectLevelVcsManager.getInstance(project);
    myAddConfirmation =
        vcsManager.getStandardConfirmation(VcsConfiguration.StandardConfirmation.ADD, this);
    myDeleteConfirmation =
        vcsManager.getStandardConfirmation(VcsConfiguration.StandardConfirmation.REMOVE, this);
    myCheckoutOptions =
        vcsManager.getStandardOption(VcsConfiguration.StandardOption.CHECKOUT, this);

    if (myProject.isDefault()) {
      myChangeListListener = null;
      myEntriesFileListener = null;
    } else {
      myEntriesFileListener = new SvnEntriesFileListener(project);
      upgradeIfNeeded(bus);

      myChangeListListener = new SvnChangelistListener(myProject, this);

      myVcsListener =
          new VcsListener() {
            @Override
            public void directoryMappingChanged() {
              invokeRefreshSvnRoots();
            }
          };
    }

    myFrameStateListener =
        project.isDefault()
            ? null
            : new MyFrameStateListener(
                ChangeListManager.getInstance(project), VcsDirtyScopeManager.getInstance(project));
    myWorkingCopiesContent = new WorkingCopiesContent(this);

    // remove used some time before old notification group ids
    correctNotificationIds();
    myChecker = new SvnExecutableChecker(myProject);
    myConfiguration.getAuthenticationManager(this).setHelper(myHelper);
  }
 public SVNRepository createRepository(SVNURL url) throws SVNException {
   SVNRepository repos = SVNRepositoryFactory.create(url);
   repos.setAuthenticationManager(myConfiguration.getAuthenticationManager(this));
   repos.setTunnelProvider(myConfiguration.getOptions(myProject));
   return repos;
 }
  @Override
  public void activate() {
    createPool();
    final ProjectLevelVcsManager vcsManager = ProjectLevelVcsManager.getInstance(myProject);
    if (!myProject.isDefault()) {
      ChangeListManager.getInstance(myProject).addChangeListListener(myChangeListListener);
      vcsManager.addVcsListener(myVcsListener);
    }

    SvnApplicationSettings.getInstance().svnActivated();
    if (myEntriesFileListener != null) {
      VirtualFileManager.getInstance().addVirtualFileListener(myEntriesFileListener);
    }
    // this will initialize its inner listener for committed changes upload
    LoadedRevisionsCache.getInstance(myProject);
    FrameStateManager.getInstance().addListener(myFrameStateListener);

    myAuthNotifier.init();
    mySvnBranchPointsCalculator = new SvnBranchPointsCalculator(myProject);
    mySvnBranchPointsCalculator.activate();

    if (SystemInfo.isWindows) {
      if (!SVNJNAUtil.isJNAPresent()) {
        Notifications.Bus.notify(
            new Notification(
                getDisplayName(),
                "Subversion plugin: no JNA",
                "A problem with JNA initialization for svnkit library. Encryption is not available.",
                NotificationType.WARNING),
            NotificationDisplayType.BALLOON,
            myProject);
      } else if (!SVNJNAUtil.isWinCryptEnabled()) {
        Notifications.Bus.notify(
            new Notification(
                getDisplayName(),
                "Subversion plugin: no encryption",
                "A problem with encryption module (Crypt32.dll) initialization for svnkit library. Encryption is not available.",
                NotificationType.WARNING),
            NotificationDisplayType.BALLOON,
            myProject);
      }
    }

    final SvnConfiguration.UseAcceleration accelerationType =
        SvnConfiguration.getInstance(myProject).myUseAcceleration;
    if (SvnConfiguration.UseAcceleration.javaHL.equals(accelerationType)) {
      CheckJavaHL.runtimeCheck(myProject);
    } else if (SvnConfiguration.UseAcceleration.commandLine.equals(accelerationType)
        && !ApplicationManager.getApplication().isHeadlessEnvironment()) {
      myChecker.checkExecutableAndNotifyIfNeeded();
    }

    // do one time after project loaded
    StartupManager.getInstance(myProject)
        .runWhenProjectIsInitialized(
            new DumbAwareRunnable() {
              @Override
              public void run() {
                postStartup();

                // for IDEA, it takes 2 minutes - and anyway this can be done in background, no
                // sense...
                // once it could be mistaken about copies for 2 minutes on start...

                /*if (! myMapping.getAllWcInfos().isEmpty()) {
                  invokeRefreshSvnRoots();
                  return;
                }
                ProgressManager.getInstance().runProcessWithProgressSynchronously(new Runnable() {
                  public void run() {
                    myCopiesRefreshManager.getCopiesRefresh().ensureInit();
                  }
                }, SvnBundle.message("refreshing.working.copies.roots.progress.text"), true, myProject);*/
              }
            });

    vcsManager.addVcsListener(myRootsToWorkingCopies);

    myLoadedBranchesStorage.activate();
  }
 @NotNull
 private SvnAuthenticationManager getAuthenticationManager() {
   return myConfiguration.getAuthenticationManager(myVcs);
 }
Beispiel #21
0
 public SVNWCAccess createWCAccess() {
   final SVNWCAccess access = SVNWCAccess.newInstance(null);
   access.setOptions(myConfiguration.getOptions(myProject));
   return access;
 }