Package org.eclipse.jgit.diff

Examples of org.eclipse.jgit.diff.EditList


          if (tw.getFileMode(0).getObjectType() == Constants.OBJ_BLOB)
            oldImage = openBlob(0);
          else
            oldImage = new byte[0];

          EditList edits = new MyersDiff(new RawText(oldImage),
              new RawText(openBlob(1))).getEdits();
          for (Edit e : edits)
            addedLines += e.getEndB() - e.getBeginB();
        }
View Full Code Here


public class EditListTest extends TestCase {
  public void testHunkHeader() throws IOException {
    final Patch p = parseTestPatchFile("testGetText_BothISO88591.patch");
    final FileHeader fh = p.getFiles().get(0);

    final EditList list0 = fh.getHunks().get(0).toEditList();
    assertEquals(1, list0.size());
    assertEquals(new Edit(4 - 1, 5 - 1, 4 - 1, 5 - 1), list0.get(0));

    final EditList list1 = fh.getHunks().get(1).toEditList();
    assertEquals(1, list1.size());
    assertEquals(new Edit(16 - 1, 17 - 1, 16 - 1, 17 - 1), list1.get(0));
  }
View Full Code Here

  }

  public void testFileHeader() throws IOException {
    final Patch p = parseTestPatchFile("testGetText_BothISO88591.patch");
    final FileHeader fh = p.getFiles().get(0);
    final EditList e = fh.toEditList();
    assertEquals(2, e.size());
    assertEquals(new Edit(4 - 1, 5 - 1, 4 - 1, 5 - 1), e.get(0));
    assertEquals(new Edit(16 - 1, 17 - 1, 16 - 1, 17 - 1), e.get(1));
  }
View Full Code Here

  }

  public void testTypes() throws IOException {
    final Patch p = parseTestPatchFile("testEditList_Types.patch");
    final FileHeader fh = p.getFiles().get(0);
    final EditList e = fh.toEditList();
    assertEquals(3, e.size());
    assertEquals(new Edit(3 - 1, 3 - 1, 3 - 1, 4 - 1), e.get(0));
    assertEquals(new Edit(17 - 1, 19 - 1, 18 - 1, 18 - 1), e.get(1));
    assertEquals(new Edit(23 - 1, 25 - 1, 22 - 1, 28 - 1), e.get(2));
  }
View Full Code Here

    return reverseBinaryHunk;
  }

  /** @return a list describing the content edits performed on this file. */
  public EditList toEditList() {
    final EditList r = new EditList();
    for (final HunkHeader hunk : hunks)
      r.addAll(hunk.toEditList());
    return r;
  }
View Full Code Here

     */
    private String getDiffinGitFormat(String string1, String string2) throws IOException {
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        RawText rt1 = new RawText(string1.getBytes());
        RawText rt2 = new RawText(string2.getBytes());
        EditList diffList = new EditList();
        diffList.addAll(new HistogramDiff().diff(RawTextComparator.DEFAULT, rt1, rt2));
        new DiffFormatter(out).format(diffList, rt1, rt2);
        return out.toString();
    }
View Full Code Here

    public void updateRange(Integer lineA, Integer lineB) {
        if (editList == null) {
            return;
        }

        EditList newEditList = new EditList();

        for (Edit edit: editList) {
            if (lineA != null) {
                if ((lineA >= edit.getBeginA() - context) && (lineA <= edit.getEndA() + context)) {
                    newEditList.add(edit);
                }
            }

            if (lineB != null) {
                if ((lineB >= edit.getBeginB() - context) && (lineB <= edit.getEndB() + context)) {
                    newEditList.add(edit);
                }
            }
        }

        editList = newEditList;
View Full Code Here

    return reverseBinaryHunk;
  }

  /** @return a list describing the content edits performed on this file. */
  public EditList toEditList() {
    final EditList r = new EditList();
    for (final HunkHeader hunk : hunks)
      r.addAll(hunk.toEditList());
    return r;
  }
View Full Code Here

    return split(next, n);
  }

  private boolean split(Candidate parent, Candidate source)
      throws IOException {
    EditList editList = diffAlgorithm.diff(textComparator,
        parent.sourceText, source.sourceText);
    if (editList.isEmpty()) {
      // Ignoring whitespace (or some other special comparator) can
      // cause non-identical blobs to have an empty edit list. In
      // a case like this push the parent alone.
      parent.regionList = source.regionList;
      push(parent);
View Full Code Here

        p.sourceBlob = ids[pIdx];
      } else {
        continue;
      }

      EditList editList;
      if (n instanceof ReverseCandidate
          && p.sourceBlob.equals(n.sourceBlob)) {
        // This special case happens on ReverseCandidate forks.
        p.sourceText = n.sourceText;
        editList = new EditList(0);
      } else {
        p.loadText(reader);
        editList = diffAlgorithm.diff(textComparator,
            p.sourceText, n.sourceText);
      }

      if (editList.isEmpty()) {
        // Ignoring whitespace (or some other special comparator) can
        // cause non-identical blobs to have an empty edit list. In
        // a case like this push the parent alone.
        if (n instanceof ReverseCandidate) {
          parents[pIdx] = p;
View Full Code Here

TOP

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

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.