Package org.eclipse.jgit.diff

Examples of org.eclipse.jgit.diff.Edit


      editList = new EditList();
      final byte[] buf = file.buf;
      int c = nextLF(buf, startOffset);
      int oLine = old.startLine;
      int nLine = newStartLine;
      Edit in = null;

      SCAN: for (; c < endOffset; c = nextLF(buf, c)) {
        switch (buf[c]) {
        case ' ':
        case '\n':
          in = null;
          oLine++;
          nLine++;
          continue;

        case '-':
          if (in == null) {
            in = new Edit(oLine - 1, nLine - 1);
            editList.add(in);
          }
          oLine++;
          in.extendA();
          continue;

        case '+':
          if (in == null) {
            in = new Edit(oLine - 1, nLine - 1);
            editList.add(in);
          }
          nLine++;
          in.extendB();
          continue;

        case '\\': // Matches "\ No newline at end of file"
          continue;
View Full Code Here


      // more responsibility for the result. Remaining edits can
      // be safely ignored.
      if (r == null)
        return;

      Edit e = editList.get(eIdx);

      // Edit ends before the next candidate region. Skip the edit.
      if (e.getEndB() <= r.sourceStart) {
        eIdx++;
        continue;
      }

      // Next candidate region starts before the edit. Assign some
      // of the blame onto A, but possibly split and also on B.
      if (r.sourceStart < e.getBeginB()) {
        int d = e.getBeginB() - r.sourceStart;
        if (r.length <= d) {
          // Pass the blame for this region onto A.
          Region next = r.next;
          r.sourceStart = e.getBeginA() - d;
          aTail = add(aTail, a, r);
          r = next;
          continue;
        }

        // Split the region and assign some to A, some to B.
        aTail = add(aTail, a, r.splitFirst(e.getBeginA() - d, d));
        r.slideAndShrink(d);
      }

      // At this point e.getBeginB() <= r.sourceStart.

      // An empty edit on the B side isn't relevant to this split,
      // as it does not overlap any candidate region.
      if (e.getLengthB() == 0) {
        eIdx++;
        continue;
      }

      // If the region ends before the edit, blame on B.
      int rEnd = r.sourceStart + r.length;
      if (rEnd <= e.getEndB()) {
        Region next = r.next;
        bTail = add(bTail, b, r);
        r = next;
        if (rEnd == e.getEndB())
          eIdx++;
        continue;
      }

      // This region extends beyond the edit. Blame the first
      // half of the region on B, and process the rest after.
      int len = e.getEndB() - r.sourceStart;
      bTail = add(bTail, b, r.splitFirst(r.sourceStart, len));
      r.slideAndShrink(len);
      eIdx++;
    }

    if (r == null)
      return;

    // For any remaining region, pass the blame onto A after shifting
    // the source start to account for the difference between the two.
    Edit e = editList.get(editList.size() - 1);
    int endB = e.getEndB();
    int d = endB - e.getEndA();
    if (aTail == null)
      a.regionList = r;
    else
      aTail.next = r;
    do {
View Full Code Here

TOP

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

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.