Exemplo n.º 1
0
  public void buildCompositeCommits() throws IOException {
    revWalk = new RevWalk(repository);
    ByteArrayOutputStream diffTexts = new ByteArrayOutputStream();
    DiffFormatter df = new DiffFormatter(diffTexts);
    df.setRepository(repository);
    df.setDiffComparator(RawTextComparator.WS_IGNORE_ALL);
    df.setContext(0);
    df.setDiffAlgorithm(DiffAlgorithm.getAlgorithm(SupportedAlgorithm.HISTOGRAM));
    df.setDetectRenames(true);
    for (int idx = 0; idx < _commits.size(); idx++) {
      RevCommit commit = revWalk.parseCommit(_commits.get(idx));
      int p_count = commit.getParentCount();
      if (p_count == 0) {
        throw new RuntimeException("commit with no parent ?!?!");
      }
      RevCommit p = revWalk.parseCommit(commit.getParent(0).getId());
      List<DiffEntry> diffs = df.scan(p.getTree(), commit.getTree());
      for (DiffEntry d : diffs) {
        CompositeDiff cd = new CompositeDiff(d, commit);

        if (ParsingUtils.isSourceFile(d.getOldPath())
            || ParsingUtils.isSourceFile(d.getNewPath())) {
          extractCodeEdits(diffTexts, df, d, cd);
        }
        _diffs.add(cd);
      }
    }
    revWalk.release();
  }
Exemplo n.º 2
0
  /**
   * @param local
   * @param inCore
   */
  protected ResolveMerger(Repository local, boolean inCore) {
    super(local);
    SupportedAlgorithm diffAlg =
        local
            .getConfig()
            .getEnum(
                ConfigConstants.CONFIG_DIFF_SECTION,
                null,
                ConfigConstants.CONFIG_KEY_ALGORITHM,
                SupportedAlgorithm.HISTOGRAM);
    mergeAlgorithm = new MergeAlgorithm(DiffAlgorithm.getAlgorithm(diffAlg));
    commitNames =
        new String[] {"BASE", "OURS", "THEIRS"}; // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    this.inCore = inCore;

    if (inCore) {
      implicitDirCache = false;
      dircache = DirCache.newInCore();
    } else {
      implicitDirCache = true;
    }
  }