Mercurial > hg4j
annotate src/org/tmatesoft/hg/internal/FileAnnotation.java @ 556:e55f17a7a195
AnnotateFacility renamed to HgBlameFacility and exposed, API shapes out and got some javadoc
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Fri, 22 Feb 2013 20:21:24 +0100 |
parents | e623aa2ca526 |
children | b9e5ac26dd83 |
rev | line source |
---|---|
546
cd78e8b9d7bc
File annotate test. Refactored FileAnnotation as standalone class, introduced LineInspector to make line offset calc code shared
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
1 /* |
cd78e8b9d7bc
File annotate test. Refactored FileAnnotation as standalone class, introduced LineInspector to make line offset calc code shared
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
2 * Copyright (c) 2013 TMate Software Ltd |
cd78e8b9d7bc
File annotate test. Refactored FileAnnotation as standalone class, introduced LineInspector to make line offset calc code shared
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
3 * |
cd78e8b9d7bc
File annotate test. Refactored FileAnnotation as standalone class, introduced LineInspector to make line offset calc code shared
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
4 * This program is free software; you can redistribute it and/or modify |
cd78e8b9d7bc
File annotate test. Refactored FileAnnotation as standalone class, introduced LineInspector to make line offset calc code shared
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
5 * it under the terms of the GNU General Public License as published by |
cd78e8b9d7bc
File annotate test. Refactored FileAnnotation as standalone class, introduced LineInspector to make line offset calc code shared
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
6 * the Free Software Foundation; version 2 of the License. |
cd78e8b9d7bc
File annotate test. Refactored FileAnnotation as standalone class, introduced LineInspector to make line offset calc code shared
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
7 * |
cd78e8b9d7bc
File annotate test. Refactored FileAnnotation as standalone class, introduced LineInspector to make line offset calc code shared
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
8 * This program is distributed in the hope that it will be useful, |
cd78e8b9d7bc
File annotate test. Refactored FileAnnotation as standalone class, introduced LineInspector to make line offset calc code shared
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
cd78e8b9d7bc
File annotate test. Refactored FileAnnotation as standalone class, introduced LineInspector to make line offset calc code shared
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
cd78e8b9d7bc
File annotate test. Refactored FileAnnotation as standalone class, introduced LineInspector to make line offset calc code shared
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
11 * GNU General Public License for more details. |
cd78e8b9d7bc
File annotate test. Refactored FileAnnotation as standalone class, introduced LineInspector to make line offset calc code shared
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
12 * |
cd78e8b9d7bc
File annotate test. Refactored FileAnnotation as standalone class, introduced LineInspector to make line offset calc code shared
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
13 * For information on how to redistribute this software under |
cd78e8b9d7bc
File annotate test. Refactored FileAnnotation as standalone class, introduced LineInspector to make line offset calc code shared
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
14 * the terms of a license other than GNU General Public License |
cd78e8b9d7bc
File annotate test. Refactored FileAnnotation as standalone class, introduced LineInspector to make line offset calc code shared
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
15 * contact TMate Software at support@hg4j.com |
cd78e8b9d7bc
File annotate test. Refactored FileAnnotation as standalone class, introduced LineInspector to make line offset calc code shared
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
16 */ |
548
ab21ac7dd833
Line-by-line annotation API and support code in place
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
546
diff
changeset
|
17 package org.tmatesoft.hg.internal; |
546
cd78e8b9d7bc
File annotate test. Refactored FileAnnotation as standalone class, introduced LineInspector to make line offset calc code shared
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
18 |
cd78e8b9d7bc
File annotate test. Refactored FileAnnotation as standalone class, introduced LineInspector to make line offset calc code shared
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
19 import java.util.LinkedList; |
cd78e8b9d7bc
File annotate test. Refactored FileAnnotation as standalone class, introduced LineInspector to make line offset calc code shared
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
20 |
555
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
21 import org.tmatesoft.hg.core.HgIterateDirection; |
556
e55f17a7a195
AnnotateFacility renamed to HgBlameFacility and exposed, API shapes out and got some javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
555
diff
changeset
|
22 import org.tmatesoft.hg.repo.HgBlameFacility; |
555
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
23 import org.tmatesoft.hg.repo.HgDataFile; |
556
e55f17a7a195
AnnotateFacility renamed to HgBlameFacility and exposed, API shapes out and got some javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
555
diff
changeset
|
24 import org.tmatesoft.hg.repo.HgBlameFacility.*; |
546
cd78e8b9d7bc
File annotate test. Refactored FileAnnotation as standalone class, introduced LineInspector to make line offset calc code shared
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
25 |
cd78e8b9d7bc
File annotate test. Refactored FileAnnotation as standalone class, introduced LineInspector to make line offset calc code shared
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
26 /** |
555
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
27 * Produce output like 'hg annotate' does |
546
cd78e8b9d7bc
File annotate test. Refactored FileAnnotation as standalone class, introduced LineInspector to make line offset calc code shared
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
28 * |
cd78e8b9d7bc
File annotate test. Refactored FileAnnotation as standalone class, introduced LineInspector to make line offset calc code shared
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
29 * @author Artem Tikhomirov |
cd78e8b9d7bc
File annotate test. Refactored FileAnnotation as standalone class, introduced LineInspector to make line offset calc code shared
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
30 * @author TMate Software Ltd. |
cd78e8b9d7bc
File annotate test. Refactored FileAnnotation as standalone class, introduced LineInspector to make line offset calc code shared
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
31 */ |
556
e55f17a7a195
AnnotateFacility renamed to HgBlameFacility and exposed, API shapes out and got some javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
555
diff
changeset
|
32 public class FileAnnotation implements HgBlameFacility.BlockInspector, RevisionDescriptor.Recipient { |
546
cd78e8b9d7bc
File annotate test. Refactored FileAnnotation as standalone class, introduced LineInspector to make line offset calc code shared
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
33 |
555
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
34 @Experimental(reason="The line-by-line inspector likely to become part of core/command API") |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
35 @Callback |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
36 public interface LineInspector { |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
37 /** |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
38 * Not necessarily invoked sequentially by line numbers |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
39 */ |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
40 void line(int lineNumber, int changesetRevIndex, LineDescriptor ld); |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
41 } |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
42 |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
43 public interface LineDescriptor { |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
44 int totalLines(); |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
45 } |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
46 |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
47 /** |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
48 * Annotate file revision, line by line. |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
49 */ |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
50 public static void annotate(HgDataFile df, int changelogRevisionIndex, LineInspector insp) { |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
51 if (!df.exists()) { |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
52 return; |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
53 } |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
54 FileAnnotation fa = new FileAnnotation(insp); |
556
e55f17a7a195
AnnotateFacility renamed to HgBlameFacility and exposed, API shapes out and got some javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
555
diff
changeset
|
55 HgBlameFacility af = new HgBlameFacility(); |
555
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
56 af.annotate(df, changelogRevisionIndex, fa, HgIterateDirection.NewToOld); |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
57 } |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
58 |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
59 // blocks deleted in the target, as reported at the previous step |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
60 private LinkedList<DeleteBlock> deleted = new LinkedList<DeleteBlock>(); |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
61 // blocks deleted in the origin, to become deletions in target at the next step |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
62 private LinkedList<DeleteBlock> newDeleted = new LinkedList<DeleteBlock>(); |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
63 // keeps <startSeq1, startSeq2, len> of equal blocks, origin to target, from previous step |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
64 // XXX smth like IntSliceVector to access triples (or slices of any size, in fact) |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
65 // with easy indexing, e.g. #get(sliceIndex, indexWithinSlice) |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
66 // and vect.get(7,2) instead of vect.get(7*SIZEOF_SLICE+2) |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
67 private IntVector identical = new IntVector(20 * 3, 2 * 3); |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
68 // equal blocks of the current iteration, to be recalculated before next step |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
69 // to track line number (current target to ultimate target) mapping |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
70 private IntVector newIdentical = new IntVector(20 * 3, 2 * 3); |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
71 |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
72 private boolean[] knownLines; |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
73 private final LineInspector delegate; |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
74 |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
75 public FileAnnotation(LineInspector lineInspector) { |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
76 delegate = lineInspector; |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
77 } |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
78 |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
79 public void start(RevisionDescriptor rd) { |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
80 if (knownLines == null) { |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
81 knownLines = new boolean[rd.target().elementCount()]; |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
82 } |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
83 } |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
84 |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
85 // private static void ppp(IntVector v) { |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
86 // for (int i = 0; i < v.size(); i+= 3) { |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
87 // int len = v.get(i+2); |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
88 // System.out.printf("[%d..%d) == [%d..%d); ", v.get(i), v.get(i) + len, v.get(i+1), v.get(i+1) + len); |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
89 // } |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
90 // System.out.println(); |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
91 // } |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
92 |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
93 public void done(RevisionDescriptor rd) { |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
94 if (identical.size() > 0) { |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
95 // update line numbers of the intermediate target to point to ultimate target's line numbers |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
96 IntVector v = new IntVector(identical.size(), 2 * 3); |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
97 for (int i = 0; i < newIdentical.size(); i += 3) { |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
98 int originLine = newIdentical.get(i); |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
99 int targetLine = newIdentical.get(i + 1); |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
100 int length = newIdentical.get(i + 2); |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
101 int startTargetLine = -1, startOriginLine = -1, c = 0; |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
102 for (int j = 0; j < length; j++) { |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
103 int lnInFinal = mapLineIndex(targetLine + j); |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
104 if (lnInFinal == -1 || (startTargetLine != -1 && lnInFinal != startTargetLine + c)) { |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
105 // the line is not among "same" in ultimate origin |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
106 // or belongs to another/next "same" chunk |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
107 if (startOriginLine == -1) { |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
108 continue; |
546
cd78e8b9d7bc
File annotate test. Refactored FileAnnotation as standalone class, introduced LineInspector to make line offset calc code shared
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
109 } |
cd78e8b9d7bc
File annotate test. Refactored FileAnnotation as standalone class, introduced LineInspector to make line offset calc code shared
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
110 v.add(startOriginLine); |
cd78e8b9d7bc
File annotate test. Refactored FileAnnotation as standalone class, introduced LineInspector to make line offset calc code shared
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
111 v.add(startTargetLine); |
cd78e8b9d7bc
File annotate test. Refactored FileAnnotation as standalone class, introduced LineInspector to make line offset calc code shared
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
112 v.add(c); |
555
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
113 c = 0; |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
114 startOriginLine = startTargetLine = -1; |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
115 // fall-through to check if it's not complete miss but a next chunk |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
116 } |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
117 if (lnInFinal != -1) { |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
118 if (startOriginLine == -1) { |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
119 startOriginLine = originLine + j; |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
120 startTargetLine = lnInFinal; |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
121 c = 1; |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
122 } else { |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
123 assert lnInFinal == startTargetLine + c; |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
124 c++; |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
125 } |
546
cd78e8b9d7bc
File annotate test. Refactored FileAnnotation as standalone class, introduced LineInspector to make line offset calc code shared
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
126 } |
cd78e8b9d7bc
File annotate test. Refactored FileAnnotation as standalone class, introduced LineInspector to make line offset calc code shared
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
127 } |
555
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
128 if (startOriginLine != -1) { |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
129 assert c > 0; |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
130 v.add(startOriginLine); |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
131 v.add(startTargetLine); |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
132 v.add(c); |
546
cd78e8b9d7bc
File annotate test. Refactored FileAnnotation as standalone class, introduced LineInspector to make line offset calc code shared
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
133 } |
cd78e8b9d7bc
File annotate test. Refactored FileAnnotation as standalone class, introduced LineInspector to make line offset calc code shared
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
134 } |
555
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
135 newIdentical.clear(); |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
136 identical = v; |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
137 } else { |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
138 IntVector li = newIdentical; |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
139 newIdentical = identical; |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
140 identical = li; |
546
cd78e8b9d7bc
File annotate test. Refactored FileAnnotation as standalone class, introduced LineInspector to make line offset calc code shared
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
141 } |
555
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
142 LinkedList<DeleteBlock> ld = newDeleted; |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
143 deleted.clear(); |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
144 newDeleted = deleted; |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
145 deleted = ld; |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
146 } |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
147 |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
148 public void same(EqualBlock block) { |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
149 newIdentical.add(block.originStart()); |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
150 newIdentical.add(block.targetStart()); |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
151 newIdentical.add(block.length()); |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
152 } |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
153 |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
154 public void added(AddBlock block) { |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
155 for (int i = 0, ln = block.firstAddedLine(), x = block.totalAddedLines(); i < x; i++, ln++) { |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
156 int lnInFinal = mapLineIndex(ln); |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
157 if (lnInFinal != -1 && !knownLines[lnInFinal]) { |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
158 delegate.line(lnInFinal, block.targetChangesetIndex(), new LineDescriptorImpl()); |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
159 knownLines[lnInFinal] = true; |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
160 } |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
161 } |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
162 } |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
163 |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
164 public void changed(ChangeBlock block) { |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
165 deleted(block); |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
166 added(block); |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
167 } |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
168 |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
169 public void deleted(DeleteBlock block) { |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
170 newDeleted.add(block); |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
171 } |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
172 |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
173 // line - index in the target |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
174 private boolean isDeleted(int line) { |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
175 for (DeleteBlock b : deleted) { |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
176 if (b.firstRemovedLine() > line) { |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
177 break; |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
178 } |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
179 // line >= b.firstRemovedLine |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
180 if (b.firstRemovedLine() + b.totalRemovedLines() > line) { |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
181 return true; |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
182 } |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
183 } |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
184 return false; |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
185 } |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
186 |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
187 // map target lines to the lines of the revision being annotated (the one that came first) |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
188 private int mapLineIndex(int ln) { |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
189 if (isDeleted(ln)) { |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
190 return -1; |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
191 } |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
192 if (identical.isEmpty()) { |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
193 return ln; |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
194 } |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
195 for (int i = 0; i < identical.size(); i += 3) { |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
196 final int originStart = identical.get(i); |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
197 if (originStart > ln) { |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
198 // assert false; |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
199 return -1; |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
200 } |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
201 // ln >= b.originStart |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
202 final int length = identical.get(i + 2); |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
203 if (originStart + length > ln) { |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
204 int targetStart = identical.get(i + 1); |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
205 return targetStart + (ln - originStart); |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
206 } |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
207 } |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
208 // assert false; |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
209 return -1; |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
210 } |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
211 |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
212 private final class LineDescriptorImpl implements LineDescriptor { |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
213 LineDescriptorImpl() { |
546
cd78e8b9d7bc
File annotate test. Refactored FileAnnotation as standalone class, introduced LineInspector to make line offset calc code shared
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
214 } |
cd78e8b9d7bc
File annotate test. Refactored FileAnnotation as standalone class, introduced LineInspector to make line offset calc code shared
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
215 |
555
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
216 public int totalLines() { |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
217 return FileAnnotation.this.knownLines.length; |
546
cd78e8b9d7bc
File annotate test. Refactored FileAnnotation as standalone class, introduced LineInspector to make line offset calc code shared
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
218 } |
555
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
219 } |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
220 } |