Mercurial > hg4j
comparison src/org/tmatesoft/hg/internal/ReverseAnnotateInspector.java @ 677:1c49c0cee540
Report line number at the first appearance, like 'hg annotate -l' does
| author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
|---|---|
| date | Thu, 18 Jul 2013 18:47:45 +0200 |
| parents | 3219cfadda49 |
| children |
comparison
equal
deleted
inserted
replaced
| 676:3219cfadda49 | 677:1c49c0cee540 |
|---|---|
| 57 private IntMap<RangePairSeq> mergedRanges = new IntMap<RangePairSeq>(10); | 57 private IntMap<RangePairSeq> mergedRanges = new IntMap<RangePairSeq>(10); |
| 58 private IntMap<RangePairSeq> equalRanges = new IntMap<RangePairSeq>(10); | 58 private IntMap<RangePairSeq> equalRanges = new IntMap<RangePairSeq>(10); |
| 59 private boolean activeEqualsComesFromMerge = false; | 59 private boolean activeEqualsComesFromMerge = false; |
| 60 | 60 |
| 61 private int[] lineRevisions; | 61 private int[] lineRevisions; |
| 62 private int[] lineNumbers; | |
| 62 | 63 |
| 63 /** | 64 /** |
| 64 * @return desired order of iteration for diff | 65 * @return desired order of iteration for diff |
| 65 */ | 66 */ |
| 66 public HgIterateDirection iterateDirection() { | 67 public HgIterateDirection iterateDirection() { |
| 70 public void report(int annotateRevIndex, HgAnnotateCommand.Inspector insp, ProgressSupport progress, CancelSupport cancel) throws HgCallbackTargetException, CancelledException { | 71 public void report(int annotateRevIndex, HgAnnotateCommand.Inspector insp, ProgressSupport progress, CancelSupport cancel) throws HgCallbackTargetException, CancelledException { |
| 71 LineImpl li = new LineImpl(); | 72 LineImpl li = new LineImpl(); |
| 72 progress.start(lineRevisions.length); | 73 progress.start(lineRevisions.length); |
| 73 for (int i = 0; i < lineRevisions.length; i++) { | 74 for (int i = 0; i < lineRevisions.length; i++) { |
| 74 byte[] c = lineContent.elementAt(i).asArray(); | 75 byte[] c = lineContent.elementAt(i).asArray(); |
| 75 li.init(i+1, lineRevisions[i], c); | 76 li.init(i+1, lineNumbers[i] + 1, lineRevisions[i], c); |
| 76 insp.next(li); | 77 insp.next(li); |
| 77 progress.worked(1); | 78 progress.worked(1); |
| 78 cancel.checkCancelled(); | 79 cancel.checkCancelled(); |
| 79 } | 80 } |
| 80 progress.done(); | 81 progress.done(); |
| 83 public void start(RevisionDescriptor rd) { | 84 public void start(RevisionDescriptor rd) { |
| 84 revisionDescriptor = rd; | 85 revisionDescriptor = rd; |
| 85 if (knownLines == null) { | 86 if (knownLines == null) { |
| 86 lineContent = rd.target(); | 87 lineContent = rd.target(); |
| 87 knownLines = new boolean[lineContent.elementCount()]; | 88 knownLines = new boolean[lineContent.elementCount()]; |
| 88 lineRevisions = new int [lineContent.elementCount()]; | 89 lineRevisions = new int [knownLines.length]; |
| 89 Arrays.fill(lineRevisions, NO_REVISION); | 90 Arrays.fill(lineRevisions, NO_REVISION); |
| 91 lineNumbers = new int[knownLines.length]; | |
| 90 activeEquals = new RangePairSeq(); | 92 activeEquals = new RangePairSeq(); |
| 91 activeEquals.add(0, 0, knownLines.length); | 93 activeEquals.add(0, 0, knownLines.length); |
| 92 equalRanges.put(rd.targetChangesetIndex(), activeEquals); | 94 equalRanges.put(rd.targetChangesetIndex(), activeEquals); |
| 93 } else { | 95 } else { |
| 94 activeEquals = equalRanges.get(rd.targetChangesetIndex()); | 96 activeEquals = equalRanges.get(rd.targetChangesetIndex()); |
| 142 int lnInFinal = activeEquals.mapLineIndex(ln); | 144 int lnInFinal = activeEquals.mapLineIndex(ln); |
| 143 if (lnInFinal != -1/* && !knownLines[lnInFinal]*/) { | 145 if (lnInFinal != -1/* && !knownLines[lnInFinal]*/) { |
| 144 if (rs != null) { | 146 if (rs != null) { |
| 145 rs.add(block.insertedAt() + i, lnInFinal, 1); | 147 rs.add(block.insertedAt() + i, lnInFinal, 1); |
| 146 } else { | 148 } else { |
| 147 line(lnInFinal, block.targetChangesetIndex()); | 149 line(lnInFinal, ln, block.targetChangesetIndex()); |
| 148 } | 150 } |
| 149 knownLines[lnInFinal] = true; | 151 knownLines[lnInFinal] = true; |
| 150 } | 152 } |
| 151 } | 153 } |
| 152 } | 154 } |
| 156 } | 158 } |
| 157 | 159 |
| 158 public void deleted(DeleteBlock block) { | 160 public void deleted(DeleteBlock block) { |
| 159 } | 161 } |
| 160 | 162 |
| 161 private void line(int lineNumber, int changesetRevIndex) { | 163 private void line(int lineNumber, int firstAppearance, int changesetRevIndex) { |
| 162 lineRevisions[lineNumber] = changesetRevIndex; | 164 lineRevisions[lineNumber] = changesetRevIndex; |
| 165 lineNumbers[lineNumber] = firstAppearance; | |
| 163 } | 166 } |
| 164 } | 167 } |
