public void reportAppendableHistory(
      FilePath path, final VcsAppendableHistorySessionPartner partner) throws VcsException {
    final FilePath committedPath = ChangesUtil.getCommittedPath(myVcs.getProject(), path);

    final LogLoader logLoader;
    if (path.isNonLocal()) {
      logLoader = new RepositoryLoader(myVcs, path);
    } else {
      logLoader = new LocalLoader(myVcs, path);
    }

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

    final MyHistorySession historySession =
        new MyHistorySession(
            Collections.<VcsFileRevision>emptyList(),
            committedPath,
            Boolean.TRUE.equals(logLoader.mySupport15),
            null);

    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>() {
          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();
  }
Ejemplo n.º 2
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();
  }