private static boolean isUndo(SvnVcs vcs) {
   if (vcs == null || vcs.getProject() == null) {
     return false;
   }
   Project p = vcs.getProject();
   return UndoManager.getInstance(p).isUndoInProgress();
 }
 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 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 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);
  }
  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);
            }
          }
        }
      }
    }
  }
  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);
                          }
                        }
                      }
                    });
          }
        });
  }
 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;
 }
  @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));
  }
 @Nullable
 public FilePath getFilePath(final SvnVcs vcs) {
   if (!myHadChanged) return null;
   final SvnFileUrlMapping svnFileUrlMapping = vcs.getSvnFileUrlMapping();
   final String absolutePath = SVNPathUtil.append(myRepositoryRoot, myCurrentPath);
   final String localPath = svnFileUrlMapping.getLocalPath(absolutePath);
   if (localPath == null) {
     LOG.info("Cannot find local path for url: " + absolutePath);
     return null;
   }
   return new FilePathImpl(new File(localPath), false);
 }
Exemplo n.º 12
0
 @Override
 public void reportAppendableHistory(
     FilePath path, final VcsAppendableHistorySessionPartner partner) throws VcsException {
   // we need + 1 rows to be reported to further detect that number of rows exceeded the limit
   reportAppendableHistory(
       path,
       partner,
       null,
       null,
       VcsConfiguration.getInstance(myVcs.getProject()).MAXIMUM_HISTORY_ROWS + 1,
       null,
       false);
 }
  public void loadCommittedChanges(
      ChangeBrowserSettings settings,
      RepositoryLocation location,
      int maxCount,
      final AsynchConsumer<CommittedChangeList> consumer)
      throws VcsException {
    try {
      final SvnRepositoryLocation svnLocation = (SvnRepositoryLocation) location;
      final ProgressIndicator progress = ProgressManager.getInstance().getProgressIndicator();
      if (progress != null) {
        progress.setText(SvnBundle.message("progress.text.changes.collecting.changes"));
        progress.setText2(
            SvnBundle.message("progress.text2.changes.establishing.connection", location));
      }

      final String repositoryRoot;
      SVNRepository repository = null;
      try {
        repository = myVcs.createRepository(svnLocation.getURL());
        repositoryRoot = repository.getRepositoryRoot(true).toString();
      } catch (SVNException e) {
        throw new VcsException(e);
      } finally {
        if (repository != null) {
          repository.closeSession();
        }
      }

      final ChangeBrowserSettings.Filter filter = settings.createFilter();

      getCommittedChangesImpl(
          settings,
          svnLocation.getURL(),
          new String[] {""},
          maxCount,
          new Consumer<SVNLogEntry>() {
            public void consume(final SVNLogEntry svnLogEntry) {
              final SvnChangeList cl =
                  new SvnChangeList(myVcs, svnLocation, svnLogEntry, repositoryRoot);
              if (filter.accepts(cl)) {
                consumer.consume(cl);
              }
            }
          },
          false,
          true);
    } finally {
      consumer.finished();
    }
  }
  /**
   * add file or directory:
   *
   * <p>parent directory is: unversioned: do nothing, return false versioned: entry is: null: create
   * entry, schedule for addition missing: do nothing, return false deleted, 'do' mode: try to
   * create entry and it schedule for addition if kind is the same, otherwise do nothing, return
   * false. deleted: 'undo' mode: try to revert non-recursively, if kind is the same, otherwise do
   * nothing, return false. anything else: return false.
   */
  private boolean createItem(
      VirtualFile dir, String name, boolean directory, final boolean recursive) {
    SvnVcs vcs = getVCS(dir);
    if (vcs == null) {
      return false;
    }
    final VcsShowConfirmationOption.Value value = vcs.getAddConfirmation().getValue();
    if (VcsShowConfirmationOption.Value.DO_NOTHING_SILENTLY.equals(value)) return false;

    if (isUndo(vcs) && SvnUtil.isAdminDirectory(dir, name)) {
      return false;
    }
    File ioDir = getIOFile(dir);
    boolean pendingAdd = isPendingAdd(vcs.getProject(), dir);
    if (!SvnUtil.isSvnVersioned(vcs.getProject(), ioDir) && !pendingAdd) {
      return false;
    }
    final File targetFile = new File(ioDir, name);
    SVNStatus status = getFileStatus(vcs, targetFile);

    if (status == null
        || status.getContentsStatus() == SVNStatusType.STATUS_NONE
        || status.getContentsStatus() == SVNStatusType.STATUS_UNVERSIONED) {
      myAddedFiles.putValue(vcs.getProject(), new AddedFileInfo(dir, name, null, recursive));
      return false;
    } else if (SvnVcs.svnStatusIs(status, SVNStatusType.STATUS_MISSING)) {
      return false;
    } else if (SvnVcs.svnStatusIs(status, SVNStatusType.STATUS_DELETED)) {
      SVNNodeKind kind = status.getKind();
      // kind differs.
      if (directory && kind != SVNNodeKind.DIR || !directory && kind != SVNNodeKind.FILE) {
        return false;
      }
      try {
        if (isUndo(vcs)) {
          createRevertAction(vcs, targetFile, false).execute();
          return true;
        }
        myAddedFiles.putValue(vcs.getProject(), new AddedFileInfo(dir, name, null, recursive));
        return false;
      } catch (SVNException e) {
        SVNFileUtil.deleteAll(targetFile, true);
        return false;
      }
    }
    return false;
  }
 private void processAddedFiles(Project project) {
   SvnVcs vcs = SvnVcs.getInstance(project);
   List<VirtualFile> addedVFiles = new ArrayList<VirtualFile>();
   Map<VirtualFile, File> copyFromMap = new HashMap<VirtualFile, File>();
   final Set<VirtualFile> recursiveItems = new HashSet<VirtualFile>();
   fillAddedFiles(project, vcs, addedVFiles, copyFromMap, recursiveItems);
   if (addedVFiles.isEmpty()) return;
   final VcsShowConfirmationOption.Value value = vcs.getAddConfirmation().getValue();
   if (value != VcsShowConfirmationOption.Value.DO_NOTHING_SILENTLY) {
     final AbstractVcsHelper vcsHelper = AbstractVcsHelper.getInstance(project);
     final Collection<VirtualFile> filesToProcess =
         promptAboutAddition(vcs, addedVFiles, value, vcsHelper);
     if (filesToProcess != null && !filesToProcess.isEmpty()) {
       final List<VcsException> exceptions = new ArrayList<VcsException>();
       runInBackground(
           project,
           "Adding files to Subversion",
           createAdditionRunnable(project, vcs, copyFromMap, filesToProcess, exceptions));
       if (!exceptions.isEmpty()) {
         vcsHelper.showErrors(exceptions, SvnBundle.message("add.files.errors.title"));
       }
     }
   }
 }
 private void fillDeletedFiles(
     Project project,
     List<Pair<FilePath, WorkingCopyFormat>> deletedFiles,
     Collection<FilePath> deleteAnyway)
     throws SVNException {
   final SvnVcs vcs = SvnVcs.getInstance(project);
   final Collection<File> files = myDeletedFiles.remove(project);
   for (final File file : files) {
     final SVNStatus status =
         new RepeatSvnActionThroughBusy() {
           @Override
           protected void executeImpl() throws SVNException {
             myT = vcs.getFactory(file).createStatusClient().doStatus(file, false);
           }
         }.compute();
     boolean isAdded = SVNStatusType.STATUS_ADDED.equals(status.getNodeStatus());
     final FilePath filePath = VcsContextFactory.SERVICE.getInstance().createFilePathOn(file);
     if (isAdded) {
       deleteAnyway.add(filePath);
     } else {
       deletedFiles.add(Pair.create(filePath, vcs.getWorkingCopyFormat(file)));
     }
   }
 }
  @Nullable
  public File copy(final VirtualFile file, final VirtualFile toDir, final String copyName)
      throws IOException {
    SvnVcs vcs = getVCS(toDir);
    if (vcs == null) {
      vcs = getVCS(file);
    }
    if (vcs == null) {
      return null;
    }

    File srcFile = new File(file.getPath());
    File destFile = new File(new File(toDir.getPath()), copyName);
    final boolean dstDirUnderControl =
        SvnUtil.isSvnVersioned(vcs.getProject(), destFile.getParentFile());
    if (!dstDirUnderControl && !isPendingAdd(vcs.getProject(), toDir)) {
      return null;
    }

    if (!SvnUtil.isSvnVersioned(vcs.getProject(), srcFile.getParentFile())) {
      myAddedFiles.putValue(vcs.getProject(), new AddedFileInfo(toDir, copyName, null, false));
      return null;
    }

    final SVNStatus fileStatus = getFileStatus(vcs, srcFile);
    if (fileStatus != null && SvnVcs.svnStatusIs(fileStatus, SVNStatusType.STATUS_ADDED)) {
      myAddedFiles.putValue(vcs.getProject(), new AddedFileInfo(toDir, copyName, null, false));
      return null;
    }

    if (sameRoot(vcs, file.getParent(), toDir)) {
      myAddedFiles.putValue(vcs.getProject(), new AddedFileInfo(toDir, copyName, srcFile, false));
      return null;
    }

    myAddedFiles.putValue(vcs.getProject(), new AddedFileInfo(toDir, copyName, null, false));
    return null;
  }
  public List<SvnChangeList> getCommittedChanges(
      ChangeBrowserSettings settings, final RepositoryLocation location, final int maxCount)
      throws VcsException {
    final SvnRepositoryLocation svnLocation = (SvnRepositoryLocation) location;
    final ArrayList<SvnChangeList> result = new ArrayList<SvnChangeList>();
    final ProgressIndicator progress = ProgressManager.getInstance().getProgressIndicator();
    if (progress != null) {
      progress.setText(SvnBundle.message("progress.text.changes.collecting.changes"));
      progress.setText2(
          SvnBundle.message("progress.text2.changes.establishing.connection", location));
    }

    final String repositoryRoot;
    SVNRepository repository = null;
    try {
      repository = myVcs.createRepository(svnLocation.getURL());
      repositoryRoot = repository.getRepositoryRoot(true).toString();
      repository.closeSession();
    } catch (SVNException e) {
      throw new VcsException(e);
    } finally {
      if (repository != null) {
        repository.closeSession();
      }
    }

    getCommittedChangesImpl(
        settings,
        svnLocation.getURL(),
        new String[] {""},
        maxCount,
        new Consumer<SVNLogEntry>() {
          public void consume(final SVNLogEntry svnLogEntry) {
            result.add(new SvnChangeList(myVcs, svnLocation, svnLogEntry, repositoryRoot));
          }
        },
        false,
        true);
    settings.filterChanges(result);
    return result;
  }
  private boolean doMove(@NotNull SvnVcs vcs, final File src, final File dst) {
    long srcTime = src.lastModified();
    try {
      final boolean isUndo = isUndo(vcs);
      final String list = isUndo ? null : SvnChangelistListener.getCurrentMapping(vcs, src);

      WorkingCopyFormat format = vcs.getWorkingCopyFormat(src);
      final boolean is17OrLater =
          WorkingCopyFormat.ONE_DOT_EIGHT.equals(format)
              || WorkingCopyFormat.ONE_DOT_SEVEN.equals(format);
      if (is17OrLater) {
        SVNStatus srcStatus = getFileStatus(vcs, src);
        final File toDir = dst.getParentFile();
        SVNStatus dstStatus = getFileStatus(vcs, toDir);
        final boolean srcUnversioned =
            srcStatus == null || SvnVcs.svnStatusIsUnversioned(srcStatus);
        if (srcUnversioned && (dstStatus == null || SvnVcs.svnStatusIsUnversioned(dstStatus))) {
          return false;
        }
        if (srcUnversioned) {
          SVNStatus dstWasStatus = getFileStatus(vcs, dst);
          if (dstWasStatus == null || SvnVcs.svnStatusIsUnversioned(dstWasStatus)) {
            return false;
          }
        }
        if (for17move(vcs, src, dst, isUndo, srcStatus)) return false;
      } else {
        if (for16move(vcs, src, dst, isUndo)) return false;
      }

      if (!isUndo && list != null) {
        SvnChangelistListener.putUnderList(vcs.getProject(), list, dst);
      }
      dst.setLastModified(srcTime);
    } catch (SVNException e) {
      addToMoveExceptions(vcs.getProject(), e);
      return false;
    } catch (VcsException e) {
      addToMoveExceptions(vcs.getProject(), e);
      return false;
    }
    return true;
  }
  private Collection<FilePath> promptAboutDeletion(
      List<Pair<FilePath, WorkingCopyFormat>> deletedFiles,
      SvnVcs vcs,
      VcsShowConfirmationOption.Value value,
      AbstractVcsHelper vcsHelper) {
    final Convertor<Pair<FilePath, WorkingCopyFormat>, FilePath> convertor =
        new Convertor<Pair<FilePath, WorkingCopyFormat>, FilePath>() {
          @Override
          public FilePath convert(Pair<FilePath, WorkingCopyFormat> o) {
            return o.getFirst();
          }
        };
    Collection<FilePath> filesToProcess;
    if (value == VcsShowConfirmationOption.Value.DO_ACTION_SILENTLY) {
      filesToProcess = ObjectsConvertor.convert(deletedFiles, convertor);
    } else {

      final String singleFilePrompt;
      if (deletedFiles.size() == 1 && deletedFiles.get(0).getFirst().isDirectory()) {
        singleFilePrompt =
            WorkingCopyFormat.ONE_DOT_SEVEN.equals(deletedFiles.get(0).getSecond())
                ? SvnBundle.getString("confirmation.text.delete.dir.17")
                : SvnBundle.getString("confirmation.text.delete.dir");
      } else {
        singleFilePrompt = SvnBundle.getString("confirmation.text.delete.file");
      }
      final Collection<FilePath> files =
          vcsHelper.selectFilePathsToProcess(
              ObjectsConvertor.convert(deletedFiles, convertor),
              SvnBundle.message("confirmation.title.delete.multiple.files"),
              null,
              SvnBundle.message("confirmation.title.delete.file"),
              singleFilePrompt,
              vcs.getDeleteConfirmation());
      filesToProcess = files == null ? null : new ArrayList<FilePath>(files);
    }
    return filesToProcess;
  }
 private boolean for16move(SvnVcs vcs, final File src, final File dst, boolean undo)
     throws SVNException {
   final SVNMoveClient mover = vcs.createMoveClient();
   if (undo) {
     myUndoingMove = true;
     restoreFromUndoStorage(dst);
     new RepeatSvnActionThroughBusy() {
       @Override
       protected void executeImpl() throws SVNException {
         mover.undoMove(src, dst);
       }
     }.execute();
   } else {
     // if src is not under version control, do usual move.
     if (doUsualMove(vcs, src)) return true;
     new RepeatSvnActionThroughBusy() {
       @Override
       protected void executeImpl() throws SVNException {
         mover.doMove(src, dst);
       }
     }.execute();
   }
   return false;
 }
Exemplo n.º 22
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();
  }
  /**
   * delete file or directory (both 'undo' and 'do' modes) unversioned: do nothing, return false
   * obstructed: do nothing, return false external or wc root: do nothing, return false missing: do
   * nothing, return false
   *
   * <p>versioned: schedule for deletion, return true added: schedule for deletion (make
   * unversioned), return true copied, but not scheduled: schedule for deletion, return true
   * replaced: schedule for deletion, return true
   *
   * <p>deleted: do nothing, return true (strange)
   */
  public boolean delete(VirtualFile file) throws IOException {
    final SvnVcs vcs = getVCS(file);
    if (vcs != null && SvnUtil.isAdminDirectory(file)) {
      return true;
    }
    if (vcs == null) return false;
    final VcsShowConfirmationOption.Value value = vcs.getDeleteConfirmation().getValue();
    if (VcsShowConfirmationOption.Value.DO_NOTHING_SILENTLY.equals(value)) return false;

    final File ioFile = getIOFile(file);
    if (!SvnUtil.isSvnVersioned(vcs.getProject(), ioFile.getParentFile())) {
      return false;
    }
    if (SvnUtil.isWorkingCopyRoot(ioFile)) {
      return false;
    }

    SVNStatus status = getFileStatus(vcs, ioFile);

    if (status == null
        || SvnVcs.svnStatusIsUnversioned(status)
        || SvnVcs.svnStatusIs(status, SVNStatusType.STATUS_OBSTRUCTED)
        || SvnVcs.svnStatusIs(status, SVNStatusType.STATUS_MISSING)
        || SvnVcs.svnStatusIs(status, SVNStatusType.STATUS_EXTERNAL)
        || SvnVcs.svnStatusIs(status, SVNStatusType.STATUS_IGNORED)) {
      return false;
    } else if (SvnVcs.svnStatusIs(status, SVNStatusType.STATUS_DELETED)) {
      if (isUndo(vcs)) {
        moveToUndoStorage(file);
      }
      return true;
    } else {
      if (vcs != null) {
        if (isAboveSourceOfCopyOrMove(vcs.getProject(), ioFile)) {
          myDeletedFiles.putValue(vcs.getProject(), ioFile);
          return true;
        }
        if (SvnVcs.svnStatusIs(status, SVNStatusType.STATUS_ADDED)) {
          try {
            createRevertAction(vcs, ioFile, false).execute();
          } catch (SVNException e) {
            // ignore
          }
        } else {
          myDeletedFiles.putValue(vcs.getProject(), ioFile);
          // packages deleted from disk should not be deleted from svn (IDEADEV-16066)
          if (file.isDirectory() || isUndo(vcs)) return true;
        }
      }
      return false;
    }
  }
  public void getCommittedChangesWithMergedRevisons(
      final ChangeBrowserSettings settings,
      final RepositoryLocation location,
      final int maxCount,
      final PairConsumer<SvnChangeList, TreeStructureNode<SVNLogEntry>> finalConsumer)
      throws VcsException {
    final SvnRepositoryLocation svnLocation = (SvnRepositoryLocation) location;
    final ProgressIndicator progress = ProgressManager.getInstance().getProgressIndicator();
    if (progress != null) {
      progress.setText(SvnBundle.message("progress.text.changes.collecting.changes"));
      progress.setText2(
          SvnBundle.message("progress.text2.changes.establishing.connection", location));
    }

    final String repositoryRoot;
    SVNRepository repository = null;
    try {
      repository = myVcs.createRepository(svnLocation.getURL());
      repositoryRoot = repository.getRepositoryRoot(true).toString();
    } catch (SVNException e) {
      throw new VcsException(e);
    } finally {
      if (repository != null) {
        repository.closeSession();
      }
    }

    final MergeTrackerProxy proxy =
        new MergeTrackerProxy(
            new Consumer<TreeStructureNode<SVNLogEntry>>() {
              public void consume(TreeStructureNode<SVNLogEntry> node) {
                finalConsumer.consume(
                    new SvnChangeList(myVcs, svnLocation, node.getMe(), repositoryRoot), node);
              }
            });
    final SvnMergeSourceTracker mergeSourceTracker =
        new SvnMergeSourceTracker(
            new ThrowableConsumer<Pair<SVNLogEntry, Integer>, SVNException>() {
              public void consume(Pair<SVNLogEntry, Integer> svnLogEntryIntegerPair)
                  throws SVNException {
                proxy.consume(svnLogEntryIntegerPair);
              }
            });

    getCommittedChangesImpl(
        settings,
        svnLocation.getURL(),
        new String[] {""},
        maxCount,
        new Consumer<SVNLogEntry>() {
          public void consume(final SVNLogEntry svnLogEntry) {
            try {
              mergeSourceTracker.consume(svnLogEntry);
            } catch (SVNException e) {
              throw new RuntimeException(e);
              // will not occur actually but anyway never eat them
            }
          }
        },
        true,
        false);

    proxy.finish();
  }
  @Override
  public Pair<SvnChangeList, FilePath> getOneList(final VirtualFile file, VcsRevisionNumber number)
      throws VcsException {
    final RootUrlInfo rootUrlInfo =
        myVcs.getSvnFileUrlMapping().getWcRootForFilePath(new File(file.getPath()));
    if (rootUrlInfo == null) return null;
    final VirtualFile root = rootUrlInfo.getVirtualFile();
    if (root == null) return null;
    final SvnRepositoryLocation svnRootLocation =
        (SvnRepositoryLocation) getLocationFor(new FilePathImpl(root));
    if (svnRootLocation == null) return null;
    final String url = svnRootLocation.getURL();
    final long revision;
    try {
      revision = Long.parseLong(number.asString());
    } catch (NumberFormatException e) {
      throw new VcsException(e);
    }

    final SvnChangeList[] result = new SvnChangeList[1];
    final SVNLogClient logger;
    final SVNRevision revisionBefore;
    final SVNURL repositoryUrl;
    final SVNURL svnurl;
    final SVNInfo targetInfo;
    try {
      logger = myVcs.createLogClient();
      revisionBefore = SVNRevision.create(revision);

      svnurl = SVNURL.parseURIEncoded(url);
      final SVNWCClient client = myVcs.createWCClient();
      final SVNInfo info = client.doInfo(svnurl, SVNRevision.UNDEFINED, SVNRevision.HEAD);
      targetInfo = client.doInfo(new File(file.getPath()), SVNRevision.UNDEFINED);
      if (info == null) {
        throw new VcsException("Can not get repository URL");
      }
      repositoryUrl = info.getRepositoryRootURL();
    } catch (SVNException e) {
      LOG.info(e);
      throw new VcsException(e);
    }

    tryExactHit(svnRootLocation, result, logger, revisionBefore, repositoryUrl, svnurl);
    if (result[0] == null) {
      tryByRoot(result, logger, revisionBefore, repositoryUrl);
      if (result[0] == null) {
        FilePath path =
            tryStepByStep(svnRootLocation, result, logger, revisionBefore, targetInfo, svnurl);
        path = path == null ? new FilePathImpl(file) : path;
        // and pass & take rename context there
        return new Pair<SvnChangeList, FilePath>(result[0], path);
      }
    }
    if (result[0].getChanges().size() == 1) {
      final Collection<Change> changes = result[0].getChanges();
      final Change change = changes.iterator().next();
      final ContentRevision afterRevision = change.getAfterRevision();
      if (afterRevision != null) {
        return new Pair<SvnChangeList, FilePath>(result[0], afterRevision.getFile());
      } else {
        return new Pair<SvnChangeList, FilePath>(result[0], new FilePathImpl(file));
      }
    }
    String relativePath =
        SVNPathUtil.getRelativePath(
            targetInfo.getRepositoryRootURL().toString(), targetInfo.getURL().toString());
    relativePath = relativePath.startsWith("/") ? relativePath : "/" + relativePath;
    final Change targetChange = result[0].getByPath(relativePath);
    if (targetChange == null) {
      FilePath path =
          tryStepByStep(svnRootLocation, result, logger, revisionBefore, targetInfo, svnurl);
      path = path == null ? new FilePathImpl(file) : path;
      // and pass & take rename context there
      return new Pair<SvnChangeList, FilePath>(result[0], path);
    }
    return new Pair<SvnChangeList, FilePath>(result[0], new FilePathImpl(file));
  }
  private void getCommittedChangesImpl(
      ChangeBrowserSettings settings,
      final String url,
      final String[] filterUrls,
      final int maxCount,
      final Consumer<SVNLogEntry> resultConsumer,
      final boolean includeMergedRevisions,
      final boolean filterOutByDate)
      throws VcsException {
    final ProgressIndicator progress = ProgressManager.getInstance().getProgressIndicator();
    if (progress != null) {
      progress.setText(SvnBundle.message("progress.text.changes.collecting.changes"));
      progress.setText2(SvnBundle.message("progress.text2.changes.establishing.connection", url));
    }
    try {
      SVNLogClient logger = myVcs.createLogClient();

      final String author = settings.getUserFilter();
      final Date dateFrom = settings.getDateAfterFilter();
      final Long changeFrom = settings.getChangeAfterFilter();
      final Date dateTo = settings.getDateBeforeFilter();
      final Long changeTo = settings.getChangeBeforeFilter();

      final SVNRevision revisionBefore;
      if (dateTo != null) {
        revisionBefore = SVNRevision.create(dateTo);
      } else if (changeTo != null) {
        revisionBefore = SVNRevision.create(changeTo.longValue());
      } else {
        SVNRepository repository = null;
        final long revision;
        try {
          repository = myVcs.createRepository(url);
          revision = repository.getLatestRevision();
        } finally {
          if (repository != null) {
            repository.closeSession();
          }
        }
        revisionBefore = SVNRevision.create(revision);
      }
      final SVNRevision revisionAfter;
      if (dateFrom != null) {
        revisionAfter = SVNRevision.create(dateFrom);
      } else if (changeFrom != null) {
        revisionAfter = SVNRevision.create(changeFrom.longValue());
      } else {
        revisionAfter = SVNRevision.create(1);
      }

      logger.doLog(
          SVNURL.parseURIEncoded(url),
          filterUrls,
          revisionBefore,
          revisionBefore,
          revisionAfter,
          settings.STOP_ON_COPY,
          true,
          includeMergedRevisions,
          maxCount,
          null,
          new ISVNLogEntryHandler() {
            public void handleLogEntry(SVNLogEntry logEntry) {
              if (myProject.isDisposed()) throw new ProcessCanceledException();
              if (progress != null) {
                progress.setText2(
                    SvnBundle.message(
                        "progress.text2.processing.revision", logEntry.getRevision()));
                progress.checkCanceled();
              }
              if (filterOutByDate && logEntry.getDate() == null) {
                // do not add lists without info - this situation is possible for lists where there
                // are paths that user has no rights to observe
                return;
              }
              if (author == null || author.equalsIgnoreCase(logEntry.getAuthor())) {
                resultConsumer.consume(logEntry);
              }
            }
          });
    } catch (SVNException e) {
      throw new VcsException(e);
    }
  }