Package org.eclipse.jgit.diff

Examples of org.eclipse.jgit.diff.DiffEntry


    }

    if (n.sourceCommit == null)
      return result(n);

    DiffEntry r = findRename(parent, n.sourceCommit, n.sourcePath);
    if (r == null)
      return result(n);

    if (0 == r.getOldId().prefixCompare(n.sourceBlob)) {
      // A 100% rename without any content change can also
      // skip directly to the parent.
      n.sourceCommit = parent;
      n.sourcePath = PathFilter.create(r.getOldPath());
      push(n);
      return false;
    }

    Candidate next = n.create(parent, PathFilter.create(r.getOldPath()));
    next.sourceBlob = r.getOldId().toObjectId();
    next.renameScore = r.getScore();
    next.loadText(reader);
    return split(next, n);
  }
View Full Code Here


      for (int pIdx = 0; pIdx < pCnt; pIdx++) {
        RevCommit parent = n.getParent(pIdx);
        if (ids != null && ids[pIdx] != null)
          continue;

        DiffEntry r = findRename(parent, n.sourceCommit, n.sourcePath);
        if (r == null)
          continue;

        if (n instanceof ReverseCandidate) {
          if (ids == null)
            ids = new ObjectId[pCnt];
          ids[pCnt] = r.getOldId().toObjectId();
        } else if (0 == r.getOldId().prefixCompare(n.sourceBlob)) {
          // A 100% rename without any content change can also
          // skip directly to the parent. Note this bypasses an
          // earlier parent that had the path (above) but did not
          // have an exact content match. For performance reasons
          // we choose to follow the one parent over trying to do
          // possibly both parents.
          n.sourcePath = PathFilter.create(r.getOldPath());
          return blameEntireRegionOnParent(n, parent);
        }

        renames[pIdx] = r;
      }
View Full Code Here

    walk.addTree(commit.getTree());
    walk.addTree(submoduleCommit.getTree());
    walk.setFilter(TreeFilter.ANY_DIFF);
    List<DiffEntry> diffs = DiffEntry.scan(walk);
    assertEquals(1, diffs.size());
    DiffEntry subDiff = diffs.get(0);
    assertEquals(FileMode.MISSING, subDiff.getOldMode());
    assertEquals(FileMode.GITLINK, subDiff.getNewMode());
    assertEquals(ObjectId.zeroId(), subDiff.getOldId().toObjectId());
    assertEquals(commit, subDiff.getNewId().toObjectId());
    assertEquals(path, subDiff.getNewPath());
  }
View Full Code Here

    walk.addTree(submoduleAddCommit.getTree());
    walk.addTree(submoduleEditCommit.getTree());
    walk.setFilter(TreeFilter.ANY_DIFF);
    List<DiffEntry> diffs = DiffEntry.scan(walk);
    assertEquals(1, diffs.size());
    DiffEntry subDiff = diffs.get(0);
    assertEquals(FileMode.GITLINK, subDiff.getOldMode());
    assertEquals(FileMode.GITLINK, subDiff.getNewMode());
    assertEquals(commit2, subDiff.getOldId().toObjectId());
    assertEquals(commit, subDiff.getNewId().toObjectId());
    assertEquals(path, subDiff.getNewPath());
    assertEquals(path, subDiff.getOldPath());
  }
View Full Code Here

    Assert.assertEquals("Unexpected number of renames. Expected: " +
        expectedRenames.length + ", actual: " + diffCollector.diffs.size(),
        expectedRenames.length, diffCollector.diffs.size());

    for (int i = 0; i < expectedRenames.length; i++) {
      DiffEntry diff = diffCollector.diffs.get(i);
      Assert.assertNotNull(diff);
      String[] split = expectedRenames[i].split("->");

      Assert.assertNotNull(split);
      Assert.assertEquals(2, split.length);
      String src = split[0];
      String target = split[1];

      Assert.assertEquals(src, diff.getOldPath());
      Assert.assertEquals(target, diff.getNewPath());
    }
  }
View Full Code Here

    int pageSize = request.getParameter("pageSize") != null ? new Integer(request.getParameter("pageSize")).intValue() : Integer.MAX_VALUE; //$NON-NLS-1$ //$NON-NLS-2$
    int start = pageSize * (page - 1);
    int end = Math.min(pageSize + start, l.size());
    int i = start;
    for (i = start; i < end; i++) {
      DiffEntry entr = l.get(i);
      JSONObject diff = new JSONObject();
      diff.put(ProtocolConstants.KEY_TYPE, org.eclipse.orion.server.git.objects.Diff.TYPE);
      diff.put(GitConstants.KEY_COMMIT_DIFF_NEWPATH, entr.getNewPath());
      diff.put(GitConstants.KEY_COMMIT_DIFF_OLDPATH, entr.getOldPath());
      diff.put(GitConstants.KEY_COMMIT_DIFF_CHANGETYPE, entr.getChangeType().toString());

      // add diff location for the commit
      String path = entr.getChangeType() != ChangeType.DELETE ? entr.getNewPath() : entr.getOldPath();
      diff.put(GitConstants.KEY_DIFF, createDiffLocation(diffLocation, path));
      diff.put(ProtocolConstants.KEY_CONTENT_LOCATION, createContentLocation(cloneLocation, entr, path));

      diffs.put(diff);
    }
View Full Code Here

      int page = 1;
      int start = pageSize * (page - 1);
      int end = Math.min(pageSize + start, l.size());
      int i = start;
      for (i = start; i < end; i++) {
        DiffEntry entr = l.get(i);
        JSONObject diff = new JSONObject();
        diff.put(ProtocolConstants.KEY_TYPE, org.eclipse.orion.server.git.objects.Diff.TYPE);
        diff.put(GitConstants.KEY_COMMIT_DIFF_NEWPATH, entr.getNewPath());
        diff.put(GitConstants.KEY_COMMIT_DIFF_OLDPATH, entr.getOldPath());
        diff.put(GitConstants.KEY_COMMIT_DIFF_CHANGETYPE, entr.getChangeType().toString());

        // add diff location for the commit
        String path = entr.getChangeType() != ChangeType.DELETE ? entr.getNewPath() : entr.getOldPath();
        diff.put(GitConstants.KEY_DIFF, createDiffLocation(revCommit.getName(), fromName, path));
        diff.put(ProtocolConstants.KEY_CONTENT_LOCATION, createContentLocation(entr, path));
        diff.put(GitConstants.KEY_TREE, createTreeLocation(path));

        diffs.put(diff);
View Full Code Here

    }

    if (n.sourceCommit == null)
      return result(n);

    DiffEntry r = findRename(parent, n.sourceCommit, n.sourcePath);
    if (r == null)
      return result(n);

    if (0 == r.getOldId().prefixCompare(n.sourceBlob)) {
      // A 100% rename without any content change can also
      // skip directly to the parent.
      n.sourceCommit = parent;
      n.sourcePath = PathFilter.create(r.getOldPath());
      push(n);
      return false;
    }

    Candidate next = n.create(parent, PathFilter.create(r.getOldPath()));
    next.sourceBlob = r.getOldId().toObjectId();
    next.renameScore = r.getScore();
    next.loadText(reader);
    return split(next, n);
  }
View Full Code Here

        if (parent.has(SEEN))
          continue;
        if (ids != null && ids[pIdx] != null)
          continue;

        DiffEntry r = findRename(parent, n.sourceCommit, n.sourcePath);
        if (r == null)
          continue;

        if (n instanceof ReverseCandidate) {
          if (ids == null)
            ids = new ObjectId[pCnt];
          ids[pCnt] = r.getOldId().toObjectId();
        } else if (0 == r.getOldId().prefixCompare(n.sourceBlob)) {
          // A 100% rename without any content change can also
          // skip directly to the parent. Note this bypasses an
          // earlier parent that had the path (above) but did not
          // have an exact content match. For performance reasons
          // we choose to follow the one parent over trying to do
          // possibly both parents.
          n.sourceCommit = parent;
          n.sourcePath = PathFilter.create(r.getOldPath());
          push(n);
          return false;
        }

        renames[pIdx] = r;
View Full Code Here

  }

  protected String getPreviousPath(Repository repository,
      ObjectReader reader, RevCommit headCommit,
      RevCommit previousCommit, String path) throws IOException {
    DiffEntry diffEntry = CompareCoreUtils.getChangeDiffEntry(repository, path,
        headCommit, previousCommit, reader);
    if (diffEntry != null)
      return diffEntry.getOldPath();
    else
      return path;
  }
View Full Code Here

TOP

Related Classes of org.eclipse.jgit.diff.DiffEntry

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.