public SvnKitManager(@NotNull SvnVcs vcs) {
    myVcs = vcs;
    myProject = myVcs.getProject();
    myConfiguration = myVcs.getSvnConfiguration();

    refreshSSLProperty();
  }
 private boolean for17move(
     final SvnVcs vcs, final File src, final File dst, boolean undo, SVNStatus srcStatus)
     throws SVNException {
   if (srcStatus != null && srcStatus.getCopyFromURL() == null) {
     undo = false;
   }
   if (undo) {
     myUndoingMove = true;
     createRevertAction(vcs, dst, true).execute();
     copyUnversionedMembersOfDirectory(src, dst);
     if (srcStatus == null || SvnVcs.svnStatusIsUnversioned(srcStatus)) {
       FileUtil.delete(src);
     } else {
       createRevertAction(vcs, src, true).execute();
     }
     restoreFromUndoStorage(dst);
   } else {
     if (doUsualMove(vcs, src)) return true;
     // check destination directory
     final SVNStatus dstParentStatus = getFileStatus(vcs, dst.getParentFile());
     if (dstParentStatus == null || SvnVcs.svnStatusIsUnversioned(dstParentStatus)) {
       try {
         copyFileOrDir(src, dst);
       } catch (IOException e) {
         throw new SVNException(SVNErrorMessage.create(SVNErrorCode.IO_ERROR, e), e);
       }
       createDeleteAction(vcs, src, true).execute();
       return false;
     }
     moveFileWithSvn(vcs, src, dst);
   }
   return false;
 }
  public boolean move(VirtualFile file, VirtualFile toDir) throws IOException {
    File srcFile = getIOFile(file);
    File dstFile = new File(getIOFile(toDir), file.getName());

    final SvnVcs vcs = getVCS(toDir);
    final SvnVcs sourceVcs = getVCS(file);
    if (vcs == null && sourceVcs == null) return false;

    if (vcs == null) {
      return false;
    }

    FileDocumentManager.getInstance().saveAllDocuments();
    if (sourceVcs == null) {
      return createItem(toDir, file.getName(), file.isDirectory(), true);
    }

    if (isPendingAdd(vcs.getProject(), toDir)) {

      myMovedFiles.add(new MovedFileInfo(sourceVcs.getProject(), srcFile, dstFile));
      return true;
    } else {
      final VirtualFile oldParent = file.getParent();
      myFilesToRefresh.add(oldParent);
      myFilesToRefresh.add(toDir);
      return doMove(sourceVcs, srcFile, dstFile);
    }
  }
 private static boolean isUndo(SvnVcs vcs) {
   if (vcs == null || vcs.getProject() == null) {
     return false;
   }
   Project p = vcs.getProject();
   return UndoManager.getInstance(p).isUndoInProgress();
 }
  private void processDeletedFiles(Project project) {
    final List<Pair<FilePath, WorkingCopyFormat>> deletedFiles =
        new ArrayList<Pair<FilePath, WorkingCopyFormat>>();
    final Collection<FilePath> filesToProcess = new ArrayList<FilePath>();
    List<VcsException> exceptions = new ArrayList<VcsException>();
    final AbstractVcsHelper vcsHelper = AbstractVcsHelper.getInstance(project);

    try {
      fillDeletedFiles(project, deletedFiles, filesToProcess);
      if (deletedFiles.isEmpty() && filesToProcess.isEmpty() || myUndoingMove) return;
      SvnVcs vcs = SvnVcs.getInstance(project);
      final VcsShowConfirmationOption.Value value = vcs.getDeleteConfirmation().getValue();
      if (value != VcsShowConfirmationOption.Value.DO_NOTHING_SILENTLY) {
        if (!deletedFiles.isEmpty()) {
          final Collection<FilePath> confirmed =
              promptAboutDeletion(deletedFiles, vcs, value, vcsHelper);
          if (confirmed != null) {
            filesToProcess.addAll(confirmed);
          }
        }
        if (filesToProcess != null && !filesToProcess.isEmpty()) {
          runInBackground(
              project,
              "Deleting files from Subversion",
              createDeleteRunnable(project, vcs, filesToProcess, exceptions));
        }
        final List<FilePath> deletedFilesFiles =
            ObjectsConvertor.convert(
                deletedFiles,
                new Convertor<Pair<FilePath, WorkingCopyFormat>, FilePath>() {
                  @Override
                  public FilePath convert(Pair<FilePath, WorkingCopyFormat> o) {
                    return o.getFirst();
                  }
                });
        for (FilePath file : deletedFilesFiles) {
          final FilePath parent = file.getParentPath();
          if (parent != null) {
            myFilesToRefresh.add(parent.getVirtualFile());
          }
        }
        if (filesToProcess != null) {
          deletedFilesFiles.removeAll(filesToProcess);
        }
        for (FilePath file : deletedFilesFiles) {
          FileUtil.delete(file.getIOFile());
        }
      }
    } catch (SVNException e) {
      exceptions.add(new VcsException(e));
    }
    if (!exceptions.isEmpty()) {
      vcsHelper.showErrors(exceptions, SvnBundle.message("delete.files.errors.title"));
    }
  }
 private boolean doUsualMove(SvnVcs vcs, File src) {
   // if src is not under version control, do usual move.
   SVNStatus srcStatus = getFileStatus(vcs, src);
   if (srcStatus == null
       || SvnVcs.svnStatusIsUnversioned(srcStatus)
       || SvnVcs.svnStatusIs(srcStatus, SVNStatusType.STATUS_OBSTRUCTED)
       || SvnVcs.svnStatusIs(srcStatus, SVNStatusType.STATUS_MISSING)
       || SvnVcs.svnStatusIs(srcStatus, SVNStatusType.STATUS_EXTERNAL)) {
     return true;
   }
   return false;
 }
  private void collectLogEntries(
      final ProgressIndicator indicator,
      FilePath file,
      VcsException[] exception,
      final Consumer<VcsFileRevision> result,
      final Ref<Boolean> supports15Ref)
      throws SVNException, VcsException {
    SVNWCClient wcClient = myVcs.createWCClient();
    SVNInfo info =
        wcClient.doInfo(new File(file.getIOFile().getAbsolutePath()), SVNRevision.UNDEFINED);
    wcClient.setEventHandler(
        new ISVNEventHandler() {
          public void handleEvent(SVNEvent event, double progress) throws SVNException {}

          public void checkCancelled() throws SVNCancelException {
            indicator.checkCanceled();
          }
        });
    if (info == null || info.getRepositoryRootURL() == null) {
      exception[0] =
          new VcsException("File ''{0}'' is not under version control" + file.getIOFile());
      return;
    }
    final String url = info.getURL() == null ? null : info.getURL().toString();
    String relativeUrl = url;
    final SVNURL repoRootURL = info.getRepositoryRootURL();

    final String root = repoRootURL.toString();
    if (url != null && url.startsWith(root)) {
      relativeUrl = url.substring(root.length());
    }
    if (indicator != null) {
      indicator.setText2(SvnBundle.message("progress.text2.changes.establishing.connection", url));
    }
    final SVNRevision pegRevision = info.getRevision();
    SVNLogClient client = myVcs.createLogClient();

    final boolean supports15 = SvnUtil.checkRepositoryVersion15(myVcs, url);
    supports15Ref.set(supports15);
    client.doLog(
        new File[] {new File(file.getIOFile().getAbsolutePath())},
        SVNRevision.HEAD,
        SVNRevision.create(1),
        SVNRevision.UNDEFINED,
        false,
        true,
        supports15,
        0,
        null,
        new MyLogEntryHandler(
            myVcs, url, pegRevision, relativeUrl, result, repoRootURL, file.getCharset()));
  }
Ejemplo n.º 8
0
  @Test
  public void testSimpleNotMerged() throws Exception {
    enableSilentOperation(VcsConfiguration.StandardConfirmation.ADD);
    enableSilentOperation(VcsConfiguration.StandardConfirmation.REMOVE);

    final File trunk = new File(myTempDirFixture.getTempDirPath(), "trunk");
    trunk.mkdir();
    Thread.sleep(100);
    final File folder = new File(trunk, "folder");
    folder.mkdir();
    Thread.sleep(100);
    final File f1 = new File(folder, "f1.txt");
    f1.createNewFile();
    new File(folder, "f2.txt").createNewFile();
    Thread.sleep(100);

    verify(runSvn("import", "-m", "test", trunk.getAbsolutePath(), myRepoUrl + "/trunk"));
    verify(runSvn("copy", "-m", "test", myRepoUrl + "/trunk", myRepoUrl + "/branch"));

    FileUtil.delete(trunk);
    verify(runSvn("co", myRepoUrl + "/trunk", trunk.getAbsolutePath()));
    verify(runSvn("co", myRepoUrl + "/branch", myBranchVcsRoot.getAbsolutePath()));

    // rev 3

    final VirtualFile vf = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(f1);
    editFileInCommand(myProject, vf, "123\n456\n123");
    Thread.sleep(100);
    verify(runSvn("ci", "-m", "test", trunk.getAbsolutePath()));

    final SvnVcs vcs = SvnVcs.getInstance(myProject);
    final CommittedChangesProvider<SvnChangeList, ChangeBrowserSettings> committedChangesProvider =
        vcs.getCommittedChangesProvider();
    final List<SvnChangeList> changeListList =
        committedChangesProvider.getCommittedChanges(
            committedChangesProvider.createDefaultSettings(),
            new SvnRepositoryLocation(myRepoUrl + "/trunk"),
            0);

    final SvnChangeList changeList = changeListList.get(0);
    final BranchInfo branchInfo =
        new BranchInfo(
            vcs,
            myRepoUrl,
            myRepoUrl + "/branch",
            myRepoUrl + "/trunk",
            myRepoUrl + "/trunk",
            vcs.createWCClient());
    final SvnMergeInfoCache.MergeCheckResult result =
        branchInfo.checkList(changeList, myBranchVcsRoot.getAbsolutePath());
    assert SvnMergeInfoCache.MergeCheckResult.NOT_MERGED.equals(result);
  }
  @NotNull
  private List<WorkingCopyFormat> getSupportedFormats() {
    List<WorkingCopyFormat> result = ContainerUtil.newArrayList();
    ClientFactory factory = myVcs.getFactory();
    ClientFactory otherFactory = myVcs.getOtherFactory(factory);

    try {
      result.addAll(factory.createUpgradeClient().getSupportedFormats());
      result.addAll(SvnFormatWorker.getOtherFactoryFormats(otherFactory));
    } catch (VcsException e) {
      LOG.info(e);
    }

    return result;
  }
  public SvnCommittedChangesProvider(final Project project) {
    myProject = project;
    myVcs = SvnVcs.getInstance(myProject);
    myZipper = new MyZipper();

    myConnection = myProject.getMessageBus().connect();

    myConnection.subscribe(
        VcsConfigurationChangeListener.BRANCHES_CHANGED_RESPONSE,
        new VcsConfigurationChangeListener.DetailedNotification() {
          public void execute(
              final Project project,
              final VirtualFile vcsRoot,
              final List<CommittedChangeList> cachedList) {
            ApplicationManager.getApplication()
                .invokeLater(
                    new Runnable() {
                      public void run() {
                        if (project.isDisposed()) {
                          return;
                        }
                        for (CommittedChangeList committedChangeList : cachedList) {
                          if ((committedChangeList instanceof SvnChangeList)
                              && ((vcsRoot == null)
                                  || (vcsRoot.equals(
                                      ((SvnChangeList) committedChangeList).getVcsRoot())))) {
                            ((SvnChangeList) committedChangeList).forceReloadCachedInfo(true);
                          }
                        }
                      }
                    });
          }
        });
  }
  // only refresh might have changed; for branches/roots change, another method is used
  public MergeCheckResult getState(
      final WCInfoWithBranches info,
      final SvnChangeList list,
      final WCInfoWithBranches.Branch selectedBranch,
      final String branchPath) {
    final String currentUrl = info.getRootUrl();
    final String branchUrl = selectedBranch.getUrl();

    MyCurrentUrlData rootMapping = myState.getCurrentUrlMapping().get(currentUrl);
    BranchInfo mergeChecker = null;
    if (rootMapping == null) {
      rootMapping = new MyCurrentUrlData();
      myState.getCurrentUrlMapping().put(currentUrl, rootMapping);
    } else {
      mergeChecker = rootMapping.getBranchInfo(branchPath);
    }
    if (mergeChecker == null) {
      mergeChecker =
          new BranchInfo(
              SvnVcs.getInstance(myProject),
              info.getRepoUrl(),
              branchUrl,
              currentUrl,
              info.getTrunkRoot());
      rootMapping.addBranchInfo(branchPath, mergeChecker);
    }

    return mergeChecker.checkList(list, branchPath);
  }
  private boolean sameRoot(final SvnVcs vcs, final VirtualFile srcDir, final VirtualFile dstDir) {
    final UUIDHelper helper = new UUIDHelper(vcs);
    final String srcUUID = helper.getRepositoryUUID(vcs.getProject(), srcDir);
    final String dstUUID = helper.getRepositoryUUID(vcs.getProject(), dstDir);

    return srcUUID != null && dstUUID != null && srcUUID.equals(dstUUID);
  }
Ejemplo n.º 13
0
  public byte[] loadContent() throws IOException, VcsException {
    ContentLoader loader = new ContentLoader(myURL, myRevision, myPegRevision);
    if (ApplicationManager.getApplication().isDispatchThread() && !myRevision.isLocal()) {
      ProgressManager.getInstance()
          .runProcessWithProgressSynchronously(
              loader,
              SvnBundle.message("progress.title.loading.file.content"),
              false,
              myVCS.getProject());
    } else {
      loader.run();
    }

    VcsException exception = loader.getException();
    if (exception == null) {
      final byte[] contents = loader.getContents();
      ContentRevisionCache.checkContentsSize(myURL, contents.length);
      return contents;
    } else {
      LOG.info(
          "Failed to load file '"
              + myURL
              + "' content at revision: "
              + myRevision
              + "\n"
              + exception.getMessage(),
          exception);
      throw exception;
    }
  }
 private Collection<VirtualFile> promptAboutAddition(
     SvnVcs vcs,
     List<VirtualFile> addedVFiles,
     VcsShowConfirmationOption.Value value,
     AbstractVcsHelper vcsHelper) {
   Collection<VirtualFile> filesToProcess;
   if (value == VcsShowConfirmationOption.Value.DO_ACTION_SILENTLY) {
     filesToProcess = addedVFiles;
   } else {
     final String singleFilePrompt;
     if (addedVFiles.size() == 1 && addedVFiles.get(0).isDirectory()) {
       singleFilePrompt = SvnBundle.getString("confirmation.text.add.dir");
     } else {
       singleFilePrompt = SvnBundle.getString("confirmation.text.add.file");
     }
     filesToProcess =
         vcsHelper.selectFilesToProcess(
             addedVFiles,
             SvnBundle.message("confirmation.title.add.multiple.files"),
             null,
             SvnBundle.message("confirmation.title.add.file"),
             singleFilePrompt,
             vcs.getAddConfirmation());
   }
   return filesToProcess;
 }
Ejemplo n.º 15
0
 public BranchMerger(
     final SvnVcs vcs,
     final SVNURL sourceUrl,
     final SVNURL targetUrl,
     final String targetPath,
     final UpdateEventHandler handler,
     final boolean isReintegrate,
     final String branchName,
     final long sourceCopyRevision) {
   myVcs = vcs;
   myTargetPath = targetPath;
   mySourceUrl = sourceUrl;
   myTargetUrl = targetUrl;
   myHandler = handler;
   myReintegrate = isReintegrate;
   myBranchName = branchName;
   mySourceCopyRevision = sourceCopyRevision;
   myAtStart = true;
   // TODO: Rewrite this SVNKit usage
   SVNRepository repository = null;
   try {
     repository = myVcs.createRepository(mySourceUrl);
     mySourceLatestRevision = repository.getLatestRevision();
   } catch (SVNException e) {
     mySourceLatestRevision = SVNRevision.HEAD.getNumber();
   } finally {
     if (repository != null) {
       repository.closeSession();
     }
   }
 }
  private void prepareInnerCopy() throws Exception {
    final SubTree subTree = new SubTree(myWorkingCopyDir);
    checkin();
    clManager.stopEveryThingIfInTestMode();
    sleep(100);
    final File rootFile = new File(subTree.myRootDir.getPath());
    FileUtil.delete(rootFile);
    FileUtil.delete(new File(myWorkingCopyDir.getPath() + File.separator + ".svn"));
    Assert.assertTrue(!rootFile.exists());
    sleep(200);
    myWorkingCopyDir.refresh(false, true);

    verify(runSvn("co", myMainUrl));
    final File sourceDir = new File(myWorkingCopyDir.getPath(), "source");
    final File innerDir = new File(sourceDir, "inner1/inner2/inner");
    verify(runSvn("co", myExternalURL, innerDir.getPath()));
    sleep(100);
    myWorkingCopyDir.refresh(false, true);
    // above is preparation

    // start change list manager again
    clManager.forceGoInTestMode();
    myVcs.invokeRefreshSvnRoots(false);
    clManager.ensureUpToDate(false);
    clManager.ensureUpToDate(false);
  }
  private void fillAddedFiles(
      Project project,
      SvnVcs vcs,
      List<VirtualFile> addedVFiles,
      Map<VirtualFile, File> copyFromMap,
      Set<VirtualFile> recursiveItems) {
    final Collection<AddedFileInfo> addedFileInfos = myAddedFiles.remove(project);
    final ChangeListManager changeListManager = ChangeListManager.getInstance(project);

    for (AddedFileInfo addedFileInfo : addedFileInfos) {
      final File ioFile = new File(getIOFile(addedFileInfo.myDir), addedFileInfo.myName);
      VirtualFile addedFile = addedFileInfo.myDir.findChild(addedFileInfo.myName);
      if (addedFile == null) {
        addedFile = myLfs.refreshAndFindFileByIoFile(ioFile);
      }
      if (addedFile != null) {
        final SVNStatus fileStatus = getFileStatus(vcs, ioFile);
        if (fileStatus == null || !SvnVcs.svnStatusIs(fileStatus, SVNStatusType.STATUS_IGNORED)) {
          boolean isIgnored = changeListManager.isIgnoredFile(addedFile);
          if (!isIgnored) {
            addedVFiles.add(addedFile);
            copyFromMap.put(addedFile, addedFileInfo.myCopyFrom);
            if (addedFileInfo.myRecursive) {
              recursiveItems.add(addedFile);
            }
          }
        }
      }
    }
  }
  @Nullable
  public VcsCommittedViewAuxiliary createActions(
      final DecoratorManager manager, @Nullable final RepositoryLocation location) {
    final RootsAndBranches rootsAndBranches = new RootsAndBranches(myProject, manager, location);
    refreshMergeInfo(rootsAndBranches);

    final DefaultActionGroup popup = new DefaultActionGroup(myVcs.getDisplayName(), true);
    popup.add(rootsAndBranches.getIntegrateAction());
    popup.add(rootsAndBranches.getUndoIntegrateAction());
    popup.add(new ConfigureBranchesAction());

    final ShowHideMergePanel action =
        new ShowHideMergePanel(manager, rootsAndBranches.getStrategy());

    return new VcsCommittedViewAuxiliary(
        Collections.<AnAction>singletonList(popup),
        new Runnable() {
          public void run() {
            if (myMergeInfoUpdatesListener != null) {
              myMergeInfoUpdatesListener.removePanel(rootsAndBranches);
              rootsAndBranches.dispose();
            }
          }
        },
        Collections.<AnAction>singletonList(action));
  }
  private List<CommittedChangeList> loadSvnChangeListsForPatch(TreeConflictDescription description)
      throws VcsException {
    long max = description.getSourceRightVersion().getPegRevision();
    long min = description.getSourceLeftVersion().getPegRevision();

    final ChangeBrowserSettings settings = new ChangeBrowserSettings();
    settings.USE_CHANGE_BEFORE_FILTER = settings.USE_CHANGE_AFTER_FILTER = true;
    settings.CHANGE_BEFORE = "" + max;
    settings.CHANGE_AFTER = "" + min;
    final List<SvnChangeList> committedChanges =
        myVcs
            .getCachingCommittedChangesProvider()
            .getCommittedChanges(
                settings,
                new SvnRepositoryLocation(
                    description.getSourceRightVersion().getRepositoryRoot().toString()),
                0);
    final List<CommittedChangeList> lst =
        new ArrayList<CommittedChangeList>(committedChanges.size() - 1);
    for (SvnChangeList change : committedChanges) {
      if (change.getNumber() == min) {
        continue;
      }
      lst.add(change);
    }
    return lst;
  }
Ejemplo n.º 20
0
  // on EDT, dispose checked
  public void execute(final UpdatedFiles updatedFiles) {
    if (myConflictedVirtualFiles.isEmpty()) {
      return;
    }
    final AbstractVcsHelper vcsHelper = AbstractVcsHelper.getInstance(myProject);

    List<VirtualFile> mergedFiles =
        vcsHelper.showMergeDialog(myConflictedVirtualFiles, new SvnMergeProvider(myProject));

    final FileGroup mergedGroup = updatedFiles.getGroupById(FileGroup.MERGED_ID);
    final FileGroup conflictedGroup = updatedFiles.getGroupById(FileGroup.MERGED_WITH_CONFLICT_ID);
    final VcsKey vcsKey = SvnVcs.getKey();

    for (final VirtualFile mergedFile : mergedFiles) {
      String path = FileUtil.toSystemDependentName(mergedFile.getPresentableUrl());
      conflictedGroup.remove(path);
      mergedGroup.add(path, vcsKey, null);

      mergedFile.refresh(false, false);
      // for additionally created files removal to be detected
      mergedFile.getParent().refresh(false, false);

      if (myChangesUnderProjectRoot) {
        myDirtyScopeManager.fileDirty(mergedFile);
      }
    }
  }
    @Override
    public void apply(
        @NotNull MultiMap<VirtualFile, TextFilePatchInProgress> patchGroups,
        @Nullable LocalChangeList localList,
        @Nullable String fileName,
        @Nullable
            TransparentlyFailedValueI<Map<String, Map<String, CharSequence>>, PatchSyntaxException>
                additionalInfo) {
      final List<FilePatch> patches;
      try {
        patches = ApplyPatchSaveToFileExecutor.patchGroupsToOneGroup(patchGroups, myBaseDir);
      } catch (IOException e) {
        myInner.handleException(e, true);
        return;
      }

      final PatchApplier<BinaryFilePatch> patchApplier =
          new PatchApplier<BinaryFilePatch>(
              myVcs.getProject(), myBaseDir, patches, localList, null, null);
      patchApplier.execute(false, true); // 3
      boolean thereAreCreations = false;
      for (FilePatch patch : patches) {
        if (patch.isNewFile() || !Comparing.equal(patch.getAfterName(), patch.getBeforeName())) {
          thereAreCreations = true;
          break;
        }
      }
      if (thereAreCreations) {
        // restore deletion of old directory:
        myInner.next(new DirectoryAddition()); // 2
      }
      appendResolveConflictToContext(myInner); // 1
      appendTailToContextLast(myInner); // 4
      myInner.ping();
    }
  public void execute() {
    int ok =
        Messages.showOkCancelDialog(
            myVcs.getProject(),
            (myChange.isMoved()
                ? SvnBundle.message(
                    "confirmation.resolve.tree.conflict.merge.moved",
                    myOldPresentation,
                    myNewPresentation)
                : SvnBundle.message(
                    "confirmation.resolve.tree.conflict.merge.renamed",
                    myOldPresentation,
                    myNewPresentation)),
            TreeConflictRefreshablePanel.TITLE,
            Messages.getQuestionIcon());
    if (Messages.OK != ok) return;

    FileDocumentManager.getInstance().saveAllDocuments();
    // final String name = "Merge changes from theirs for: " + myOldPresentation;

    final Continuation fragmented = Continuation.createFragmented(myVcs.getProject(), false);
    fragmented.addExceptionHandler(
        VcsException.class,
        new Consumer<VcsException>() {
          @Override
          public void consume(VcsException e) {
            myWarnings.add(e);
            if (e.isWarning()) {
              return;
            }
            AbstractVcsHelper.getInstance(myVcs.getProject())
                .showErrors(myWarnings, TreeConflictRefreshablePanel.TITLE);
          }
        });

    final List<TaskDescriptor> tasks = new SmartList<TaskDescriptor>();
    tasks.add(
        myDescription.isDirectory()
            ? new PreloadChangesContentsForDir()
            : new PreloadChangesContentsForFile());
    tasks.add(new ConvertTextPaths());
    tasks.add(new PatchCreator());
    tasks.add(new SelectPatchesInApplyPatchDialog());
    tasks.add(new SelectBinaryFiles());

    fragmented.run(tasks);
  }
Ejemplo n.º 23
0
 public void conflictResolvedForFile(@NotNull VirtualFile file) {
   // TODO: Add possibility to resolve content conflicts separately from property conflicts.
   SvnVcs vcs = SvnVcs.getInstance(myProject);
   File path = new File(file.getPath());
   try {
     // TODO: Probably false should be passed to "resolveTree", but previous logic used true
     // implicitly
     vcs.getFactory(path).createConflictClient().resolve(path, Depth.EMPTY, false, true, true);
   } catch (VcsException e) {
     LOG.warn(e);
   }
   // the .mine/.r## files have been deleted
   final VirtualFile parent = file.getParent();
   if (parent != null) {
     parent.refresh(true, false);
   }
 }
 public SvnFormatWorker(
     final Project project, final WorkingCopyFormat newFormat, final List<WCInfo> wcInfos) {
   super(project, SvnBundle.message("action.change.wcopy.format.task.title"), false, DEAF);
   myProject = project;
   myNewFormat = newFormat;
   myExceptions = new ArrayList<Throwable>();
   myWcInfos = wcInfos;
   myVcs = SvnVcs.getInstance(myProject);
 }
Ejemplo n.º 25
0
  public void update(final AnActionEvent e) {
    final FileGroupInfo fileGroupInfo = new FileGroupInfo();

    myHelperAction.setFileIterationListener(fileGroupInfo);
    myHelperAction.update(e);

    myGetterStub.setDelegate(fileGroupInfo);

    if ((e.getPresentation().isEnabled())) {
      removeAll();
      if (myHelperAction.allAreIgnored()) {
        final DataContext dataContext = e.getDataContext();
        final Project project = CommonDataKeys.PROJECT.getData(dataContext);
        SvnVcs vcs = SvnVcs.getInstance(project);

        final Ref<Boolean> filesOk = new Ref<Boolean>(Boolean.FALSE);
        final Ref<Boolean> extensionOk = new Ref<Boolean>(Boolean.FALSE);

        // virtual files parameter is not used -> can pass null
        SvnPropertyService.doCheckIgnoreProperty(
            vcs,
            project,
            null,
            fileGroupInfo,
            fileGroupInfo.getExtensionMask(),
            filesOk,
            extensionOk);

        if (Boolean.TRUE.equals(filesOk.get())) {
          myRemoveExactAction.setActionText(
              fileGroupInfo.oneFileSelected()
                  ? fileGroupInfo.getFileName()
                  : SvnBundle.message("action.Subversion.UndoIgnore.text"));
          add(myRemoveExactAction);
        }

        if (Boolean.TRUE.equals(extensionOk.get())) {
          myRemoveExtensionAction.setActionText(fileGroupInfo.getExtensionMask());
          add(myRemoveExtensionAction);
        }

        e.getPresentation().setText(SvnBundle.message("group.RevertIgnoreChoicesGroup.text"));
      } else if (myHelperAction.allCanBeIgnored()) {
        final String ignoreExactlyName =
            (fileGroupInfo.oneFileSelected())
                ? fileGroupInfo.getFileName()
                : SvnBundle.message("action.Subversion.Ignore.ExactMatch.text");
        myAddExactAction.setActionText(ignoreExactlyName);
        add(myAddExactAction);
        if (fileGroupInfo.sameExtension()) {
          myAddExtensionAction.setActionText(fileGroupInfo.getExtensionMask());
          add(myAddExtensionAction);
        }
        e.getPresentation().setText(SvnBundle.message("group.IgnoreChoicesGroup.text"));
      }
    }
  }
  @Nullable
  public static SvnBranchConfigurationNew loadDefaultConfiguration(
      final Project project, final VirtualFile vcsRoot) {
    try {
      final SvnVcs vcs = SvnVcs.getInstance(project);

      File rootFile = new File(vcsRoot.getPath());
      final Info info = vcs.getInfo(rootFile);
      if (info == null || info.getURL() == null) {
        LOG.info("Directory is not a working copy: " + vcsRoot.getPresentableUrl());
        return null;
      }
      SVNURL baseUrl = info.getURL();

      final SvnBranchConfigurationNew result = new SvnBranchConfigurationNew();
      result.setTrunkUrl(baseUrl.toString());
      while (true) {
        final String s = SVNPathUtil.tail(baseUrl.getPath());
        if (s.equalsIgnoreCase(DEFAULT_TRUNK_NAME)
            || s.equalsIgnoreCase(DEFAULT_BRANCHES_NAME)
            || s.equalsIgnoreCase(DEFAULT_TAGS_NAME)) {
          SVNURL rootPath = baseUrl.removePathTail();
          SvnTarget target = SvnTarget.fromURL(rootPath);

          vcs.getFactory(target)
              .createBrowseClient()
              .list(target, SVNRevision.HEAD, Depth.IMMEDIATES, createHandler(result, rootPath));
          break;
        }
        if (SVNPathUtil.removeTail(baseUrl.getPath()).length() == 0) {
          break;
        }
        baseUrl = baseUrl.removePathTail();
      }
      return result;
    } catch (SVNException e) {
      LOG.info(e);
      return null;
    } catch (VcsException e) {
      LOG.info(e);
      return null;
    }
  }
 public void setIgnoreSpacesInAnnotate(final boolean value) {
   final boolean changed = IGNORE_SPACES_IN_ANNOTATE != value;
   IGNORE_SPACES_IN_ANNOTATE = value;
   if (changed) {
     myProject
         .getMessageBus()
         .syncPublisher(VcsAnnotationRefresher.LOCAL_CHANGES_CHANGED)
         .configurationChanged(SvnVcs.getKey());
   }
 }
 public SvnAuthenticationManager getManager(final AuthManagerType type, final SvnVcs vcs) {
   if (AuthManagerType.active.equals(type)) {
     return getInteractiveManager(vcs);
   } else if (AuthManagerType.passive.equals(type)) {
     return getPassiveAuthenticationManager(vcs.getProject());
   } else if (AuthManagerType.usual.equals(type)) {
     return getAuthenticationManager(vcs);
   }
   throw new IllegalArgumentException();
 }
 public SvnAuthenticationManager getInteractiveManager(final SvnVcs svnVcs) {
   if (myInteractiveManager == null) {
     myInteractiveManager =
         new SvnAuthenticationManager(svnVcs.getProject(), new File(getConfigurationDirectory()));
     myInteractiveManager.setRuntimeStorage(RUNTIME_AUTH_CACHE);
     myInteractiveProvider =
         new SvnInteractiveAuthenticationProvider(svnVcs, myInteractiveManager);
     myInteractiveManager.setAuthenticationProvider(myInteractiveProvider);
   }
   return myInteractiveManager;
 }
 public SvnAuthenticationManager getAuthenticationManager(final SvnVcs svnVcs) {
   if (myAuthManager == null) {
     // reloaded when configuration directory changes
     myAuthManager =
         new SvnAuthenticationManager(svnVcs.getProject(), new File(getConfigurationDirectory()));
     Disposer.register(
         svnVcs.getProject(),
         new Disposable() {
           @Override
           public void dispose() {
             myAuthManager = null;
           }
         });
     getInteractiveManager(svnVcs);
     // to init
     myAuthManager.setAuthenticationProvider(
         new SvnAuthenticationProvider(svnVcs, myInteractiveProvider, RUNTIME_AUTH_CACHE));
     myAuthManager.setRuntimeStorage(RUNTIME_AUTH_CACHE);
   }
   return myAuthManager;
 }