Mercurial > hg4j
annotate src/org/tmatesoft/hg/internal/ReverseAnnotateInspector.java @ 676:3219cfadda49
Switch to alternative annotate producer (walks from parents to children). Refactor FileAnnotation to match updated annotate approach
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Thu, 18 Jul 2013 18:03:51 +0200 |
parents | src/org/tmatesoft/hg/internal/FileAnnotation.java@cce0387c6041 |
children | 1c49c0cee540 |
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 |
676
3219cfadda49
Switch to alternative annotate producer (walks from parents to children). Refactor FileAnnotation to match updated annotate approach
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
674
diff
changeset
|
20 import static org.tmatesoft.hg.repo.HgRepository.NO_REVISION; |
3219cfadda49
Switch to alternative annotate producer (walks from parents to children). Refactor FileAnnotation to match updated annotate approach
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
674
diff
changeset
|
21 |
3219cfadda49
Switch to alternative annotate producer (walks from parents to children). Refactor FileAnnotation to match updated annotate approach
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
674
diff
changeset
|
22 import java.util.Arrays; |
3219cfadda49
Switch to alternative annotate producer (walks from parents to children). Refactor FileAnnotation to match updated annotate approach
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
674
diff
changeset
|
23 |
3219cfadda49
Switch to alternative annotate producer (walks from parents to children). Refactor FileAnnotation to match updated annotate approach
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
674
diff
changeset
|
24 import org.tmatesoft.hg.core.HgAnnotateCommand; |
629
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
628
diff
changeset
|
25 import org.tmatesoft.hg.core.HgBlameInspector; |
676
3219cfadda49
Switch to alternative annotate producer (walks from parents to children). Refactor FileAnnotation to match updated annotate approach
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
674
diff
changeset
|
26 import org.tmatesoft.hg.core.HgIterateDirection; |
629
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
628
diff
changeset
|
27 import org.tmatesoft.hg.core.HgBlameInspector.RevisionDescriptor; |
676
3219cfadda49
Switch to alternative annotate producer (walks from parents to children). Refactor FileAnnotation to match updated annotate approach
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
674
diff
changeset
|
28 import org.tmatesoft.hg.core.HgCallbackTargetException; |
557
b9e5ac26dd83
Annotate: Line annotation needs true line position from merged blocks; test-annotate repo updated to show elements from both parents in the merged revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
556
diff
changeset
|
29 import org.tmatesoft.hg.repo.HgInvalidStateException; |
676
3219cfadda49
Switch to alternative annotate producer (walks from parents to children). Refactor FileAnnotation to match updated annotate approach
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
674
diff
changeset
|
30 import org.tmatesoft.hg.util.CancelSupport; |
3219cfadda49
Switch to alternative annotate producer (walks from parents to children). Refactor FileAnnotation to match updated annotate approach
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
674
diff
changeset
|
31 import org.tmatesoft.hg.util.CancelledException; |
3219cfadda49
Switch to alternative annotate producer (walks from parents to children). Refactor FileAnnotation to match updated annotate approach
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
674
diff
changeset
|
32 import org.tmatesoft.hg.util.ProgressSupport; |
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 |
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
|
34 /** |
676
3219cfadda49
Switch to alternative annotate producer (walks from parents to children). Refactor FileAnnotation to match updated annotate approach
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
674
diff
changeset
|
35 * Produce output like 'hg annotate' does. |
3219cfadda49
Switch to alternative annotate producer (walks from parents to children). Refactor FileAnnotation to match updated annotate approach
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
674
diff
changeset
|
36 * Expects revisions to come in order from child to parent. |
3219cfadda49
Switch to alternative annotate producer (walks from parents to children). Refactor FileAnnotation to match updated annotate approach
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
674
diff
changeset
|
37 * Unlike {@link ForwardAnnotateInspector}, can be easily modified to report lines as soon as its origin is detected. |
3219cfadda49
Switch to alternative annotate producer (walks from parents to children). Refactor FileAnnotation to match updated annotate approach
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
674
diff
changeset
|
38 * |
3219cfadda49
Switch to alternative annotate producer (walks from parents to children). Refactor FileAnnotation to match updated annotate approach
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
674
diff
changeset
|
39 * (+) Handles annotate of partial history, at any moment lines with ({@link #knownLines} == <code>false</code> indicate lines |
3219cfadda49
Switch to alternative annotate producer (walks from parents to children). Refactor FileAnnotation to match updated annotate approach
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
674
diff
changeset
|
40 * that were added prior to any revision already visited. |
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
|
41 * |
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
|
42 * @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
|
43 * @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
|
44 */ |
676
3219cfadda49
Switch to alternative annotate producer (walks from parents to children). Refactor FileAnnotation to match updated annotate approach
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
674
diff
changeset
|
45 public class ReverseAnnotateInspector implements HgBlameInspector, RevisionDescriptor.Recipient { |
555
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
46 |
557
b9e5ac26dd83
Annotate: Line annotation needs true line position from merged blocks; test-annotate repo updated to show elements from both parents in the merged revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
556
diff
changeset
|
47 // keeps <startSeq1, startSeq2, len> of equal blocks, origin to target, from some previous step |
674
cce0387c6041
Introduced dedicated IntSliceSeq/IntTuple in place of IntArray with subsequences
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
630
diff
changeset
|
48 private RangePairSeq activeEquals; |
555
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
49 // 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
|
50 // to track line number (current target to ultimate target) mapping |
674
cce0387c6041
Introduced dedicated IntSliceSeq/IntTuple in place of IntArray with subsequences
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
630
diff
changeset
|
51 private RangePairSeq intermediateEquals = new RangePairSeq(); |
555
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
52 |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
53 private boolean[] knownLines; |
557
b9e5ac26dd83
Annotate: Line annotation needs true line position from merged blocks; test-annotate repo updated to show elements from both parents in the merged revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
556
diff
changeset
|
54 private RevisionDescriptor revisionDescriptor; |
b9e5ac26dd83
Annotate: Line annotation needs true line position from merged blocks; test-annotate repo updated to show elements from both parents in the merged revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
556
diff
changeset
|
55 private BlockData lineContent; |
b9e5ac26dd83
Annotate: Line annotation needs true line position from merged blocks; test-annotate repo updated to show elements from both parents in the merged revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
556
diff
changeset
|
56 |
674
cce0387c6041
Introduced dedicated IntSliceSeq/IntTuple in place of IntArray with subsequences
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
630
diff
changeset
|
57 private IntMap<RangePairSeq> mergedRanges = new IntMap<RangePairSeq>(10); |
cce0387c6041
Introduced dedicated IntSliceSeq/IntTuple in place of IntArray with subsequences
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
630
diff
changeset
|
58 private IntMap<RangePairSeq> equalRanges = new IntMap<RangePairSeq>(10); |
557
b9e5ac26dd83
Annotate: Line annotation needs true line position from merged blocks; test-annotate repo updated to show elements from both parents in the merged revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
556
diff
changeset
|
59 private boolean activeEqualsComesFromMerge = false; |
555
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
60 |
676
3219cfadda49
Switch to alternative annotate producer (walks from parents to children). Refactor FileAnnotation to match updated annotate approach
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
674
diff
changeset
|
61 private int[] lineRevisions; |
3219cfadda49
Switch to alternative annotate producer (walks from parents to children). Refactor FileAnnotation to match updated annotate approach
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
674
diff
changeset
|
62 |
3219cfadda49
Switch to alternative annotate producer (walks from parents to children). Refactor FileAnnotation to match updated annotate approach
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
674
diff
changeset
|
63 /** |
3219cfadda49
Switch to alternative annotate producer (walks from parents to children). Refactor FileAnnotation to match updated annotate approach
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
674
diff
changeset
|
64 * @return desired order of iteration for diff |
3219cfadda49
Switch to alternative annotate producer (walks from parents to children). Refactor FileAnnotation to match updated annotate approach
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
674
diff
changeset
|
65 */ |
3219cfadda49
Switch to alternative annotate producer (walks from parents to children). Refactor FileAnnotation to match updated annotate approach
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
674
diff
changeset
|
66 public HgIterateDirection iterateDirection() { |
3219cfadda49
Switch to alternative annotate producer (walks from parents to children). Refactor FileAnnotation to match updated annotate approach
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
674
diff
changeset
|
67 return HgIterateDirection.NewToOld; |
3219cfadda49
Switch to alternative annotate producer (walks from parents to children). Refactor FileAnnotation to match updated annotate approach
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
674
diff
changeset
|
68 } |
3219cfadda49
Switch to alternative annotate producer (walks from parents to children). Refactor FileAnnotation to match updated annotate approach
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
674
diff
changeset
|
69 |
3219cfadda49
Switch to alternative annotate producer (walks from parents to children). Refactor FileAnnotation to match updated annotate approach
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
674
diff
changeset
|
70 public void report(int annotateRevIndex, HgAnnotateCommand.Inspector insp, ProgressSupport progress, CancelSupport cancel) throws HgCallbackTargetException, CancelledException { |
3219cfadda49
Switch to alternative annotate producer (walks from parents to children). Refactor FileAnnotation to match updated annotate approach
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
674
diff
changeset
|
71 LineImpl li = new LineImpl(); |
3219cfadda49
Switch to alternative annotate producer (walks from parents to children). Refactor FileAnnotation to match updated annotate approach
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
674
diff
changeset
|
72 progress.start(lineRevisions.length); |
3219cfadda49
Switch to alternative annotate producer (walks from parents to children). Refactor FileAnnotation to match updated annotate approach
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
674
diff
changeset
|
73 for (int i = 0; i < lineRevisions.length; i++) { |
3219cfadda49
Switch to alternative annotate producer (walks from parents to children). Refactor FileAnnotation to match updated annotate approach
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
674
diff
changeset
|
74 byte[] c = lineContent.elementAt(i).asArray(); |
3219cfadda49
Switch to alternative annotate producer (walks from parents to children). Refactor FileAnnotation to match updated annotate approach
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
674
diff
changeset
|
75 li.init(i+1, lineRevisions[i], c); |
3219cfadda49
Switch to alternative annotate producer (walks from parents to children). Refactor FileAnnotation to match updated annotate approach
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
674
diff
changeset
|
76 insp.next(li); |
3219cfadda49
Switch to alternative annotate producer (walks from parents to children). Refactor FileAnnotation to match updated annotate approach
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
674
diff
changeset
|
77 progress.worked(1); |
3219cfadda49
Switch to alternative annotate producer (walks from parents to children). Refactor FileAnnotation to match updated annotate approach
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
674
diff
changeset
|
78 cancel.checkCancelled(); |
3219cfadda49
Switch to alternative annotate producer (walks from parents to children). Refactor FileAnnotation to match updated annotate approach
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
674
diff
changeset
|
79 } |
3219cfadda49
Switch to alternative annotate producer (walks from parents to children). Refactor FileAnnotation to match updated annotate approach
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
674
diff
changeset
|
80 progress.done(); |
555
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
81 } |
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 public void start(RevisionDescriptor rd) { |
557
b9e5ac26dd83
Annotate: Line annotation needs true line position from merged blocks; test-annotate repo updated to show elements from both parents in the merged revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
556
diff
changeset
|
84 revisionDescriptor = rd; |
555
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
85 if (knownLines == null) { |
557
b9e5ac26dd83
Annotate: Line annotation needs true line position from merged blocks; test-annotate repo updated to show elements from both parents in the merged revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
556
diff
changeset
|
86 lineContent = rd.target(); |
b9e5ac26dd83
Annotate: Line annotation needs true line position from merged blocks; test-annotate repo updated to show elements from both parents in the merged revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
556
diff
changeset
|
87 knownLines = new boolean[lineContent.elementCount()]; |
676
3219cfadda49
Switch to alternative annotate producer (walks from parents to children). Refactor FileAnnotation to match updated annotate approach
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
674
diff
changeset
|
88 lineRevisions = new int [lineContent.elementCount()]; |
3219cfadda49
Switch to alternative annotate producer (walks from parents to children). Refactor FileAnnotation to match updated annotate approach
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
674
diff
changeset
|
89 Arrays.fill(lineRevisions, NO_REVISION); |
674
cce0387c6041
Introduced dedicated IntSliceSeq/IntTuple in place of IntArray with subsequences
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
630
diff
changeset
|
90 activeEquals = new RangePairSeq(); |
557
b9e5ac26dd83
Annotate: Line annotation needs true line position from merged blocks; test-annotate repo updated to show elements from both parents in the merged revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
556
diff
changeset
|
91 activeEquals.add(0, 0, knownLines.length); |
b9e5ac26dd83
Annotate: Line annotation needs true line position from merged blocks; test-annotate repo updated to show elements from both parents in the merged revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
556
diff
changeset
|
92 equalRanges.put(rd.targetChangesetIndex(), activeEquals); |
b9e5ac26dd83
Annotate: Line annotation needs true line position from merged blocks; test-annotate repo updated to show elements from both parents in the merged revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
556
diff
changeset
|
93 } else { |
b9e5ac26dd83
Annotate: Line annotation needs true line position from merged blocks; test-annotate repo updated to show elements from both parents in the merged revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
556
diff
changeset
|
94 activeEquals = equalRanges.get(rd.targetChangesetIndex()); |
b9e5ac26dd83
Annotate: Line annotation needs true line position from merged blocks; test-annotate repo updated to show elements from both parents in the merged revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
556
diff
changeset
|
95 if (activeEquals == null) { |
b9e5ac26dd83
Annotate: Line annotation needs true line position from merged blocks; test-annotate repo updated to show elements from both parents in the merged revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
556
diff
changeset
|
96 // we didn't see this target revision as origin yet |
b9e5ac26dd83
Annotate: Line annotation needs true line position from merged blocks; test-annotate repo updated to show elements from both parents in the merged revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
556
diff
changeset
|
97 // the only way this may happen is that this revision was a merge parent |
b9e5ac26dd83
Annotate: Line annotation needs true line position from merged blocks; test-annotate repo updated to show elements from both parents in the merged revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
556
diff
changeset
|
98 activeEquals = mergedRanges.get(rd.targetChangesetIndex()); |
b9e5ac26dd83
Annotate: Line annotation needs true line position from merged blocks; test-annotate repo updated to show elements from both parents in the merged revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
556
diff
changeset
|
99 activeEqualsComesFromMerge = true; |
b9e5ac26dd83
Annotate: Line annotation needs true line position from merged blocks; test-annotate repo updated to show elements from both parents in the merged revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
556
diff
changeset
|
100 if (activeEquals == null) { |
b9e5ac26dd83
Annotate: Line annotation needs true line position from merged blocks; test-annotate repo updated to show elements from both parents in the merged revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
556
diff
changeset
|
101 throw new HgInvalidStateException(String.format("Can't find previously visited revision %d (while in %d->%1$d diff)", rd.targetChangesetIndex(), rd.originChangesetIndex())); |
b9e5ac26dd83
Annotate: Line annotation needs true line position from merged blocks; test-annotate repo updated to show elements from both parents in the merged revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
556
diff
changeset
|
102 } |
b9e5ac26dd83
Annotate: Line annotation needs true line position from merged blocks; test-annotate repo updated to show elements from both parents in the merged revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
556
diff
changeset
|
103 } |
555
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
104 } |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
105 } |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
106 |
557
b9e5ac26dd83
Annotate: Line annotation needs true line position from merged blocks; test-annotate repo updated to show elements from both parents in the merged revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
556
diff
changeset
|
107 public void done(RevisionDescriptor rd) { |
b9e5ac26dd83
Annotate: Line annotation needs true line position from merged blocks; test-annotate repo updated to show elements from both parents in the merged revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
556
diff
changeset
|
108 // update line numbers of the intermediate target to point to ultimate target's line numbers |
674
cce0387c6041
Introduced dedicated IntSliceSeq/IntTuple in place of IntArray with subsequences
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
630
diff
changeset
|
109 RangePairSeq v = intermediateEquals.intersect(activeEquals); |
557
b9e5ac26dd83
Annotate: Line annotation needs true line position from merged blocks; test-annotate repo updated to show elements from both parents in the merged revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
556
diff
changeset
|
110 if (activeEqualsComesFromMerge) { |
b9e5ac26dd83
Annotate: Line annotation needs true line position from merged blocks; test-annotate repo updated to show elements from both parents in the merged revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
556
diff
changeset
|
111 mergedRanges.put(rd.originChangesetIndex(), v); |
b9e5ac26dd83
Annotate: Line annotation needs true line position from merged blocks; test-annotate repo updated to show elements from both parents in the merged revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
556
diff
changeset
|
112 } else { |
b9e5ac26dd83
Annotate: Line annotation needs true line position from merged blocks; test-annotate repo updated to show elements from both parents in the merged revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
556
diff
changeset
|
113 equalRanges.put(rd.originChangesetIndex(), v); |
b9e5ac26dd83
Annotate: Line annotation needs true line position from merged blocks; test-annotate repo updated to show elements from both parents in the merged revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
556
diff
changeset
|
114 } |
560
52263817b998
Exception when no blocks from merged revision were reported and merge parent was not recorded for future use
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
558
diff
changeset
|
115 if (rd.isMerge() && !mergedRanges.containsKey(rd.mergeChangesetIndex())) { |
52263817b998
Exception when no blocks from merged revision were reported and merge parent was not recorded for future use
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
558
diff
changeset
|
116 // seen merge, but no lines were merged from p2. |
52263817b998
Exception when no blocks from merged revision were reported and merge parent was not recorded for future use
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
558
diff
changeset
|
117 // Add empty range to avoid uncertainty when a parent of p2 pops in |
674
cce0387c6041
Introduced dedicated IntSliceSeq/IntTuple in place of IntArray with subsequences
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
630
diff
changeset
|
118 mergedRanges.put(rd.mergeChangesetIndex(), new RangePairSeq()); |
560
52263817b998
Exception when no blocks from merged revision were reported and merge parent was not recorded for future use
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
558
diff
changeset
|
119 } |
557
b9e5ac26dd83
Annotate: Line annotation needs true line position from merged blocks; test-annotate repo updated to show elements from both parents in the merged revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
556
diff
changeset
|
120 intermediateEquals.clear(); |
b9e5ac26dd83
Annotate: Line annotation needs true line position from merged blocks; test-annotate repo updated to show elements from both parents in the merged revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
556
diff
changeset
|
121 activeEquals = null; |
b9e5ac26dd83
Annotate: Line annotation needs true line position from merged blocks; test-annotate repo updated to show elements from both parents in the merged revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
556
diff
changeset
|
122 activeEqualsComesFromMerge = false; |
b9e5ac26dd83
Annotate: Line annotation needs true line position from merged blocks; test-annotate repo updated to show elements from both parents in the merged revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
556
diff
changeset
|
123 revisionDescriptor = null; |
b9e5ac26dd83
Annotate: Line annotation needs true line position from merged blocks; test-annotate repo updated to show elements from both parents in the merged revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
556
diff
changeset
|
124 } |
555
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
125 |
557
b9e5ac26dd83
Annotate: Line annotation needs true line position from merged blocks; test-annotate repo updated to show elements from both parents in the merged revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
556
diff
changeset
|
126 public void same(EqualBlock block) { |
b9e5ac26dd83
Annotate: Line annotation needs true line position from merged blocks; test-annotate repo updated to show elements from both parents in the merged revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
556
diff
changeset
|
127 intermediateEquals.add(block.originStart(), block.targetStart(), block.length()); |
b9e5ac26dd83
Annotate: Line annotation needs true line position from merged blocks; test-annotate repo updated to show elements from both parents in the merged revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
556
diff
changeset
|
128 } |
b9e5ac26dd83
Annotate: Line annotation needs true line position from merged blocks; test-annotate repo updated to show elements from both parents in the merged revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
556
diff
changeset
|
129 |
b9e5ac26dd83
Annotate: Line annotation needs true line position from merged blocks; test-annotate repo updated to show elements from both parents in the merged revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
556
diff
changeset
|
130 public void added(AddBlock block) { |
674
cce0387c6041
Introduced dedicated IntSliceSeq/IntTuple in place of IntArray with subsequences
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
630
diff
changeset
|
131 RangePairSeq rs = null; |
557
b9e5ac26dd83
Annotate: Line annotation needs true line position from merged blocks; test-annotate repo updated to show elements from both parents in the merged revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
556
diff
changeset
|
132 if (revisionDescriptor.isMerge() && block.originChangesetIndex() == revisionDescriptor.mergeChangesetIndex()) { |
b9e5ac26dd83
Annotate: Line annotation needs true line position from merged blocks; test-annotate repo updated to show elements from both parents in the merged revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
556
diff
changeset
|
133 rs = mergedRanges.get(revisionDescriptor.mergeChangesetIndex()); |
b9e5ac26dd83
Annotate: Line annotation needs true line position from merged blocks; test-annotate repo updated to show elements from both parents in the merged revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
556
diff
changeset
|
134 if (rs == null) { |
674
cce0387c6041
Introduced dedicated IntSliceSeq/IntTuple in place of IntArray with subsequences
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
630
diff
changeset
|
135 mergedRanges.put(revisionDescriptor.mergeChangesetIndex(), rs = new RangePairSeq()); |
557
b9e5ac26dd83
Annotate: Line annotation needs true line position from merged blocks; test-annotate repo updated to show elements from both parents in the merged revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
556
diff
changeset
|
136 } |
b9e5ac26dd83
Annotate: Line annotation needs true line position from merged blocks; test-annotate repo updated to show elements from both parents in the merged revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
556
diff
changeset
|
137 } |
b9e5ac26dd83
Annotate: Line annotation needs true line position from merged blocks; test-annotate repo updated to show elements from both parents in the merged revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
556
diff
changeset
|
138 if (activeEquals.size() == 0) { |
b9e5ac26dd83
Annotate: Line annotation needs true line position from merged blocks; test-annotate repo updated to show elements from both parents in the merged revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
556
diff
changeset
|
139 return; |
b9e5ac26dd83
Annotate: Line annotation needs true line position from merged blocks; test-annotate repo updated to show elements from both parents in the merged revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
556
diff
changeset
|
140 } |
b9e5ac26dd83
Annotate: Line annotation needs true line position from merged blocks; test-annotate repo updated to show elements from both parents in the merged revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
556
diff
changeset
|
141 for (int i = 0, ln = block.firstAddedLine(), x = block.totalAddedLines(); i < x; i++, ln++) { |
b9e5ac26dd83
Annotate: Line annotation needs true line position from merged blocks; test-annotate repo updated to show elements from both parents in the merged revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
556
diff
changeset
|
142 int lnInFinal = activeEquals.mapLineIndex(ln); |
b9e5ac26dd83
Annotate: Line annotation needs true line position from merged blocks; test-annotate repo updated to show elements from both parents in the merged revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
556
diff
changeset
|
143 if (lnInFinal != -1/* && !knownLines[lnInFinal]*/) { |
b9e5ac26dd83
Annotate: Line annotation needs true line position from merged blocks; test-annotate repo updated to show elements from both parents in the merged revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
556
diff
changeset
|
144 if (rs != null) { |
b9e5ac26dd83
Annotate: Line annotation needs true line position from merged blocks; test-annotate repo updated to show elements from both parents in the merged revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
556
diff
changeset
|
145 rs.add(block.insertedAt() + i, lnInFinal, 1); |
b9e5ac26dd83
Annotate: Line annotation needs true line position from merged blocks; test-annotate repo updated to show elements from both parents in the merged revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
556
diff
changeset
|
146 } else { |
676
3219cfadda49
Switch to alternative annotate producer (walks from parents to children). Refactor FileAnnotation to match updated annotate approach
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
674
diff
changeset
|
147 line(lnInFinal, block.targetChangesetIndex()); |
557
b9e5ac26dd83
Annotate: Line annotation needs true line position from merged blocks; test-annotate repo updated to show elements from both parents in the merged revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
556
diff
changeset
|
148 } |
b9e5ac26dd83
Annotate: Line annotation needs true line position from merged blocks; test-annotate repo updated to show elements from both parents in the merged revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
556
diff
changeset
|
149 knownLines[lnInFinal] = true; |
b9e5ac26dd83
Annotate: Line annotation needs true line position from merged blocks; test-annotate repo updated to show elements from both parents in the merged revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
556
diff
changeset
|
150 } |
b9e5ac26dd83
Annotate: Line annotation needs true line position from merged blocks; test-annotate repo updated to show elements from both parents in the merged revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
556
diff
changeset
|
151 } |
b9e5ac26dd83
Annotate: Line annotation needs true line position from merged blocks; test-annotate repo updated to show elements from both parents in the merged revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
556
diff
changeset
|
152 } |
b9e5ac26dd83
Annotate: Line annotation needs true line position from merged blocks; test-annotate repo updated to show elements from both parents in the merged revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
556
diff
changeset
|
153 |
b9e5ac26dd83
Annotate: Line annotation needs true line position from merged blocks; test-annotate repo updated to show elements from both parents in the merged revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
556
diff
changeset
|
154 public void changed(ChangeBlock block) { |
b9e5ac26dd83
Annotate: Line annotation needs true line position from merged blocks; test-annotate repo updated to show elements from both parents in the merged revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
556
diff
changeset
|
155 added(block); |
b9e5ac26dd83
Annotate: Line annotation needs true line position from merged blocks; test-annotate repo updated to show elements from both parents in the merged revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
556
diff
changeset
|
156 } |
b9e5ac26dd83
Annotate: Line annotation needs true line position from merged blocks; test-annotate repo updated to show elements from both parents in the merged revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
556
diff
changeset
|
157 |
b9e5ac26dd83
Annotate: Line annotation needs true line position from merged blocks; test-annotate repo updated to show elements from both parents in the merged revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
556
diff
changeset
|
158 public void deleted(DeleteBlock block) { |
b9e5ac26dd83
Annotate: Line annotation needs true line position from merged blocks; test-annotate repo updated to show elements from both parents in the merged revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
556
diff
changeset
|
159 } |
b9e5ac26dd83
Annotate: Line annotation needs true line position from merged blocks; test-annotate repo updated to show elements from both parents in the merged revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
556
diff
changeset
|
160 |
676
3219cfadda49
Switch to alternative annotate producer (walks from parents to children). Refactor FileAnnotation to match updated annotate approach
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
674
diff
changeset
|
161 private void line(int lineNumber, int changesetRevIndex) { |
3219cfadda49
Switch to alternative annotate producer (walks from parents to children). Refactor FileAnnotation to match updated annotate approach
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
674
diff
changeset
|
162 lineRevisions[lineNumber] = changesetRevIndex; |
557
b9e5ac26dd83
Annotate: Line annotation needs true line position from merged blocks; test-annotate repo updated to show elements from both parents in the merged revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
556
diff
changeset
|
163 } |
555
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
164 } |