Mercurial > jhg
annotate src/org/tmatesoft/hg/repo/HgBlameFacility.java @ 562:6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Thu, 28 Feb 2013 15:57:04 +0100 |
parents | d3c71498919c |
children | 8ed4f4f4f0a6 |
rev | line source |
---|---|
542
a71a05ec11bc
Towards annotate/blame support: general outline of the functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
1 /* |
a71a05ec11bc
Towards annotate/blame support: general outline of the functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
2 * Copyright (c) 2013 TMate Software Ltd |
a71a05ec11bc
Towards annotate/blame support: general outline of the functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
3 * |
a71a05ec11bc
Towards annotate/blame support: general outline of the functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
4 * This program is free software; you can redistribute it and/or modify |
a71a05ec11bc
Towards annotate/blame support: general outline of the functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
5 * it under the terms of the GNU General Public License as published by |
a71a05ec11bc
Towards annotate/blame support: general outline of the functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
6 * the Free Software Foundation; version 2 of the License. |
a71a05ec11bc
Towards annotate/blame support: general outline of the functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
7 * |
a71a05ec11bc
Towards annotate/blame support: general outline of the functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
8 * This program is distributed in the hope that it will be useful, |
a71a05ec11bc
Towards annotate/blame support: general outline of the functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
a71a05ec11bc
Towards annotate/blame support: general outline of the functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
a71a05ec11bc
Towards annotate/blame support: general outline of the functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
11 * GNU General Public License for more details. |
a71a05ec11bc
Towards annotate/blame support: general outline of the functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
12 * |
a71a05ec11bc
Towards annotate/blame support: general outline of the functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
13 * For information on how to redistribute this software under |
a71a05ec11bc
Towards annotate/blame support: general outline of the functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
14 * the terms of a license other than GNU General Public License |
a71a05ec11bc
Towards annotate/blame support: general outline of the functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
15 * contact TMate Software at support@hg4j.com |
a71a05ec11bc
Towards annotate/blame support: general outline of the functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
16 */ |
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
|
17 package org.tmatesoft.hg.repo; |
542
a71a05ec11bc
Towards annotate/blame support: general outline of the functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
18 |
a71a05ec11bc
Towards annotate/blame support: general outline of the functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
19 import static org.tmatesoft.hg.repo.HgRepository.NO_REVISION; |
548
ab21ac7dd833
Line-by-line annotation API and support code in place
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
546
diff
changeset
|
20 import static org.tmatesoft.hg.repo.HgRepository.TIP; |
542
a71a05ec11bc
Towards annotate/blame support: general outline of the functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
21 |
552
45751456b471
Annotate file changes through few revisions, walking either direction (old to new and vice versa)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
551
diff
changeset
|
22 import java.util.BitSet; |
45751456b471
Annotate file changes through few revisions, walking either direction (old to new and vice versa)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
551
diff
changeset
|
23 import java.util.LinkedList; |
45751456b471
Annotate file changes through few revisions, walking either direction (old to new and vice versa)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
551
diff
changeset
|
24 import java.util.ListIterator; |
45751456b471
Annotate file changes through few revisions, walking either direction (old to new and vice versa)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
551
diff
changeset
|
25 |
562
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
26 import org.tmatesoft.hg.core.HgCallbackTargetException; |
552
45751456b471
Annotate file changes through few revisions, walking either direction (old to new and vice versa)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
551
diff
changeset
|
27 import org.tmatesoft.hg.core.HgIterateDirection; |
542
a71a05ec11bc
Towards annotate/blame support: general outline of the functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
28 import org.tmatesoft.hg.core.Nodeid; |
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
|
29 import org.tmatesoft.hg.internal.ByteArrayChannel; |
e55f17a7a195
AnnotateFacility renamed to HgBlameFacility and exposed, API shapes out and got some javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
555
diff
changeset
|
30 import org.tmatesoft.hg.internal.Callback; |
e55f17a7a195
AnnotateFacility renamed to HgBlameFacility and exposed, API shapes out and got some javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
555
diff
changeset
|
31 import org.tmatesoft.hg.internal.DiffHelper; |
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 import org.tmatesoft.hg.internal.Experimental; |
e55f17a7a195
AnnotateFacility renamed to HgBlameFacility and exposed, API shapes out and got some javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
555
diff
changeset
|
33 import org.tmatesoft.hg.internal.IntMap; |
e55f17a7a195
AnnotateFacility renamed to HgBlameFacility and exposed, API shapes out and got some javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
555
diff
changeset
|
34 import org.tmatesoft.hg.internal.IntVector; |
551
4ea0351ca878
Better (precise) name for diff facility, tests
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
549
diff
changeset
|
35 import org.tmatesoft.hg.internal.DiffHelper.LineSequence; |
554
a5fd757d1b5d
Access to content of annotated files through BlockData interface
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
553
diff
changeset
|
36 import org.tmatesoft.hg.internal.DiffHelper.LineSequence.ByteChain; |
558
154718ae23ed
Annotate: refactor/reuse range handling code
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
557
diff
changeset
|
37 import org.tmatesoft.hg.internal.RangeSeq; |
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
|
38 import org.tmatesoft.hg.repo.HgBlameFacility.RevisionDescriptor.Recipient; |
555
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
39 import org.tmatesoft.hg.util.Adaptable; |
542
a71a05ec11bc
Towards annotate/blame support: general outline of the functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
40 import org.tmatesoft.hg.util.CancelledException; |
552
45751456b471
Annotate file changes through few revisions, walking either direction (old to new and vice versa)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
551
diff
changeset
|
41 import org.tmatesoft.hg.util.Pair; |
542
a71a05ec11bc
Towards annotate/blame support: general outline of the functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
42 |
a71a05ec11bc
Towards annotate/blame support: general outline of the functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
43 /** |
555
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
44 * Facility with diff/annotate functionality. |
542
a71a05ec11bc
Towards annotate/blame support: general outline of the functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
45 * |
a71a05ec11bc
Towards annotate/blame support: general outline of the functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
46 * @author Artem Tikhomirov |
a71a05ec11bc
Towards annotate/blame support: general outline of the functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
47 * @author TMate Software Ltd. |
a71a05ec11bc
Towards annotate/blame support: general outline of the functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
48 */ |
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
|
49 @Experimental(reason="Unstable API") |
e55f17a7a195
AnnotateFacility renamed to HgBlameFacility and exposed, API shapes out and got some javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
555
diff
changeset
|
50 public final class HgBlameFacility { |
549
83afa680555d
Annotate merge revision (combined diff against two parents without looking further)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
548
diff
changeset
|
51 |
83afa680555d
Annotate merge revision (combined diff against two parents without looking further)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
548
diff
changeset
|
52 /** |
552
45751456b471
Annotate file changes through few revisions, walking either direction (old to new and vice versa)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
551
diff
changeset
|
53 * mimic 'hg diff -r clogRevIndex1 -r clogRevIndex2' |
549
83afa680555d
Annotate merge revision (combined diff against two parents without looking further)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
548
diff
changeset
|
54 */ |
562
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
55 public void diff(HgDataFile df, int clogRevIndex1, int clogRevIndex2, Inspector insp) throws HgCallbackTargetException { |
552
45751456b471
Annotate file changes through few revisions, walking either direction (old to new and vice versa)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
551
diff
changeset
|
56 int fileRevIndex1 = fileRevIndex(df, clogRevIndex1); |
45751456b471
Annotate file changes through few revisions, walking either direction (old to new and vice versa)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
551
diff
changeset
|
57 int fileRevIndex2 = fileRevIndex(df, clogRevIndex2); |
45751456b471
Annotate file changes through few revisions, walking either direction (old to new and vice versa)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
551
diff
changeset
|
58 FileLinesCache fileInfoCache = new FileLinesCache(df, 5); |
45751456b471
Annotate file changes through few revisions, walking either direction (old to new and vice versa)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
551
diff
changeset
|
59 LineSequence c1 = fileInfoCache.lines(fileRevIndex1); |
45751456b471
Annotate file changes through few revisions, walking either direction (old to new and vice versa)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
551
diff
changeset
|
60 LineSequence c2 = fileInfoCache.lines(fileRevIndex2); |
551
4ea0351ca878
Better (precise) name for diff facility, tests
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
549
diff
changeset
|
61 DiffHelper<LineSequence> pg = new DiffHelper<LineSequence>(); |
549
83afa680555d
Annotate merge revision (combined diff against two parents without looking further)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
548
diff
changeset
|
62 pg.init(c1, c2); |
562
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
63 BlameBlockInspector bbi = new BlameBlockInspector(fileRevIndex2, insp, clogRevIndex1, clogRevIndex2); |
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
64 pg.findMatchingBlocks(bbi); |
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
65 bbi.checkErrors(); |
552
45751456b471
Annotate file changes through few revisions, walking either direction (old to new and vice versa)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
551
diff
changeset
|
66 } |
45751456b471
Annotate file changes through few revisions, walking either direction (old to new and vice versa)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
551
diff
changeset
|
67 |
555
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
68 /** |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
69 * Walk file history up to revision at given changeset and report changes for each revision |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
70 */ |
562
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
71 public void annotate(HgDataFile df, int changelogRevisionIndex, Inspector insp, HgIterateDirection iterateOrder) throws HgCallbackTargetException { |
552
45751456b471
Annotate file changes through few revisions, walking either direction (old to new and vice versa)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
551
diff
changeset
|
72 if (!df.exists()) { |
45751456b471
Annotate file changes through few revisions, walking either direction (old to new and vice versa)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
551
diff
changeset
|
73 return; |
45751456b471
Annotate file changes through few revisions, walking either direction (old to new and vice versa)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
551
diff
changeset
|
74 } |
45751456b471
Annotate file changes through few revisions, walking either direction (old to new and vice versa)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
551
diff
changeset
|
75 // Note, changelogRevisionIndex may be TIP, while #implAnnotateChange doesn't tolerate constants |
45751456b471
Annotate file changes through few revisions, walking either direction (old to new and vice versa)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
551
diff
changeset
|
76 // |
45751456b471
Annotate file changes through few revisions, walking either direction (old to new and vice versa)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
551
diff
changeset
|
77 // XXX df.indexWalk(0, fileRevIndex, ) might be more effective |
45751456b471
Annotate file changes through few revisions, walking either direction (old to new and vice versa)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
551
diff
changeset
|
78 int fileRevIndex = fileRevIndex(df, changelogRevisionIndex); |
45751456b471
Annotate file changes through few revisions, walking either direction (old to new and vice versa)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
551
diff
changeset
|
79 int[] fileRevParents = new int[2]; |
45751456b471
Annotate file changes through few revisions, walking either direction (old to new and vice versa)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
551
diff
changeset
|
80 IntVector fileParentRevs = new IntVector((fileRevIndex+1) * 2, 0); |
45751456b471
Annotate file changes through few revisions, walking either direction (old to new and vice versa)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
551
diff
changeset
|
81 fileParentRevs.add(NO_REVISION, NO_REVISION); |
45751456b471
Annotate file changes through few revisions, walking either direction (old to new and vice versa)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
551
diff
changeset
|
82 for (int i = 1; i <= fileRevIndex; i++) { |
45751456b471
Annotate file changes through few revisions, walking either direction (old to new and vice versa)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
551
diff
changeset
|
83 df.parents(i, fileRevParents, null, null); |
45751456b471
Annotate file changes through few revisions, walking either direction (old to new and vice versa)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
551
diff
changeset
|
84 fileParentRevs.add(fileRevParents[0], fileRevParents[1]); |
45751456b471
Annotate file changes through few revisions, walking either direction (old to new and vice versa)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
551
diff
changeset
|
85 } |
561
d3c71498919c
Do not process child revisions before all possible parent paths were visited
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
558
diff
changeset
|
86 // collect file revisions to visit, from newest to oldest: |
d3c71498919c
Do not process child revisions before all possible parent paths were visited
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
558
diff
changeset
|
87 // traverse parents, starting from the given file revision |
d3c71498919c
Do not process child revisions before all possible parent paths were visited
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
558
diff
changeset
|
88 // this ignores all file revision made in parallel to the one of interest |
552
45751456b471
Annotate file changes through few revisions, walking either direction (old to new and vice versa)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
551
diff
changeset
|
89 IntVector fileRevsToVisit = new IntVector(fileRevIndex + 1, 0); |
45751456b471
Annotate file changes through few revisions, walking either direction (old to new and vice versa)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
551
diff
changeset
|
90 LinkedList<Integer> queue = new LinkedList<Integer>(); |
45751456b471
Annotate file changes through few revisions, walking either direction (old to new and vice versa)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
551
diff
changeset
|
91 BitSet seen = new BitSet(fileRevIndex + 1); |
45751456b471
Annotate file changes through few revisions, walking either direction (old to new and vice versa)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
551
diff
changeset
|
92 queue.add(fileRevIndex); |
45751456b471
Annotate file changes through few revisions, walking either direction (old to new and vice versa)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
551
diff
changeset
|
93 do { |
45751456b471
Annotate file changes through few revisions, walking either direction (old to new and vice versa)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
551
diff
changeset
|
94 int x = queue.removeFirst(); |
45751456b471
Annotate file changes through few revisions, walking either direction (old to new and vice versa)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
551
diff
changeset
|
95 if (seen.get(x)) { |
45751456b471
Annotate file changes through few revisions, walking either direction (old to new and vice versa)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
551
diff
changeset
|
96 continue; |
45751456b471
Annotate file changes through few revisions, walking either direction (old to new and vice versa)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
551
diff
changeset
|
97 } |
45751456b471
Annotate file changes through few revisions, walking either direction (old to new and vice versa)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
551
diff
changeset
|
98 seen.set(x); |
45751456b471
Annotate file changes through few revisions, walking either direction (old to new and vice versa)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
551
diff
changeset
|
99 fileRevsToVisit.add(x); |
45751456b471
Annotate file changes through few revisions, walking either direction (old to new and vice versa)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
551
diff
changeset
|
100 int p1 = fileParentRevs.get(2*x); |
45751456b471
Annotate file changes through few revisions, walking either direction (old to new and vice versa)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
551
diff
changeset
|
101 int p2 = fileParentRevs.get(2*x + 1); |
45751456b471
Annotate file changes through few revisions, walking either direction (old to new and vice versa)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
551
diff
changeset
|
102 if (p1 != NO_REVISION) { |
45751456b471
Annotate file changes through few revisions, walking either direction (old to new and vice versa)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
551
diff
changeset
|
103 queue.addLast(p1); |
45751456b471
Annotate file changes through few revisions, walking either direction (old to new and vice versa)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
551
diff
changeset
|
104 } |
45751456b471
Annotate file changes through few revisions, walking either direction (old to new and vice versa)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
551
diff
changeset
|
105 if (p2 != NO_REVISION) { |
45751456b471
Annotate file changes through few revisions, walking either direction (old to new and vice versa)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
551
diff
changeset
|
106 queue.addLast(p2); |
45751456b471
Annotate file changes through few revisions, walking either direction (old to new and vice versa)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
551
diff
changeset
|
107 } |
45751456b471
Annotate file changes through few revisions, walking either direction (old to new and vice versa)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
551
diff
changeset
|
108 } while (!queue.isEmpty()); |
45751456b471
Annotate file changes through few revisions, walking either direction (old to new and vice versa)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
551
diff
changeset
|
109 FileLinesCache fileInfoCache = new FileLinesCache(df, 10); |
561
d3c71498919c
Do not process child revisions before all possible parent paths were visited
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
558
diff
changeset
|
110 // make sure no child is processed before we handled all (grand-)parents of the element |
d3c71498919c
Do not process child revisions before all possible parent paths were visited
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
558
diff
changeset
|
111 fileRevsToVisit.sort(false); |
552
45751456b471
Annotate file changes through few revisions, walking either direction (old to new and vice versa)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
551
diff
changeset
|
112 // fileRevsToVisit now { r10, r7, r6, r5, r0 } |
45751456b471
Annotate file changes through few revisions, walking either direction (old to new and vice versa)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
551
diff
changeset
|
113 // and we'll iterate it from behind, e.g. old to new unless reversed |
45751456b471
Annotate file changes through few revisions, walking either direction (old to new and vice versa)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
551
diff
changeset
|
114 if (iterateOrder == HgIterateDirection.NewToOld) { |
45751456b471
Annotate file changes through few revisions, walking either direction (old to new and vice versa)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
551
diff
changeset
|
115 fileRevsToVisit.reverse(); |
45751456b471
Annotate file changes through few revisions, walking either direction (old to new and vice versa)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
551
diff
changeset
|
116 } |
45751456b471
Annotate file changes through few revisions, walking either direction (old to new and vice versa)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
551
diff
changeset
|
117 for (int i = fileRevsToVisit.size() - 1; i >= 0; i--) { |
45751456b471
Annotate file changes through few revisions, walking either direction (old to new and vice versa)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
551
diff
changeset
|
118 int fri = fileRevsToVisit.get(i); |
45751456b471
Annotate file changes through few revisions, walking either direction (old to new and vice versa)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
551
diff
changeset
|
119 int clogRevIndex = df.getChangesetRevisionIndex(fri); |
45751456b471
Annotate file changes through few revisions, walking either direction (old to new and vice versa)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
551
diff
changeset
|
120 fileRevParents[0] = fileParentRevs.get(fri * 2); |
45751456b471
Annotate file changes through few revisions, walking either direction (old to new and vice versa)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
551
diff
changeset
|
121 fileRevParents[1] = fileParentRevs.get(fri * 2 + 1); |
45751456b471
Annotate file changes through few revisions, walking either direction (old to new and vice versa)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
551
diff
changeset
|
122 implAnnotateChange(fileInfoCache, clogRevIndex, fri, fileRevParents, insp); |
45751456b471
Annotate file changes through few revisions, walking either direction (old to new and vice versa)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
551
diff
changeset
|
123 } |
549
83afa680555d
Annotate merge revision (combined diff against two parents without looking further)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
548
diff
changeset
|
124 } |
548
ab21ac7dd833
Line-by-line annotation API and support code in place
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
546
diff
changeset
|
125 |
ab21ac7dd833
Line-by-line annotation API and support code in place
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
546
diff
changeset
|
126 /** |
555
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
127 * Annotates changes of the file against its parent(s). |
562
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
128 * Unlike {@link #annotate(HgDataFile, int, Inspector, HgIterateDirection)}, doesn't |
555
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
129 * walk file history, looks at the specified revision only. Handles both parents (if merge revision). |
548
ab21ac7dd833
Line-by-line annotation API and support code in place
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
546
diff
changeset
|
130 */ |
562
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
131 public void annotateSingleRevision(HgDataFile df, int changelogRevisionIndex, Inspector insp) throws HgCallbackTargetException { |
545
15b406c7cd9d
First round of annotate file is functional
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
544
diff
changeset
|
132 // TODO detect if file is text/binary (e.g. looking for chars < ' ' and not \t\r\n\f |
552
45751456b471
Annotate file changes through few revisions, walking either direction (old to new and vice versa)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
551
diff
changeset
|
133 int fileRevIndex = fileRevIndex(df, changelogRevisionIndex); |
542
a71a05ec11bc
Towards annotate/blame support: general outline of the functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
134 int[] fileRevParents = new int[2]; |
a71a05ec11bc
Towards annotate/blame support: general outline of the functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
135 df.parents(fileRevIndex, fileRevParents, null, null); |
552
45751456b471
Annotate file changes through few revisions, walking either direction (old to new and vice versa)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
551
diff
changeset
|
136 if (changelogRevisionIndex == TIP) { |
45751456b471
Annotate file changes through few revisions, walking either direction (old to new and vice versa)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
551
diff
changeset
|
137 changelogRevisionIndex = df.getChangesetRevisionIndex(fileRevIndex); |
548
ab21ac7dd833
Line-by-line annotation API and support code in place
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
546
diff
changeset
|
138 } |
552
45751456b471
Annotate file changes through few revisions, walking either direction (old to new and vice versa)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
551
diff
changeset
|
139 implAnnotateChange(new FileLinesCache(df, 5), changelogRevisionIndex, fileRevIndex, fileRevParents, insp); |
548
ab21ac7dd833
Line-by-line annotation API and support code in place
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
546
diff
changeset
|
140 } |
ab21ac7dd833
Line-by-line annotation API and support code in place
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
546
diff
changeset
|
141 |
562
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
142 private void implAnnotateChange(FileLinesCache fl, int csetRevIndex, int fileRevIndex, int[] fileParentRevs, Inspector insp) throws HgCallbackTargetException { |
552
45751456b471
Annotate file changes through few revisions, walking either direction (old to new and vice versa)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
551
diff
changeset
|
143 final LineSequence fileRevLines = fl.lines(fileRevIndex); |
549
83afa680555d
Annotate merge revision (combined diff against two parents without looking further)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
548
diff
changeset
|
144 if (fileParentRevs[0] != NO_REVISION && fileParentRevs[1] != NO_REVISION) { |
552
45751456b471
Annotate file changes through few revisions, walking either direction (old to new and vice versa)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
551
diff
changeset
|
145 LineSequence p1Lines = fl.lines(fileParentRevs[0]); |
45751456b471
Annotate file changes through few revisions, walking either direction (old to new and vice versa)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
551
diff
changeset
|
146 LineSequence p2Lines = fl.lines(fileParentRevs[1]); |
45751456b471
Annotate file changes through few revisions, walking either direction (old to new and vice versa)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
551
diff
changeset
|
147 int p1ClogIndex = fl.getChangesetRevisionIndex(fileParentRevs[0]); |
45751456b471
Annotate file changes through few revisions, walking either direction (old to new and vice versa)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
551
diff
changeset
|
148 int p2ClogIndex = fl.getChangesetRevisionIndex(fileParentRevs[1]); |
551
4ea0351ca878
Better (precise) name for diff facility, tests
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
549
diff
changeset
|
149 DiffHelper<LineSequence> pg = new DiffHelper<LineSequence>(); |
549
83afa680555d
Annotate merge revision (combined diff against two parents without looking further)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
548
diff
changeset
|
150 pg.init(p2Lines, fileRevLines); |
83afa680555d
Annotate merge revision (combined diff against two parents without looking further)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
548
diff
changeset
|
151 EqualBlocksCollector p2MergeCommon = new EqualBlocksCollector(); |
83afa680555d
Annotate merge revision (combined diff against two parents without looking further)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
548
diff
changeset
|
152 pg.findMatchingBlocks(p2MergeCommon); |
83afa680555d
Annotate merge revision (combined diff against two parents without looking further)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
548
diff
changeset
|
153 // |
83afa680555d
Annotate merge revision (combined diff against two parents without looking further)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
548
diff
changeset
|
154 pg.init(p1Lines); |
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
|
155 BlameBlockInspector bbi = new BlameBlockInspector(fileRevIndex, insp, p1ClogIndex, csetRevIndex); |
549
83afa680555d
Annotate merge revision (combined diff against two parents without looking further)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
548
diff
changeset
|
156 bbi.setMergeParent2(p2MergeCommon, p2ClogIndex); |
83afa680555d
Annotate merge revision (combined diff against two parents without looking further)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
548
diff
changeset
|
157 pg.findMatchingBlocks(bbi); |
562
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
158 bbi.checkErrors(); |
549
83afa680555d
Annotate merge revision (combined diff against two parents without looking further)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
548
diff
changeset
|
159 } else if (fileParentRevs[0] == fileParentRevs[1]) { |
83afa680555d
Annotate merge revision (combined diff against two parents without looking further)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
548
diff
changeset
|
160 // may be equal iff both are unset |
83afa680555d
Annotate merge revision (combined diff against two parents without looking further)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
548
diff
changeset
|
161 assert fileParentRevs[0] == NO_REVISION; |
83afa680555d
Annotate merge revision (combined diff against two parents without looking further)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
548
diff
changeset
|
162 // everything added |
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
|
163 BlameBlockInspector bbi = new BlameBlockInspector(fileRevIndex, insp, NO_REVISION, csetRevIndex); |
549
83afa680555d
Annotate merge revision (combined diff against two parents without looking further)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
548
diff
changeset
|
164 bbi.begin(LineSequence.newlines(new byte[0]), fileRevLines); |
83afa680555d
Annotate merge revision (combined diff against two parents without looking further)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
548
diff
changeset
|
165 bbi.match(0, fileRevLines.chunkCount()-1, 0); |
83afa680555d
Annotate merge revision (combined diff against two parents without looking further)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
548
diff
changeset
|
166 bbi.end(); |
562
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
167 bbi.checkErrors(); |
549
83afa680555d
Annotate merge revision (combined diff against two parents without looking further)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
548
diff
changeset
|
168 } else { |
83afa680555d
Annotate merge revision (combined diff against two parents without looking further)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
548
diff
changeset
|
169 int soleParent = fileParentRevs[0] == NO_REVISION ? fileParentRevs[1] : fileParentRevs[0]; |
83afa680555d
Annotate merge revision (combined diff against two parents without looking further)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
548
diff
changeset
|
170 assert soleParent != NO_REVISION; |
552
45751456b471
Annotate file changes through few revisions, walking either direction (old to new and vice versa)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
551
diff
changeset
|
171 LineSequence parentLines = fl.lines(soleParent); |
549
83afa680555d
Annotate merge revision (combined diff against two parents without looking further)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
548
diff
changeset
|
172 |
552
45751456b471
Annotate file changes through few revisions, walking either direction (old to new and vice versa)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
551
diff
changeset
|
173 int parentChangesetRevIndex = fl.getChangesetRevisionIndex(soleParent); |
551
4ea0351ca878
Better (precise) name for diff facility, tests
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
549
diff
changeset
|
174 DiffHelper<LineSequence> pg = new DiffHelper<LineSequence>(); |
549
83afa680555d
Annotate merge revision (combined diff against two parents without looking further)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
548
diff
changeset
|
175 pg.init(parentLines, fileRevLines); |
562
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
176 BlameBlockInspector bbi = new BlameBlockInspector(fileRevIndex, insp, parentChangesetRevIndex, csetRevIndex); |
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
177 pg.findMatchingBlocks(bbi); |
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
178 bbi.checkErrors(); |
549
83afa680555d
Annotate merge revision (combined diff against two parents without looking further)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
548
diff
changeset
|
179 } |
83afa680555d
Annotate merge revision (combined diff against two parents without looking further)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
548
diff
changeset
|
180 } |
83afa680555d
Annotate merge revision (combined diff against two parents without looking further)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
548
diff
changeset
|
181 |
83afa680555d
Annotate merge revision (combined diff against two parents without looking further)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
548
diff
changeset
|
182 private static int fileRevIndex(HgDataFile df, int csetRevIndex) { |
83afa680555d
Annotate merge revision (combined diff against two parents without looking further)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
548
diff
changeset
|
183 Nodeid fileRev = df.getRepo().getManifest().getFileRevision(csetRevIndex, df.getPath()); |
83afa680555d
Annotate merge revision (combined diff against two parents without looking further)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
548
diff
changeset
|
184 return df.getRevisionIndex(fileRev); |
83afa680555d
Annotate merge revision (combined diff against two parents without looking further)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
548
diff
changeset
|
185 } |
83afa680555d
Annotate merge revision (combined diff against two parents without looking further)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
548
diff
changeset
|
186 |
552
45751456b471
Annotate file changes through few revisions, walking either direction (old to new and vice versa)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
551
diff
changeset
|
187 private static class FileLinesCache { |
45751456b471
Annotate file changes through few revisions, walking either direction (old to new and vice versa)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
551
diff
changeset
|
188 private final HgDataFile df; |
45751456b471
Annotate file changes through few revisions, walking either direction (old to new and vice versa)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
551
diff
changeset
|
189 private final LinkedList<Pair<Integer, LineSequence>> lruCache; |
45751456b471
Annotate file changes through few revisions, walking either direction (old to new and vice versa)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
551
diff
changeset
|
190 private final int limit; |
45751456b471
Annotate file changes through few revisions, walking either direction (old to new and vice versa)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
551
diff
changeset
|
191 private IntMap<Integer> fileToClogIndexMap = new IntMap<Integer>(20); |
45751456b471
Annotate file changes through few revisions, walking either direction (old to new and vice versa)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
551
diff
changeset
|
192 |
45751456b471
Annotate file changes through few revisions, walking either direction (old to new and vice versa)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
551
diff
changeset
|
193 public FileLinesCache(HgDataFile file, int lruLimit) { |
45751456b471
Annotate file changes through few revisions, walking either direction (old to new and vice versa)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
551
diff
changeset
|
194 df = file; |
45751456b471
Annotate file changes through few revisions, walking either direction (old to new and vice versa)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
551
diff
changeset
|
195 limit = lruLimit; |
45751456b471
Annotate file changes through few revisions, walking either direction (old to new and vice versa)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
551
diff
changeset
|
196 lruCache = new LinkedList<Pair<Integer, LineSequence>>(); |
45751456b471
Annotate file changes through few revisions, walking either direction (old to new and vice versa)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
551
diff
changeset
|
197 } |
45751456b471
Annotate file changes through few revisions, walking either direction (old to new and vice versa)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
551
diff
changeset
|
198 |
45751456b471
Annotate file changes through few revisions, walking either direction (old to new and vice versa)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
551
diff
changeset
|
199 public int getChangesetRevisionIndex(int fileRevIndex) { |
45751456b471
Annotate file changes through few revisions, walking either direction (old to new and vice versa)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
551
diff
changeset
|
200 Integer cached = fileToClogIndexMap.get(fileRevIndex); |
45751456b471
Annotate file changes through few revisions, walking either direction (old to new and vice versa)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
551
diff
changeset
|
201 if (cached == null) { |
45751456b471
Annotate file changes through few revisions, walking either direction (old to new and vice versa)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
551
diff
changeset
|
202 cached = df.getChangesetRevisionIndex(fileRevIndex); |
45751456b471
Annotate file changes through few revisions, walking either direction (old to new and vice versa)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
551
diff
changeset
|
203 fileToClogIndexMap.put(fileRevIndex, cached); |
45751456b471
Annotate file changes through few revisions, walking either direction (old to new and vice versa)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
551
diff
changeset
|
204 } |
45751456b471
Annotate file changes through few revisions, walking either direction (old to new and vice versa)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
551
diff
changeset
|
205 return cached.intValue(); |
45751456b471
Annotate file changes through few revisions, walking either direction (old to new and vice versa)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
551
diff
changeset
|
206 } |
45751456b471
Annotate file changes through few revisions, walking either direction (old to new and vice versa)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
551
diff
changeset
|
207 |
45751456b471
Annotate file changes through few revisions, walking either direction (old to new and vice versa)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
551
diff
changeset
|
208 public LineSequence lines(int fileRevIndex) { |
45751456b471
Annotate file changes through few revisions, walking either direction (old to new and vice versa)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
551
diff
changeset
|
209 Pair<Integer, LineSequence> cached = checkCache(fileRevIndex); |
45751456b471
Annotate file changes through few revisions, walking either direction (old to new and vice versa)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
551
diff
changeset
|
210 if (cached != null) { |
45751456b471
Annotate file changes through few revisions, walking either direction (old to new and vice versa)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
551
diff
changeset
|
211 return cached.second(); |
45751456b471
Annotate file changes through few revisions, walking either direction (old to new and vice versa)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
551
diff
changeset
|
212 } |
45751456b471
Annotate file changes through few revisions, walking either direction (old to new and vice versa)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
551
diff
changeset
|
213 try { |
45751456b471
Annotate file changes through few revisions, walking either direction (old to new and vice versa)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
551
diff
changeset
|
214 ByteArrayChannel c; |
45751456b471
Annotate file changes through few revisions, walking either direction (old to new and vice versa)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
551
diff
changeset
|
215 df.content(fileRevIndex, c = new ByteArrayChannel()); |
45751456b471
Annotate file changes through few revisions, walking either direction (old to new and vice versa)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
551
diff
changeset
|
216 LineSequence rv = LineSequence.newlines(c.toArray()); |
45751456b471
Annotate file changes through few revisions, walking either direction (old to new and vice versa)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
551
diff
changeset
|
217 lruCache.addFirst(new Pair<Integer, LineSequence>(fileRevIndex, rv)); |
45751456b471
Annotate file changes through few revisions, walking either direction (old to new and vice versa)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
551
diff
changeset
|
218 if (lruCache.size() > limit) { |
45751456b471
Annotate file changes through few revisions, walking either direction (old to new and vice versa)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
551
diff
changeset
|
219 lruCache.removeLast(); |
45751456b471
Annotate file changes through few revisions, walking either direction (old to new and vice versa)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
551
diff
changeset
|
220 } |
45751456b471
Annotate file changes through few revisions, walking either direction (old to new and vice versa)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
551
diff
changeset
|
221 return rv; |
45751456b471
Annotate file changes through few revisions, walking either direction (old to new and vice versa)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
551
diff
changeset
|
222 } catch (CancelledException ex) { |
45751456b471
Annotate file changes through few revisions, walking either direction (old to new and vice versa)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
551
diff
changeset
|
223 // TODO likely it was bad idea to throw cancelled exception from content() |
45751456b471
Annotate file changes through few revisions, walking either direction (old to new and vice versa)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
551
diff
changeset
|
224 // deprecate and provide alternative? |
45751456b471
Annotate file changes through few revisions, walking either direction (old to new and vice versa)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
551
diff
changeset
|
225 HgInvalidStateException ise = new HgInvalidStateException("ByteArrayChannel never throws CancelledException"); |
45751456b471
Annotate file changes through few revisions, walking either direction (old to new and vice versa)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
551
diff
changeset
|
226 ise.initCause(ex); |
45751456b471
Annotate file changes through few revisions, walking either direction (old to new and vice versa)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
551
diff
changeset
|
227 throw ise; |
45751456b471
Annotate file changes through few revisions, walking either direction (old to new and vice versa)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
551
diff
changeset
|
228 } |
45751456b471
Annotate file changes through few revisions, walking either direction (old to new and vice versa)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
551
diff
changeset
|
229 } |
45751456b471
Annotate file changes through few revisions, walking either direction (old to new and vice versa)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
551
diff
changeset
|
230 |
45751456b471
Annotate file changes through few revisions, walking either direction (old to new and vice versa)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
551
diff
changeset
|
231 private Pair<Integer,LineSequence> checkCache(int fileRevIndex) { |
45751456b471
Annotate file changes through few revisions, walking either direction (old to new and vice versa)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
551
diff
changeset
|
232 Pair<Integer, LineSequence> rv = null; |
45751456b471
Annotate file changes through few revisions, walking either direction (old to new and vice versa)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
551
diff
changeset
|
233 for (ListIterator<Pair<Integer, LineSequence>> it = lruCache.listIterator(); it.hasNext(); ) { |
45751456b471
Annotate file changes through few revisions, walking either direction (old to new and vice versa)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
551
diff
changeset
|
234 Pair<Integer, LineSequence> p = it.next(); |
45751456b471
Annotate file changes through few revisions, walking either direction (old to new and vice versa)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
551
diff
changeset
|
235 if (p.first() == fileRevIndex) { |
45751456b471
Annotate file changes through few revisions, walking either direction (old to new and vice versa)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
551
diff
changeset
|
236 rv = p; |
45751456b471
Annotate file changes through few revisions, walking either direction (old to new and vice versa)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
551
diff
changeset
|
237 it.remove(); |
45751456b471
Annotate file changes through few revisions, walking either direction (old to new and vice versa)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
551
diff
changeset
|
238 break; |
45751456b471
Annotate file changes through few revisions, walking either direction (old to new and vice versa)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
551
diff
changeset
|
239 } |
45751456b471
Annotate file changes through few revisions, walking either direction (old to new and vice versa)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
551
diff
changeset
|
240 } |
45751456b471
Annotate file changes through few revisions, walking either direction (old to new and vice versa)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
551
diff
changeset
|
241 if (rv != null) { |
45751456b471
Annotate file changes through few revisions, walking either direction (old to new and vice versa)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
551
diff
changeset
|
242 lruCache.addFirst(rv); |
45751456b471
Annotate file changes through few revisions, walking either direction (old to new and vice versa)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
551
diff
changeset
|
243 } |
45751456b471
Annotate file changes through few revisions, walking either direction (old to new and vice versa)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
551
diff
changeset
|
244 return rv; |
542
a71a05ec11bc
Towards annotate/blame support: general outline of the functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
245 } |
a71a05ec11bc
Towards annotate/blame support: general outline of the functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
246 } |
a71a05ec11bc
Towards annotate/blame support: general outline of the functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
247 |
555
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
248 /** |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
249 * Client's sink for revision differences. |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
250 * |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
251 * When implemented, clients shall not expect new {@link Block blocks} instances in each call. |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
252 * |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
253 * In case more information about annotated revision is needed, inspector instances may supply |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
254 * {@link RevisionDescriptor.Recipient} through {@link Adaptable}. |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
255 */ |
542
a71a05ec11bc
Towards annotate/blame support: general outline of the functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
256 @Callback |
562
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
257 public interface Inspector { |
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
258 void same(EqualBlock block) throws HgCallbackTargetException; |
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
259 void added(AddBlock block) throws HgCallbackTargetException; |
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
260 void changed(ChangeBlock block) throws HgCallbackTargetException; |
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
261 void deleted(DeleteBlock block) throws HgCallbackTargetException; |
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
262 } |
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
263 |
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
264 /** |
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
265 * No need to keep "Block" prefix as long as there's only one {@link Inspector} |
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
266 */ |
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
267 @Deprecated |
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
268 public interface BlockInspector extends Inspector { |
542
a71a05ec11bc
Towards annotate/blame support: general outline of the functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
269 } |
a71a05ec11bc
Towards annotate/blame support: general outline of the functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
270 |
554
a5fd757d1b5d
Access to content of annotated files through BlockData interface
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
553
diff
changeset
|
271 /** |
a5fd757d1b5d
Access to content of annotated files through BlockData interface
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
553
diff
changeset
|
272 * Represents content of a block, either as a sequence of bytes or a |
a5fd757d1b5d
Access to content of annotated files through BlockData interface
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
553
diff
changeset
|
273 * sequence of smaller blocks (lines), if appropriate (according to usage context). |
a5fd757d1b5d
Access to content of annotated files through BlockData interface
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
553
diff
changeset
|
274 * |
a5fd757d1b5d
Access to content of annotated files through BlockData interface
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
553
diff
changeset
|
275 * This approach allows line-by-line access to content data along with complete byte sequence for the whole block, i.e. |
a5fd757d1b5d
Access to content of annotated files through BlockData interface
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
553
diff
changeset
|
276 * <pre> |
a5fd757d1b5d
Access to content of annotated files through BlockData interface
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
553
diff
changeset
|
277 * BlockData bd = addBlock.addedLines() |
a5fd757d1b5d
Access to content of annotated files through BlockData interface
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
553
diff
changeset
|
278 * // bd describes data from the addition completely. |
a5fd757d1b5d
Access to content of annotated files through BlockData interface
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
553
diff
changeset
|
279 * // elements of the BlockData are lines |
a5fd757d1b5d
Access to content of annotated files through BlockData interface
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
553
diff
changeset
|
280 * bd.elementCount() == addBlock.totalAddedLines(); |
a5fd757d1b5d
Access to content of annotated files through BlockData interface
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
553
diff
changeset
|
281 * // one cat obtain complete addition with |
a5fd757d1b5d
Access to content of annotated files through BlockData interface
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
553
diff
changeset
|
282 * byte[] everythingAdded = bd.asArray(); |
a5fd757d1b5d
Access to content of annotated files through BlockData interface
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
553
diff
changeset
|
283 * // or iterate line by line |
a5fd757d1b5d
Access to content of annotated files through BlockData interface
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
553
diff
changeset
|
284 * for (int i = 0; i < bd.elementCount(); i++) { |
a5fd757d1b5d
Access to content of annotated files through BlockData interface
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
553
diff
changeset
|
285 * byte[] lineContent = bd.elementAt(i); |
a5fd757d1b5d
Access to content of annotated files through BlockData interface
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
553
diff
changeset
|
286 * String line = new String(lineContent, fileEncodingCharset); |
a5fd757d1b5d
Access to content of annotated files through BlockData interface
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
553
diff
changeset
|
287 * } |
a5fd757d1b5d
Access to content of annotated files through BlockData interface
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
553
diff
changeset
|
288 * where bd.elementAt(0) is the line at index addBlock.firstAddedLine() |
a5fd757d1b5d
Access to content of annotated files through BlockData interface
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
553
diff
changeset
|
289 * </pre> |
a5fd757d1b5d
Access to content of annotated files through BlockData interface
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
553
diff
changeset
|
290 * |
a5fd757d1b5d
Access to content of annotated files through BlockData interface
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
553
diff
changeset
|
291 * LineData or ChunkData? |
a5fd757d1b5d
Access to content of annotated files through BlockData interface
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
553
diff
changeset
|
292 */ |
a5fd757d1b5d
Access to content of annotated files through BlockData interface
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
553
diff
changeset
|
293 public interface BlockData { |
a5fd757d1b5d
Access to content of annotated files through BlockData interface
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
553
diff
changeset
|
294 BlockData elementAt(int index); |
a5fd757d1b5d
Access to content of annotated files through BlockData interface
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
553
diff
changeset
|
295 int elementCount(); |
a5fd757d1b5d
Access to content of annotated files through BlockData interface
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
553
diff
changeset
|
296 byte[] asArray(); |
a5fd757d1b5d
Access to content of annotated files through BlockData interface
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
553
diff
changeset
|
297 } |
a5fd757d1b5d
Access to content of annotated files through BlockData interface
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
553
diff
changeset
|
298 |
555
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
299 /** |
562
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
300 * {@link Inspector} may optionally request extra information about revisions |
555
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
301 * being inspected, denoting itself as a {@link RevisionDescriptor.Recipient}. This class |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
302 * provides complete information about file revision under annotation now. |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
303 */ |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
304 public interface RevisionDescriptor { |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
305 /** |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
306 * @return complete source of the diff origin, never <code>null</code> |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
307 */ |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
308 BlockData origin(); |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
309 /** |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
310 * @return complete source of the diff target, never <code>null</code> |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
311 */ |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
312 BlockData target(); |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
313 /** |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
314 * @return changeset revision index of original file, or {@link HgRepository#NO_REVISION} if it's the very first revision |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
315 */ |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
316 int originChangesetIndex(); |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
317 /** |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
318 * @return changeset revision index of the target file |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
319 */ |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
320 int targetChangesetIndex(); |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
321 /** |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
322 * @return <code>true</code> if this revision is merge |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
323 */ |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
324 boolean isMerge(); |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
325 /** |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
326 * @return changeset revision index of the second, merged parent |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
327 */ |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
328 int mergeChangesetIndex(); |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
329 /** |
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
|
330 * @return revision index of the change in target file's revlog |
555
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
331 */ |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
332 int fileRevisionIndex(); |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
333 |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
334 /** |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
335 * Implement to indicate interest in {@link RevisionDescriptor}. |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
336 * |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
337 * Note, instance of {@link RevisionDescriptor} is the same for |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
338 * {@link #start(RevisionDescriptor)} and {@link #done(RevisionDescriptor)} |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
339 * methods, and not necessarily a new one (i.e. <code>==</code>) for the next |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
340 * revision announced. |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
341 */ |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
342 @Callback |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
343 public interface Recipient { |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
344 /** |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
345 * Comes prior to any change {@link Block blocks} |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
346 */ |
562
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
347 void start(RevisionDescriptor revisionDescription) throws HgCallbackTargetException; |
555
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
348 /** |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
349 * Comes after all change {@link Block blocks} were dispatched |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
350 */ |
562
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
351 void done(RevisionDescriptor revisionDescription) throws HgCallbackTargetException; |
555
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
352 } |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
353 } |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
354 |
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
|
355 /** |
e55f17a7a195
AnnotateFacility renamed to HgBlameFacility and exposed, API shapes out and got some javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
555
diff
changeset
|
356 * Each change block comes from a single origin, blocks that are result of a merge |
e55f17a7a195
AnnotateFacility renamed to HgBlameFacility and exposed, API shapes out and got some javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
555
diff
changeset
|
357 * have {@link #originChangesetIndex()} equal to {@link RevisionDescriptor#mergeChangesetIndex()}. |
e55f17a7a195
AnnotateFacility renamed to HgBlameFacility and exposed, API shapes out and got some javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
555
diff
changeset
|
358 */ |
542
a71a05ec11bc
Towards annotate/blame support: general outline of the functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
359 public interface Block { |
545
15b406c7cd9d
First round of annotate file is functional
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
544
diff
changeset
|
360 int originChangesetIndex(); |
15b406c7cd9d
First round of annotate file is functional
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
544
diff
changeset
|
361 int targetChangesetIndex(); |
542
a71a05ec11bc
Towards annotate/blame support: general outline of the functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
362 } |
a71a05ec11bc
Towards annotate/blame support: general outline of the functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
363 |
545
15b406c7cd9d
First round of annotate file is functional
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
544
diff
changeset
|
364 public interface EqualBlock extends Block { |
15b406c7cd9d
First round of annotate file is functional
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
544
diff
changeset
|
365 int originStart(); |
15b406c7cd9d
First round of annotate file is functional
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
544
diff
changeset
|
366 int targetStart(); |
15b406c7cd9d
First round of annotate file is functional
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
544
diff
changeset
|
367 int length(); |
554
a5fd757d1b5d
Access to content of annotated files through BlockData interface
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
553
diff
changeset
|
368 BlockData content(); |
545
15b406c7cd9d
First round of annotate file is functional
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
544
diff
changeset
|
369 } |
15b406c7cd9d
First round of annotate file is functional
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
544
diff
changeset
|
370 |
542
a71a05ec11bc
Towards annotate/blame support: general outline of the functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
371 public interface AddBlock extends Block { |
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
|
372 /** |
e55f17a7a195
AnnotateFacility renamed to HgBlameFacility and exposed, API shapes out and got some javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
555
diff
changeset
|
373 * @return line index in the origin where this block is inserted |
e55f17a7a195
AnnotateFacility renamed to HgBlameFacility and exposed, API shapes out and got some javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
555
diff
changeset
|
374 */ |
e55f17a7a195
AnnotateFacility renamed to HgBlameFacility and exposed, API shapes out and got some javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
555
diff
changeset
|
375 int insertedAt(); |
e55f17a7a195
AnnotateFacility renamed to HgBlameFacility and exposed, API shapes out and got some javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
555
diff
changeset
|
376 /** |
e55f17a7a195
AnnotateFacility renamed to HgBlameFacility and exposed, API shapes out and got some javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
555
diff
changeset
|
377 * @return line index of the first added line in the target revision |
e55f17a7a195
AnnotateFacility renamed to HgBlameFacility and exposed, API shapes out and got some javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
555
diff
changeset
|
378 */ |
542
a71a05ec11bc
Towards annotate/blame support: general outline of the functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
379 int firstAddedLine(); |
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
|
380 /** |
e55f17a7a195
AnnotateFacility renamed to HgBlameFacility and exposed, API shapes out and got some javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
555
diff
changeset
|
381 * @return number of added lines in this block |
e55f17a7a195
AnnotateFacility renamed to HgBlameFacility and exposed, API shapes out and got some javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
555
diff
changeset
|
382 */ |
542
a71a05ec11bc
Towards annotate/blame support: general outline of the functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
383 int totalAddedLines(); |
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
|
384 /** |
e55f17a7a195
AnnotateFacility renamed to HgBlameFacility and exposed, API shapes out and got some javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
555
diff
changeset
|
385 * @return content of added lines |
e55f17a7a195
AnnotateFacility renamed to HgBlameFacility and exposed, API shapes out and got some javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
555
diff
changeset
|
386 */ |
554
a5fd757d1b5d
Access to content of annotated files through BlockData interface
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
553
diff
changeset
|
387 BlockData addedLines(); |
542
a71a05ec11bc
Towards annotate/blame support: general outline of the functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
388 } |
a71a05ec11bc
Towards annotate/blame support: general outline of the functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
389 public interface DeleteBlock extends Block { |
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
|
390 /** |
e55f17a7a195
AnnotateFacility renamed to HgBlameFacility and exposed, API shapes out and got some javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
555
diff
changeset
|
391 * @return line index in the target revision were this deleted block would be |
e55f17a7a195
AnnotateFacility renamed to HgBlameFacility and exposed, API shapes out and got some javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
555
diff
changeset
|
392 */ |
e55f17a7a195
AnnotateFacility renamed to HgBlameFacility and exposed, API shapes out and got some javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
555
diff
changeset
|
393 int removedAt(); |
e55f17a7a195
AnnotateFacility renamed to HgBlameFacility and exposed, API shapes out and got some javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
555
diff
changeset
|
394 /** |
e55f17a7a195
AnnotateFacility renamed to HgBlameFacility and exposed, API shapes out and got some javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
555
diff
changeset
|
395 * @return line index of the first removed line in the original revision |
e55f17a7a195
AnnotateFacility renamed to HgBlameFacility and exposed, API shapes out and got some javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
555
diff
changeset
|
396 */ |
542
a71a05ec11bc
Towards annotate/blame support: general outline of the functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
397 int firstRemovedLine(); |
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
|
398 /** |
e55f17a7a195
AnnotateFacility renamed to HgBlameFacility and exposed, API shapes out and got some javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
555
diff
changeset
|
399 * @return number of deleted lines in this block |
e55f17a7a195
AnnotateFacility renamed to HgBlameFacility and exposed, API shapes out and got some javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
555
diff
changeset
|
400 */ |
542
a71a05ec11bc
Towards annotate/blame support: general outline of the functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
401 int totalRemovedLines(); |
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
|
402 /** |
e55f17a7a195
AnnotateFacility renamed to HgBlameFacility and exposed, API shapes out and got some javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
555
diff
changeset
|
403 * @return content of deleted lines |
e55f17a7a195
AnnotateFacility renamed to HgBlameFacility and exposed, API shapes out and got some javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
555
diff
changeset
|
404 */ |
554
a5fd757d1b5d
Access to content of annotated files through BlockData interface
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
553
diff
changeset
|
405 BlockData removedLines(); |
542
a71a05ec11bc
Towards annotate/blame support: general outline of the functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
406 } |
a71a05ec11bc
Towards annotate/blame support: general outline of the functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
407 public interface ChangeBlock extends AddBlock, DeleteBlock { |
a71a05ec11bc
Towards annotate/blame support: general outline of the functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
408 } |
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:
545
diff
changeset
|
409 |
555
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
410 private static class BlameBlockInspector extends DiffHelper.DeltaInspector<LineSequence> { |
562
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
411 private final Inspector insp; |
549
83afa680555d
Annotate merge revision (combined diff against two parents without looking further)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
548
diff
changeset
|
412 private final int csetOrigin; |
545
15b406c7cd9d
First round of annotate file is functional
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
544
diff
changeset
|
413 private final int csetTarget; |
549
83afa680555d
Annotate merge revision (combined diff against two parents without looking further)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
548
diff
changeset
|
414 private EqualBlocksCollector p2MergeCommon; |
83afa680555d
Annotate merge revision (combined diff against two parents without looking further)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
548
diff
changeset
|
415 private int csetMergeParent; |
83afa680555d
Annotate merge revision (combined diff against two parents without looking further)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
548
diff
changeset
|
416 private IntVector mergeRanges; |
555
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
417 private final AnnotateRev annotatedRevision; |
562
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
418 private HgCallbackTargetException error; |
542
a71a05ec11bc
Towards annotate/blame support: general outline of the functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
419 |
562
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
420 public BlameBlockInspector(int fileRevIndex, Inspector inspector, int originCset, int targetCset) { |
542
a71a05ec11bc
Towards annotate/blame support: general outline of the functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
421 assert inspector != null; |
a71a05ec11bc
Towards annotate/blame support: general outline of the functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
422 insp = inspector; |
555
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
423 annotatedRevision = new AnnotateRev(); |
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
|
424 annotatedRevision.set(fileRevIndex); |
549
83afa680555d
Annotate merge revision (combined diff against two parents without looking further)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
548
diff
changeset
|
425 csetOrigin = originCset; |
545
15b406c7cd9d
First round of annotate file is functional
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
544
diff
changeset
|
426 csetTarget = targetCset; |
15b406c7cd9d
First round of annotate file is functional
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
544
diff
changeset
|
427 } |
15b406c7cd9d
First round of annotate file is functional
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
544
diff
changeset
|
428 |
549
83afa680555d
Annotate merge revision (combined diff against two parents without looking further)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
548
diff
changeset
|
429 public void setMergeParent2(EqualBlocksCollector p2Merge, int parentCset2) { |
83afa680555d
Annotate merge revision (combined diff against two parents without looking further)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
548
diff
changeset
|
430 p2MergeCommon = p2Merge; |
83afa680555d
Annotate merge revision (combined diff against two parents without looking further)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
548
diff
changeset
|
431 csetMergeParent = parentCset2; |
83afa680555d
Annotate merge revision (combined diff against two parents without looking further)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
548
diff
changeset
|
432 mergeRanges = new IntVector(3*10, 3*10); |
83afa680555d
Annotate merge revision (combined diff against two parents without looking further)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
548
diff
changeset
|
433 } |
83afa680555d
Annotate merge revision (combined diff against two parents without looking further)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
548
diff
changeset
|
434 |
545
15b406c7cd9d
First round of annotate file is functional
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
544
diff
changeset
|
435 @Override |
15b406c7cd9d
First round of annotate file is functional
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
544
diff
changeset
|
436 public void begin(LineSequence s1, LineSequence s2) { |
15b406c7cd9d
First round of annotate file is functional
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
544
diff
changeset
|
437 super.begin(s1, s2); |
562
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
438 if (shallStop()) { |
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
439 return; |
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
440 } |
555
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
441 ContentBlock originContent = new ContentBlock(s1); |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
442 ContentBlock targetContent = new ContentBlock(s2); |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
443 annotatedRevision.set(originContent, targetContent); |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
444 annotatedRevision.set(csetOrigin, csetTarget, p2MergeCommon != null ? csetMergeParent : NO_REVISION); |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
445 Recipient curious = Adaptable.Factory.getAdapter(insp, Recipient.class, null); |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
446 if (curious != null) { |
562
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
447 try { |
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
448 curious.start(annotatedRevision); |
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
449 } catch (HgCallbackTargetException ex) { |
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
450 error = ex; |
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
451 } |
545
15b406c7cd9d
First round of annotate file is functional
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
544
diff
changeset
|
452 } |
15b406c7cd9d
First round of annotate file is functional
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
544
diff
changeset
|
453 } |
15b406c7cd9d
First round of annotate file is functional
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
544
diff
changeset
|
454 |
15b406c7cd9d
First round of annotate file is functional
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
544
diff
changeset
|
455 @Override |
15b406c7cd9d
First round of annotate file is functional
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
544
diff
changeset
|
456 public void end() { |
15b406c7cd9d
First round of annotate file is functional
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
544
diff
changeset
|
457 super.end(); |
562
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
458 if (shallStop()) { |
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
459 return; |
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
460 } |
555
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
461 Recipient curious = Adaptable.Factory.getAdapter(insp, Recipient.class, null); |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
462 if (curious != null) { |
562
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
463 try { |
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
464 curious.done(annotatedRevision); |
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
465 } catch (HgCallbackTargetException ex) { |
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
466 error = ex; |
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
467 } |
545
15b406c7cd9d
First round of annotate file is functional
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
544
diff
changeset
|
468 } |
555
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
469 p2MergeCommon = null; |
542
a71a05ec11bc
Towards annotate/blame support: general outline of the functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
470 } |
a71a05ec11bc
Towards annotate/blame support: general outline of the functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
471 |
a71a05ec11bc
Towards annotate/blame support: general outline of the functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
472 @Override |
a71a05ec11bc
Towards annotate/blame support: general outline of the functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
473 protected void changed(int s1From, int s1To, int s2From, int s2To) { |
562
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
474 if (shallStop()) { |
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
475 return; |
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
476 } |
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
477 try { |
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
478 if (p2MergeCommon != null) { |
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
479 mergeRanges.clear(); |
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
480 p2MergeCommon.combineAndMarkRangesWithTarget(s2From, s2To - s2From, csetOrigin, csetMergeParent, mergeRanges); |
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
481 |
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
482 /* |
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
483 * Usecases, how it USED TO BE initially: |
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
484 * 3 lines changed to 10 lines. range of 10 lines breaks down to 2 from p2, 3 from p1, and 5 from p2. |
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
485 * We report: 2 lines changed to 2(p2), then 1 line changed with 3(p1) and 5 lines added from p2. |
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
486 * |
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
487 * 10 lines changed to 3 lines, range of 3 lines breaks down to 2 line from p1 and 1 line from p2. |
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
488 * We report: 2 lines changed to 2(p1) and 8 lines changed to 1(p2) |
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
489 * |
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
490 * NOW, lines from p2 are always reported as pure add (since we need their insertion point to be in p2, not in p1) |
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
491 * and we try to consume p1 changes as soon as we see first p1's range |
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
492 */ |
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
493 int s1TotalLines = s1To - s1From, s1ConsumedLines = 0, s1Start = s1From; |
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
494 |
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
495 for (int i = 0; i < mergeRanges.size(); i += 3) { |
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
496 final int rangeOrigin = mergeRanges.get(i); |
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
497 final int rangeStart = mergeRanges.get(i+1); |
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
498 final int rangeLen = mergeRanges.get(i+2); |
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
499 final boolean lastRange = i+3 >= mergeRanges.size(); |
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
500 final int s1LinesLeft = s1TotalLines - s1ConsumedLines; |
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
501 // how many lines we may report as changed (don't use more than in range unless it's the very last range) |
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
502 final int s1LinesToBorrow = lastRange ? s1LinesLeft : Math.min(s1LinesLeft, rangeLen); |
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
503 if (rangeOrigin != csetMergeParent && s1LinesToBorrow > 0) { |
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
504 ChangeBlockImpl block = getChangeBlock(s1Start, s1LinesToBorrow, rangeStart, rangeLen); |
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
505 block.setOriginAndTarget(rangeOrigin, csetTarget); |
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
506 insp.changed(block); |
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
507 s1ConsumedLines += s1LinesToBorrow; |
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
508 s1Start += s1LinesToBorrow; |
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
509 } else { |
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
510 int blockInsPoint = rangeOrigin != csetMergeParent ? s1Start : p2MergeCommon.reverseMapLine(rangeStart); |
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
511 ChangeBlockImpl block = getAddBlock(rangeStart, rangeLen, blockInsPoint); |
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
512 block.setOriginAndTarget(rangeOrigin, csetTarget); |
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
513 insp.added(block); |
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
514 } |
549
83afa680555d
Annotate merge revision (combined diff against two parents without looking further)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
548
diff
changeset
|
515 } |
562
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
516 if (s1ConsumedLines != s1TotalLines) { |
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
517 assert s1ConsumedLines < s1TotalLines : String.format("Expected to process %d lines, but actually was %d", s1TotalLines, s1ConsumedLines); |
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
518 // either there were no ranges from p1, whole s2From..s2To range came from p2, shall report as deleted |
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
519 // or the ranges found were not enough to consume whole s2From..s2To |
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
520 // The "deletion point" is shifted to the end of last csetOrigin->csetTarget change |
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
521 int s2DeletePoint = s2From + s1ConsumedLines; |
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
522 ChangeBlockImpl block = new ChangeBlockImpl(annotatedRevision.origin, null, s1Start, s1To - s1Start, -1, -1, -1, s2DeletePoint); |
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
523 block.setOriginAndTarget(csetOrigin, csetTarget); |
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
524 insp.deleted(block); |
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
525 } |
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
526 } else { |
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
527 ChangeBlockImpl block = getChangeBlock(s1From, s1To - s1From, s2From, s2To - s2From); |
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
528 block.setOriginAndTarget(csetOrigin, csetTarget); |
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
529 insp.changed(block); |
549
83afa680555d
Annotate merge revision (combined diff against two parents without looking further)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
548
diff
changeset
|
530 } |
562
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
531 } catch (HgCallbackTargetException ex) { |
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
532 error = ex; |
549
83afa680555d
Annotate merge revision (combined diff against two parents without looking further)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
548
diff
changeset
|
533 } |
542
a71a05ec11bc
Towards annotate/blame support: general outline of the functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
534 } |
a71a05ec11bc
Towards annotate/blame support: general outline of the functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
535 |
a71a05ec11bc
Towards annotate/blame support: general outline of the functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
536 @Override |
a71a05ec11bc
Towards annotate/blame support: general outline of the functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
537 protected void added(int s1InsertPoint, int s2From, int s2To) { |
562
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
538 if (shallStop()) { |
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
539 return; |
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
540 } |
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
541 try { |
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
542 if (p2MergeCommon != null) { |
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
543 mergeRanges.clear(); |
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
544 p2MergeCommon.combineAndMarkRangesWithTarget(s2From, s2To - s2From, csetOrigin, csetMergeParent, mergeRanges); |
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
545 int insPoint = s1InsertPoint; // track changes to insertion point |
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
546 for (int i = 0; i < mergeRanges.size(); i += 3) { |
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
547 int rangeOrigin = mergeRanges.get(i); |
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
548 int rangeStart = mergeRanges.get(i+1); |
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
549 int rangeLen = mergeRanges.get(i+2); |
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
550 ChangeBlockImpl block = getAddBlock(rangeStart, rangeLen, insPoint); |
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
551 block.setOriginAndTarget(rangeOrigin, csetTarget); |
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
552 insp.added(block); |
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
553 // indicate insPoint moved down number of lines we just reported |
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
554 insPoint += rangeLen; |
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
555 } |
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
556 } else { |
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
557 ChangeBlockImpl block = getAddBlock(s2From, s2To - s2From, s1InsertPoint); |
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
558 block.setOriginAndTarget(csetOrigin, csetTarget); |
549
83afa680555d
Annotate merge revision (combined diff against two parents without looking further)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
548
diff
changeset
|
559 insp.added(block); |
83afa680555d
Annotate merge revision (combined diff against two parents without looking further)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
548
diff
changeset
|
560 } |
562
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
561 } catch (HgCallbackTargetException ex) { |
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
562 error = ex; |
549
83afa680555d
Annotate merge revision (combined diff against two parents without looking further)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
548
diff
changeset
|
563 } |
542
a71a05ec11bc
Towards annotate/blame support: general outline of the functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
564 } |
a71a05ec11bc
Towards annotate/blame support: general outline of the functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
565 |
a71a05ec11bc
Towards annotate/blame support: general outline of the functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
566 @Override |
543
1e95f48d9886
Report line index for insertion and deletion, test against 'hg diff' output
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
542
diff
changeset
|
567 protected void deleted(int s2DeletePoint, int s1From, int s1To) { |
562
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
568 if (shallStop()) { |
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
569 return; |
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
570 } |
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
571 try { |
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
572 ChangeBlockImpl block = new ChangeBlockImpl(annotatedRevision.origin, null, s1From, s1To - s1From, -1, -1, -1, s2DeletePoint); |
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
573 block.setOriginAndTarget(csetOrigin, csetTarget); |
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
574 insp.deleted(block); |
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
575 } catch (HgCallbackTargetException ex) { |
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
576 error = ex; |
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
577 } |
542
a71a05ec11bc
Towards annotate/blame support: general outline of the functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
578 } |
a71a05ec11bc
Towards annotate/blame support: general outline of the functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
579 |
a71a05ec11bc
Towards annotate/blame support: general outline of the functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
580 @Override |
a71a05ec11bc
Towards annotate/blame support: general outline of the functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
581 protected void unchanged(int s1From, int s2From, int length) { |
562
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
582 if (shallStop()) { |
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
583 return; |
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
584 } |
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
585 try { |
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
586 EqualBlockImpl block = new EqualBlockImpl(s1From, s2From, length, annotatedRevision.target); |
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
587 block.setOriginAndTarget(csetOrigin, csetTarget); |
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
588 insp.same(block); |
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
589 } catch (HgCallbackTargetException ex) { |
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
590 error = ex; |
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
591 } |
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
592 } |
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
593 |
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
594 void checkErrors() throws HgCallbackTargetException { |
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
595 if (error != null) { |
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
596 throw error; |
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
597 } |
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
598 } |
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
599 |
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
600 private boolean shallStop() { |
6fbca6506bb5
Allow HgBlameFacility.Inspector (former BlockInspector) to throw an exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
561
diff
changeset
|
601 return error != null; |
545
15b406c7cd9d
First round of annotate file is functional
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
544
diff
changeset
|
602 } |
549
83afa680555d
Annotate merge revision (combined diff against two parents without looking further)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
548
diff
changeset
|
603 |
554
a5fd757d1b5d
Access to content of annotated files through BlockData interface
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
553
diff
changeset
|
604 private ChangeBlockImpl getAddBlock(int start, int len, int insPoint) { |
555
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
605 return new ChangeBlockImpl(null, annotatedRevision.target, -1, -1, start, len, insPoint, -1); |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
606 } |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
607 |
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
|
608 private ChangeBlockImpl getChangeBlock(int start1, int len1, int start2, int len2) { |
e55f17a7a195
AnnotateFacility renamed to HgBlameFacility and exposed, API shapes out and got some javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
555
diff
changeset
|
609 return new ChangeBlockImpl(annotatedRevision.origin, annotatedRevision.target, start1, len1, start2, len2, start1, start2); |
549
83afa680555d
Annotate merge revision (combined diff against two parents without looking further)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
548
diff
changeset
|
610 } |
545
15b406c7cd9d
First round of annotate file is functional
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
544
diff
changeset
|
611 } |
15b406c7cd9d
First round of annotate file is functional
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
544
diff
changeset
|
612 |
555
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
613 private static class BlockImpl implements Block { |
545
15b406c7cd9d
First round of annotate file is functional
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
544
diff
changeset
|
614 private int originCset; |
15b406c7cd9d
First round of annotate file is functional
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
544
diff
changeset
|
615 private int targetCset; |
15b406c7cd9d
First round of annotate file is functional
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
544
diff
changeset
|
616 |
15b406c7cd9d
First round of annotate file is functional
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
544
diff
changeset
|
617 void setOriginAndTarget(int originChangesetIndex, int targetChangesetIndex) { |
15b406c7cd9d
First round of annotate file is functional
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
544
diff
changeset
|
618 // XXX perhaps, shall be part of Inspector API, rather than Block's |
15b406c7cd9d
First round of annotate file is functional
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
544
diff
changeset
|
619 // as they don't change between blocks (although the moment about merged revisions) |
15b406c7cd9d
First round of annotate file is functional
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
544
diff
changeset
|
620 // is not yet clear to me |
15b406c7cd9d
First round of annotate file is functional
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
544
diff
changeset
|
621 originCset = originChangesetIndex; |
15b406c7cd9d
First round of annotate file is functional
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
544
diff
changeset
|
622 targetCset = targetChangesetIndex; |
15b406c7cd9d
First round of annotate file is functional
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
544
diff
changeset
|
623 } |
15b406c7cd9d
First round of annotate file is functional
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
544
diff
changeset
|
624 |
15b406c7cd9d
First round of annotate file is functional
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
544
diff
changeset
|
625 public int originChangesetIndex() { |
15b406c7cd9d
First round of annotate file is functional
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
544
diff
changeset
|
626 return originCset; |
15b406c7cd9d
First round of annotate file is functional
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
544
diff
changeset
|
627 } |
15b406c7cd9d
First round of annotate file is functional
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
544
diff
changeset
|
628 |
15b406c7cd9d
First round of annotate file is functional
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
544
diff
changeset
|
629 public int targetChangesetIndex() { |
15b406c7cd9d
First round of annotate file is functional
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
544
diff
changeset
|
630 return targetCset; |
542
a71a05ec11bc
Towards annotate/blame support: general outline of the functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
631 } |
a71a05ec11bc
Towards annotate/blame support: general outline of the functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
632 } |
a71a05ec11bc
Towards annotate/blame support: general outline of the functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
633 |
555
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
634 private static class EqualBlockImpl extends BlockImpl implements EqualBlock { |
545
15b406c7cd9d
First round of annotate file is functional
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
544
diff
changeset
|
635 private final int start1, start2; |
542
a71a05ec11bc
Towards annotate/blame support: general outline of the functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
636 private final int length; |
554
a5fd757d1b5d
Access to content of annotated files through BlockData interface
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
553
diff
changeset
|
637 private final ContentBlock fullContent; |
a5fd757d1b5d
Access to content of annotated files through BlockData interface
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
553
diff
changeset
|
638 private FilterBlock myContent; |
542
a71a05ec11bc
Towards annotate/blame support: general outline of the functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
639 |
554
a5fd757d1b5d
Access to content of annotated files through BlockData interface
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
553
diff
changeset
|
640 EqualBlockImpl(int blockStartSeq1, int blockStartSeq2, int blockLength, ContentBlock targetContent) { |
545
15b406c7cd9d
First round of annotate file is functional
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
544
diff
changeset
|
641 start1 = blockStartSeq1; |
15b406c7cd9d
First round of annotate file is functional
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
544
diff
changeset
|
642 start2 = blockStartSeq2; |
15b406c7cd9d
First round of annotate file is functional
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
544
diff
changeset
|
643 length = blockLength; |
554
a5fd757d1b5d
Access to content of annotated files through BlockData interface
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
553
diff
changeset
|
644 fullContent = targetContent; |
542
a71a05ec11bc
Towards annotate/blame support: general outline of the functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
645 } |
a71a05ec11bc
Towards annotate/blame support: general outline of the functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
646 |
545
15b406c7cd9d
First round of annotate file is functional
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
544
diff
changeset
|
647 public int originStart() { |
15b406c7cd9d
First round of annotate file is functional
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
544
diff
changeset
|
648 return start1; |
15b406c7cd9d
First round of annotate file is functional
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
544
diff
changeset
|
649 } |
15b406c7cd9d
First round of annotate file is functional
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
544
diff
changeset
|
650 |
15b406c7cd9d
First round of annotate file is functional
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
544
diff
changeset
|
651 public int targetStart() { |
15b406c7cd9d
First round of annotate file is functional
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
544
diff
changeset
|
652 return start2; |
15b406c7cd9d
First round of annotate file is functional
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
544
diff
changeset
|
653 } |
15b406c7cd9d
First round of annotate file is functional
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
544
diff
changeset
|
654 |
15b406c7cd9d
First round of annotate file is functional
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
544
diff
changeset
|
655 public int length() { |
15b406c7cd9d
First round of annotate file is functional
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
544
diff
changeset
|
656 return length; |
542
a71a05ec11bc
Towards annotate/blame support: general outline of the functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
657 } |
a71a05ec11bc
Towards annotate/blame support: general outline of the functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
658 |
554
a5fd757d1b5d
Access to content of annotated files through BlockData interface
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
553
diff
changeset
|
659 public BlockData content() { |
a5fd757d1b5d
Access to content of annotated files through BlockData interface
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
553
diff
changeset
|
660 if (myContent == null) { |
a5fd757d1b5d
Access to content of annotated files through BlockData interface
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
553
diff
changeset
|
661 myContent = new FilterBlock(fullContent, start2, length); |
a5fd757d1b5d
Access to content of annotated files through BlockData interface
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
553
diff
changeset
|
662 } |
a5fd757d1b5d
Access to content of annotated files through BlockData interface
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
553
diff
changeset
|
663 return myContent; |
a5fd757d1b5d
Access to content of annotated files through BlockData interface
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
553
diff
changeset
|
664 } |
a5fd757d1b5d
Access to content of annotated files through BlockData interface
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
553
diff
changeset
|
665 |
545
15b406c7cd9d
First round of annotate file is functional
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
544
diff
changeset
|
666 @Override |
15b406c7cd9d
First round of annotate file is functional
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
544
diff
changeset
|
667 public String toString() { |
15b406c7cd9d
First round of annotate file is functional
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
544
diff
changeset
|
668 return String.format("@@ [%d..%d) == [%d..%d) @@", start1, start1+length, start2, start2+length); |
15b406c7cd9d
First round of annotate file is functional
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
544
diff
changeset
|
669 } |
542
a71a05ec11bc
Towards annotate/blame support: general outline of the functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
670 } |
a71a05ec11bc
Towards annotate/blame support: general outline of the functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
671 |
555
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
672 private static class ChangeBlockImpl extends BlockImpl implements ChangeBlock { |
554
a5fd757d1b5d
Access to content of annotated files through BlockData interface
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
553
diff
changeset
|
673 private final ContentBlock oldContent; |
a5fd757d1b5d
Access to content of annotated files through BlockData interface
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
553
diff
changeset
|
674 private final ContentBlock newContent; |
542
a71a05ec11bc
Towards annotate/blame support: general outline of the functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
675 private final int s1Start; |
a71a05ec11bc
Towards annotate/blame support: general outline of the functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
676 private final int s1Len; |
a71a05ec11bc
Towards annotate/blame support: general outline of the functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
677 private final int s2Start; |
a71a05ec11bc
Towards annotate/blame support: general outline of the functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
678 private final int s2Len; |
543
1e95f48d9886
Report line index for insertion and deletion, test against 'hg diff' output
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
542
diff
changeset
|
679 private final int s1InsertPoint; |
1e95f48d9886
Report line index for insertion and deletion, test against 'hg diff' output
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
542
diff
changeset
|
680 private final int s2DeletePoint; |
554
a5fd757d1b5d
Access to content of annotated files through BlockData interface
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
553
diff
changeset
|
681 private FilterBlock addedBlock, removedBlock; |
542
a71a05ec11bc
Towards annotate/blame support: general outline of the functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
682 |
554
a5fd757d1b5d
Access to content of annotated files through BlockData interface
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
553
diff
changeset
|
683 public ChangeBlockImpl(ContentBlock c1, ContentBlock c2, int s1Start, int s1Len, int s2Start, int s2Len, int s1InsertPoint, int s2DeletePoint) { |
a5fd757d1b5d
Access to content of annotated files through BlockData interface
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
553
diff
changeset
|
684 oldContent = c1; |
a5fd757d1b5d
Access to content of annotated files through BlockData interface
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
553
diff
changeset
|
685 newContent = c2; |
542
a71a05ec11bc
Towards annotate/blame support: general outline of the functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
686 this.s1Start = s1Start; |
a71a05ec11bc
Towards annotate/blame support: general outline of the functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
687 this.s1Len = s1Len; |
a71a05ec11bc
Towards annotate/blame support: general outline of the functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
688 this.s2Start = s2Start; |
a71a05ec11bc
Towards annotate/blame support: general outline of the functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
689 this.s2Len = s2Len; |
543
1e95f48d9886
Report line index for insertion and deletion, test against 'hg diff' output
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
542
diff
changeset
|
690 this.s1InsertPoint = s1InsertPoint; |
1e95f48d9886
Report line index for insertion and deletion, test against 'hg diff' output
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
542
diff
changeset
|
691 this.s2DeletePoint = s2DeletePoint; |
1e95f48d9886
Report line index for insertion and deletion, test against 'hg diff' output
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
542
diff
changeset
|
692 } |
1e95f48d9886
Report line index for insertion and deletion, test against 'hg diff' output
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
542
diff
changeset
|
693 |
1e95f48d9886
Report line index for insertion and deletion, test against 'hg diff' output
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
542
diff
changeset
|
694 public int insertedAt() { |
1e95f48d9886
Report line index for insertion and deletion, test against 'hg diff' output
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
542
diff
changeset
|
695 return s1InsertPoint; |
542
a71a05ec11bc
Towards annotate/blame support: general outline of the functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
696 } |
a71a05ec11bc
Towards annotate/blame support: general outline of the functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
697 |
a71a05ec11bc
Towards annotate/blame support: general outline of the functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
698 public int firstAddedLine() { |
a71a05ec11bc
Towards annotate/blame support: general outline of the functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
699 return s2Start; |
a71a05ec11bc
Towards annotate/blame support: general outline of the functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
700 } |
a71a05ec11bc
Towards annotate/blame support: general outline of the functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
701 |
a71a05ec11bc
Towards annotate/blame support: general outline of the functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
702 public int totalAddedLines() { |
a71a05ec11bc
Towards annotate/blame support: general outline of the functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
703 return s2Len; |
a71a05ec11bc
Towards annotate/blame support: general outline of the functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
704 } |
a71a05ec11bc
Towards annotate/blame support: general outline of the functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
705 |
554
a5fd757d1b5d
Access to content of annotated files through BlockData interface
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
553
diff
changeset
|
706 public BlockData addedLines() { |
a5fd757d1b5d
Access to content of annotated files through BlockData interface
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
553
diff
changeset
|
707 if (addedBlock == null) { |
a5fd757d1b5d
Access to content of annotated files through BlockData interface
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
553
diff
changeset
|
708 addedBlock = new FilterBlock(newContent, firstAddedLine(), totalAddedLines()); |
a5fd757d1b5d
Access to content of annotated files through BlockData interface
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
553
diff
changeset
|
709 } |
a5fd757d1b5d
Access to content of annotated files through BlockData interface
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
553
diff
changeset
|
710 return addedBlock; |
542
a71a05ec11bc
Towards annotate/blame support: general outline of the functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
711 } |
543
1e95f48d9886
Report line index for insertion and deletion, test against 'hg diff' output
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
542
diff
changeset
|
712 |
1e95f48d9886
Report line index for insertion and deletion, test against 'hg diff' output
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
542
diff
changeset
|
713 public int removedAt() { |
1e95f48d9886
Report line index for insertion and deletion, test against 'hg diff' output
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
542
diff
changeset
|
714 return s2DeletePoint; |
1e95f48d9886
Report line index for insertion and deletion, test against 'hg diff' output
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
542
diff
changeset
|
715 } |
542
a71a05ec11bc
Towards annotate/blame support: general outline of the functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
716 |
a71a05ec11bc
Towards annotate/blame support: general outline of the functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
717 public int firstRemovedLine() { |
a71a05ec11bc
Towards annotate/blame support: general outline of the functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
718 return s1Start; |
a71a05ec11bc
Towards annotate/blame support: general outline of the functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
719 } |
a71a05ec11bc
Towards annotate/blame support: general outline of the functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
720 |
a71a05ec11bc
Towards annotate/blame support: general outline of the functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
721 public int totalRemovedLines() { |
a71a05ec11bc
Towards annotate/blame support: general outline of the functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
722 return s1Len; |
a71a05ec11bc
Towards annotate/blame support: general outline of the functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
723 } |
a71a05ec11bc
Towards annotate/blame support: general outline of the functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
724 |
554
a5fd757d1b5d
Access to content of annotated files through BlockData interface
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
553
diff
changeset
|
725 public BlockData removedLines() { |
a5fd757d1b5d
Access to content of annotated files through BlockData interface
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
553
diff
changeset
|
726 if (removedBlock == null) { |
a5fd757d1b5d
Access to content of annotated files through BlockData interface
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
553
diff
changeset
|
727 removedBlock = new FilterBlock(oldContent, firstRemovedLine(), totalRemovedLines()); |
542
a71a05ec11bc
Towards annotate/blame support: general outline of the functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
728 } |
554
a5fd757d1b5d
Access to content of annotated files through BlockData interface
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
553
diff
changeset
|
729 return removedBlock; |
542
a71a05ec11bc
Towards annotate/blame support: general outline of the functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
730 } |
545
15b406c7cd9d
First round of annotate file is functional
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
544
diff
changeset
|
731 |
15b406c7cd9d
First round of annotate file is functional
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
544
diff
changeset
|
732 @Override |
15b406c7cd9d
First round of annotate file is functional
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
544
diff
changeset
|
733 public String toString() { |
15b406c7cd9d
First round of annotate file is functional
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
544
diff
changeset
|
734 if (s2DeletePoint == -1) { |
15b406c7cd9d
First round of annotate file is functional
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
544
diff
changeset
|
735 return String.format("@@ -%d,0 +%d,%d @@", insertedAt(), firstAddedLine(), totalAddedLines()); |
15b406c7cd9d
First round of annotate file is functional
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
544
diff
changeset
|
736 } else if (s1InsertPoint == -1) { |
15b406c7cd9d
First round of annotate file is functional
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
544
diff
changeset
|
737 // delete only |
15b406c7cd9d
First round of annotate file is functional
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
544
diff
changeset
|
738 return String.format("@@ -%d,%d +%d,0 @@", firstRemovedLine(), totalRemovedLines(), removedAt()); |
15b406c7cd9d
First round of annotate file is functional
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
544
diff
changeset
|
739 } |
15b406c7cd9d
First round of annotate file is functional
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
544
diff
changeset
|
740 return String.format("@@ -%d,%d +%d,%d @@", firstRemovedLine(), totalRemovedLines(), firstAddedLine(), totalAddedLines()); |
15b406c7cd9d
First round of annotate file is functional
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
544
diff
changeset
|
741 } |
542
a71a05ec11bc
Towards annotate/blame support: general outline of the functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
742 } |
554
a5fd757d1b5d
Access to content of annotated files through BlockData interface
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
553
diff
changeset
|
743 |
a5fd757d1b5d
Access to content of annotated files through BlockData interface
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
553
diff
changeset
|
744 private static class SingleLine implements BlockData { |
a5fd757d1b5d
Access to content of annotated files through BlockData interface
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
553
diff
changeset
|
745 private final ByteChain line; |
a5fd757d1b5d
Access to content of annotated files through BlockData interface
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
553
diff
changeset
|
746 |
a5fd757d1b5d
Access to content of annotated files through BlockData interface
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
553
diff
changeset
|
747 public SingleLine(ByteChain lineContent) { |
a5fd757d1b5d
Access to content of annotated files through BlockData interface
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
553
diff
changeset
|
748 line = lineContent; |
a5fd757d1b5d
Access to content of annotated files through BlockData interface
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
553
diff
changeset
|
749 } |
a5fd757d1b5d
Access to content of annotated files through BlockData interface
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
553
diff
changeset
|
750 |
a5fd757d1b5d
Access to content of annotated files through BlockData interface
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
553
diff
changeset
|
751 public BlockData elementAt(int index) { |
a5fd757d1b5d
Access to content of annotated files through BlockData interface
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
553
diff
changeset
|
752 assert false; |
a5fd757d1b5d
Access to content of annotated files through BlockData interface
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
553
diff
changeset
|
753 return null; |
a5fd757d1b5d
Access to content of annotated files through BlockData interface
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
553
diff
changeset
|
754 } |
a5fd757d1b5d
Access to content of annotated files through BlockData interface
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
553
diff
changeset
|
755 |
a5fd757d1b5d
Access to content of annotated files through BlockData interface
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
553
diff
changeset
|
756 public int elementCount() { |
a5fd757d1b5d
Access to content of annotated files through BlockData interface
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
553
diff
changeset
|
757 return 0; |
a5fd757d1b5d
Access to content of annotated files through BlockData interface
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
553
diff
changeset
|
758 } |
a5fd757d1b5d
Access to content of annotated files through BlockData interface
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
553
diff
changeset
|
759 |
a5fd757d1b5d
Access to content of annotated files through BlockData interface
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
553
diff
changeset
|
760 public byte[] asArray() { |
a5fd757d1b5d
Access to content of annotated files through BlockData interface
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
553
diff
changeset
|
761 return line.data(); |
a5fd757d1b5d
Access to content of annotated files through BlockData interface
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
553
diff
changeset
|
762 } |
a5fd757d1b5d
Access to content of annotated files through BlockData interface
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
553
diff
changeset
|
763 } |
a5fd757d1b5d
Access to content of annotated files through BlockData interface
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
553
diff
changeset
|
764 |
a5fd757d1b5d
Access to content of annotated files through BlockData interface
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
553
diff
changeset
|
765 private static class ContentBlock implements BlockData { |
a5fd757d1b5d
Access to content of annotated files through BlockData interface
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
553
diff
changeset
|
766 private final LineSequence seq; |
a5fd757d1b5d
Access to content of annotated files through BlockData interface
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
553
diff
changeset
|
767 |
a5fd757d1b5d
Access to content of annotated files through BlockData interface
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
553
diff
changeset
|
768 public ContentBlock(LineSequence sequence) { |
a5fd757d1b5d
Access to content of annotated files through BlockData interface
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
553
diff
changeset
|
769 seq = sequence; |
a5fd757d1b5d
Access to content of annotated files through BlockData interface
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
553
diff
changeset
|
770 } |
a5fd757d1b5d
Access to content of annotated files through BlockData interface
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
553
diff
changeset
|
771 |
a5fd757d1b5d
Access to content of annotated files through BlockData interface
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
553
diff
changeset
|
772 public BlockData elementAt(int index) { |
a5fd757d1b5d
Access to content of annotated files through BlockData interface
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
553
diff
changeset
|
773 return new SingleLine(seq.chunk(index)); |
a5fd757d1b5d
Access to content of annotated files through BlockData interface
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
553
diff
changeset
|
774 } |
a5fd757d1b5d
Access to content of annotated files through BlockData interface
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
553
diff
changeset
|
775 |
a5fd757d1b5d
Access to content of annotated files through BlockData interface
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
553
diff
changeset
|
776 public int elementCount() { |
a5fd757d1b5d
Access to content of annotated files through BlockData interface
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
553
diff
changeset
|
777 return seq.chunkCount() - 1; |
a5fd757d1b5d
Access to content of annotated files through BlockData interface
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
553
diff
changeset
|
778 } |
a5fd757d1b5d
Access to content of annotated files through BlockData interface
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
553
diff
changeset
|
779 |
a5fd757d1b5d
Access to content of annotated files through BlockData interface
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
553
diff
changeset
|
780 public byte[] asArray() { |
a5fd757d1b5d
Access to content of annotated files through BlockData interface
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
553
diff
changeset
|
781 return seq.data(0, seq.chunkCount() - 1); |
a5fd757d1b5d
Access to content of annotated files through BlockData interface
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
553
diff
changeset
|
782 } |
a5fd757d1b5d
Access to content of annotated files through BlockData interface
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
553
diff
changeset
|
783 } |
a5fd757d1b5d
Access to content of annotated files through BlockData interface
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
553
diff
changeset
|
784 |
a5fd757d1b5d
Access to content of annotated files through BlockData interface
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
553
diff
changeset
|
785 private static class FilterBlock implements BlockData { |
a5fd757d1b5d
Access to content of annotated files through BlockData interface
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
553
diff
changeset
|
786 private final ContentBlock contentBlock; |
a5fd757d1b5d
Access to content of annotated files through BlockData interface
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
553
diff
changeset
|
787 private final int from; |
a5fd757d1b5d
Access to content of annotated files through BlockData interface
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
553
diff
changeset
|
788 private final int length; |
a5fd757d1b5d
Access to content of annotated files through BlockData interface
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
553
diff
changeset
|
789 |
a5fd757d1b5d
Access to content of annotated files through BlockData interface
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
553
diff
changeset
|
790 public FilterBlock(ContentBlock bd, int startFrom, int len) { |
a5fd757d1b5d
Access to content of annotated files through BlockData interface
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
553
diff
changeset
|
791 assert bd != null; |
a5fd757d1b5d
Access to content of annotated files through BlockData interface
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
553
diff
changeset
|
792 assert startFrom + len < bd.seq.chunkCount(); // there's one extra chunk in the end, so strict less is ok |
a5fd757d1b5d
Access to content of annotated files through BlockData interface
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
553
diff
changeset
|
793 contentBlock = bd; |
a5fd757d1b5d
Access to content of annotated files through BlockData interface
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
553
diff
changeset
|
794 from = startFrom; |
a5fd757d1b5d
Access to content of annotated files through BlockData interface
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
553
diff
changeset
|
795 length = len; |
a5fd757d1b5d
Access to content of annotated files through BlockData interface
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
553
diff
changeset
|
796 } |
a5fd757d1b5d
Access to content of annotated files through BlockData interface
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
553
diff
changeset
|
797 |
a5fd757d1b5d
Access to content of annotated files through BlockData interface
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
553
diff
changeset
|
798 public BlockData elementAt(int index) { |
a5fd757d1b5d
Access to content of annotated files through BlockData interface
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
553
diff
changeset
|
799 if (index < 0 || index >= length) { |
a5fd757d1b5d
Access to content of annotated files through BlockData interface
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
553
diff
changeset
|
800 throw new IllegalArgumentException(String.format("Expected value from [0..%d), got %d", length, index)); |
a5fd757d1b5d
Access to content of annotated files through BlockData interface
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
553
diff
changeset
|
801 } |
a5fd757d1b5d
Access to content of annotated files through BlockData interface
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
553
diff
changeset
|
802 return contentBlock.elementAt(from + index); |
a5fd757d1b5d
Access to content of annotated files through BlockData interface
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
553
diff
changeset
|
803 } |
a5fd757d1b5d
Access to content of annotated files through BlockData interface
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
553
diff
changeset
|
804 |
a5fd757d1b5d
Access to content of annotated files through BlockData interface
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
553
diff
changeset
|
805 public int elementCount() { |
a5fd757d1b5d
Access to content of annotated files through BlockData interface
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
553
diff
changeset
|
806 return length; |
a5fd757d1b5d
Access to content of annotated files through BlockData interface
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
553
diff
changeset
|
807 } |
a5fd757d1b5d
Access to content of annotated files through BlockData interface
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
553
diff
changeset
|
808 |
a5fd757d1b5d
Access to content of annotated files through BlockData interface
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
553
diff
changeset
|
809 public byte[] asArray() { |
a5fd757d1b5d
Access to content of annotated files through BlockData interface
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
553
diff
changeset
|
810 return contentBlock.seq.data(from, from + length); |
a5fd757d1b5d
Access to content of annotated files through BlockData interface
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
553
diff
changeset
|
811 } |
a5fd757d1b5d
Access to content of annotated files through BlockData interface
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
553
diff
changeset
|
812 } |
a5fd757d1b5d
Access to content of annotated files through BlockData interface
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
553
diff
changeset
|
813 |
549
83afa680555d
Annotate merge revision (combined diff against two parents without looking further)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
548
diff
changeset
|
814 |
558
154718ae23ed
Annotate: refactor/reuse range handling code
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
557
diff
changeset
|
815 private static class EqualBlocksCollector implements DiffHelper.MatchInspector<LineSequence> { |
154718ae23ed
Annotate: refactor/reuse range handling code
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
557
diff
changeset
|
816 private final RangeSeq matches = new RangeSeq(); |
549
83afa680555d
Annotate merge revision (combined diff against two parents without looking further)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
548
diff
changeset
|
817 |
83afa680555d
Annotate merge revision (combined diff against two parents without looking further)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
548
diff
changeset
|
818 public void begin(LineSequence s1, LineSequence s2) { |
83afa680555d
Annotate merge revision (combined diff against two parents without looking further)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
548
diff
changeset
|
819 } |
83afa680555d
Annotate merge revision (combined diff against two parents without looking further)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
548
diff
changeset
|
820 |
83afa680555d
Annotate merge revision (combined diff against two parents without looking further)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
548
diff
changeset
|
821 public void match(int startSeq1, int startSeq2, int matchLength) { |
558
154718ae23ed
Annotate: refactor/reuse range handling code
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
557
diff
changeset
|
822 matches.add(startSeq1, startSeq2, matchLength); |
549
83afa680555d
Annotate merge revision (combined diff against two parents without looking further)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
548
diff
changeset
|
823 } |
83afa680555d
Annotate merge revision (combined diff against two parents without looking further)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
548
diff
changeset
|
824 |
83afa680555d
Annotate merge revision (combined diff against two parents without looking further)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
548
diff
changeset
|
825 public void end() { |
83afa680555d
Annotate merge revision (combined diff against two parents without looking further)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
548
diff
changeset
|
826 } |
558
154718ae23ed
Annotate: refactor/reuse range handling code
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
557
diff
changeset
|
827 |
154718ae23ed
Annotate: refactor/reuse range handling code
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
557
diff
changeset
|
828 public int reverseMapLine(int ln) { |
154718ae23ed
Annotate: refactor/reuse range handling code
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
557
diff
changeset
|
829 return matches.reverseMapLine(ln); |
549
83afa680555d
Annotate merge revision (combined diff against two parents without looking further)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
548
diff
changeset
|
830 } |
558
154718ae23ed
Annotate: refactor/reuse range handling code
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
557
diff
changeset
|
831 |
549
83afa680555d
Annotate merge revision (combined diff against two parents without looking further)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
548
diff
changeset
|
832 public void intersectWithTarget(int start, int length, IntVector result) { |
83afa680555d
Annotate merge revision (combined diff against two parents without looking further)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
548
diff
changeset
|
833 int s = start; |
83afa680555d
Annotate merge revision (combined diff against two parents without looking further)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
548
diff
changeset
|
834 for (int l = start, x = start + length; l < x; l++) { |
558
154718ae23ed
Annotate: refactor/reuse range handling code
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
557
diff
changeset
|
835 if (!matches.includesTargetLine(l)) { |
549
83afa680555d
Annotate merge revision (combined diff against two parents without looking further)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
548
diff
changeset
|
836 if (l - s > 0) { |
83afa680555d
Annotate merge revision (combined diff against two parents without looking further)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
548
diff
changeset
|
837 result.add(s); |
83afa680555d
Annotate merge revision (combined diff against two parents without looking further)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
548
diff
changeset
|
838 result.add(l - s); |
83afa680555d
Annotate merge revision (combined diff against two parents without looking further)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
548
diff
changeset
|
839 } |
83afa680555d
Annotate merge revision (combined diff against two parents without looking further)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
548
diff
changeset
|
840 s = l+1; |
83afa680555d
Annotate merge revision (combined diff against two parents without looking further)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
548
diff
changeset
|
841 } |
83afa680555d
Annotate merge revision (combined diff against two parents without looking further)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
548
diff
changeset
|
842 } |
83afa680555d
Annotate merge revision (combined diff against two parents without looking further)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
548
diff
changeset
|
843 if (s < start+length) { |
83afa680555d
Annotate merge revision (combined diff against two parents without looking further)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
548
diff
changeset
|
844 result.add(s); |
83afa680555d
Annotate merge revision (combined diff against two parents without looking further)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
548
diff
changeset
|
845 result.add((start + length) - s); |
83afa680555d
Annotate merge revision (combined diff against two parents without looking further)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
548
diff
changeset
|
846 } |
83afa680555d
Annotate merge revision (combined diff against two parents without looking further)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
548
diff
changeset
|
847 } |
83afa680555d
Annotate merge revision (combined diff against two parents without looking further)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
548
diff
changeset
|
848 |
83afa680555d
Annotate merge revision (combined diff against two parents without looking further)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
548
diff
changeset
|
849 /* |
83afa680555d
Annotate merge revision (combined diff against two parents without looking further)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
548
diff
changeset
|
850 * intersects [start..start+length) with ranges of target lines, and based on the intersection |
83afa680555d
Annotate merge revision (combined diff against two parents without looking further)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
548
diff
changeset
|
851 * breaks initial range into smaller ranges and records them into result, with marker to indicate |
83afa680555d
Annotate merge revision (combined diff against two parents without looking further)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
548
diff
changeset
|
852 * whether the range is from initial range (markerSource) or is a result of the intersection with target |
83afa680555d
Annotate merge revision (combined diff against two parents without looking further)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
548
diff
changeset
|
853 * (markerTarget) |
83afa680555d
Annotate merge revision (combined diff against two parents without looking further)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
548
diff
changeset
|
854 */ |
83afa680555d
Annotate merge revision (combined diff against two parents without looking further)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
548
diff
changeset
|
855 public void combineAndMarkRangesWithTarget(int start, int length, int markerSource, int markerTarget, IntVector result) { |
83afa680555d
Annotate merge revision (combined diff against two parents without looking further)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
548
diff
changeset
|
856 int sourceStart = start, targetStart = start, sourceEnd = start + length; |
83afa680555d
Annotate merge revision (combined diff against two parents without looking further)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
548
diff
changeset
|
857 for (int l = sourceStart; l < sourceEnd; l++) { |
558
154718ae23ed
Annotate: refactor/reuse range handling code
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
557
diff
changeset
|
858 if (matches.includesTargetLine(l)) { |
549
83afa680555d
Annotate merge revision (combined diff against two parents without looking further)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
548
diff
changeset
|
859 // l is from target |
83afa680555d
Annotate merge revision (combined diff against two parents without looking further)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
548
diff
changeset
|
860 if (sourceStart < l) { |
83afa680555d
Annotate merge revision (combined diff against two parents without looking further)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
548
diff
changeset
|
861 // few lines from source range were not in the target, report them |
83afa680555d
Annotate merge revision (combined diff against two parents without looking further)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
548
diff
changeset
|
862 result.add(markerSource); |
83afa680555d
Annotate merge revision (combined diff against two parents without looking further)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
548
diff
changeset
|
863 result.add(sourceStart); |
83afa680555d
Annotate merge revision (combined diff against two parents without looking further)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
548
diff
changeset
|
864 result.add(l - sourceStart); |
83afa680555d
Annotate merge revision (combined diff against two parents without looking further)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
548
diff
changeset
|
865 } |
83afa680555d
Annotate merge revision (combined diff against two parents without looking further)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
548
diff
changeset
|
866 // indicate the earliest line from source range to use |
83afa680555d
Annotate merge revision (combined diff against two parents without looking further)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
548
diff
changeset
|
867 sourceStart = l + 1; |
83afa680555d
Annotate merge revision (combined diff against two parents without looking further)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
548
diff
changeset
|
868 } else { |
83afa680555d
Annotate merge revision (combined diff against two parents without looking further)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
548
diff
changeset
|
869 // l is not in target |
83afa680555d
Annotate merge revision (combined diff against two parents without looking further)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
548
diff
changeset
|
870 if (targetStart < l) { |
83afa680555d
Annotate merge revision (combined diff against two parents without looking further)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
548
diff
changeset
|
871 // report lines from target range |
83afa680555d
Annotate merge revision (combined diff against two parents without looking further)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
548
diff
changeset
|
872 result.add(markerTarget); |
83afa680555d
Annotate merge revision (combined diff against two parents without looking further)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
548
diff
changeset
|
873 result.add(targetStart); |
83afa680555d
Annotate merge revision (combined diff against two parents without looking further)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
548
diff
changeset
|
874 result.add(l - targetStart); |
83afa680555d
Annotate merge revision (combined diff against two parents without looking further)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
548
diff
changeset
|
875 } |
83afa680555d
Annotate merge revision (combined diff against two parents without looking further)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
548
diff
changeset
|
876 // next line *may* be from target |
83afa680555d
Annotate merge revision (combined diff against two parents without looking further)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
548
diff
changeset
|
877 targetStart = l + 1; |
83afa680555d
Annotate merge revision (combined diff against two parents without looking further)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
548
diff
changeset
|
878 } |
83afa680555d
Annotate merge revision (combined diff against two parents without looking further)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
548
diff
changeset
|
879 } |
83afa680555d
Annotate merge revision (combined diff against two parents without looking further)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
548
diff
changeset
|
880 // if source range end with line from target, sourceStart would be == sourceEnd, and we need to add range with markerTarget |
83afa680555d
Annotate merge revision (combined diff against two parents without looking further)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
548
diff
changeset
|
881 // if source range doesn't end with target line, targetStart == sourceEnd, while sourceStart < sourceEnd |
83afa680555d
Annotate merge revision (combined diff against two parents without looking further)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
548
diff
changeset
|
882 if (sourceStart < sourceEnd) { |
83afa680555d
Annotate merge revision (combined diff against two parents without looking further)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
548
diff
changeset
|
883 assert targetStart == sourceEnd; |
83afa680555d
Annotate merge revision (combined diff against two parents without looking further)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
548
diff
changeset
|
884 // something left from the source range |
83afa680555d
Annotate merge revision (combined diff against two parents without looking further)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
548
diff
changeset
|
885 result.add(markerSource); |
83afa680555d
Annotate merge revision (combined diff against two parents without looking further)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
548
diff
changeset
|
886 result.add(sourceStart); |
83afa680555d
Annotate merge revision (combined diff against two parents without looking further)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
548
diff
changeset
|
887 result.add(sourceEnd - sourceStart); |
83afa680555d
Annotate merge revision (combined diff against two parents without looking further)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
548
diff
changeset
|
888 } else if (targetStart < sourceEnd) { |
83afa680555d
Annotate merge revision (combined diff against two parents without looking further)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
548
diff
changeset
|
889 assert sourceStart == sourceEnd; |
83afa680555d
Annotate merge revision (combined diff against two parents without looking further)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
548
diff
changeset
|
890 result.add(markerTarget); |
83afa680555d
Annotate merge revision (combined diff against two parents without looking further)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
548
diff
changeset
|
891 result.add(targetStart); |
83afa680555d
Annotate merge revision (combined diff against two parents without looking further)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
548
diff
changeset
|
892 result.add(sourceEnd - targetStart); |
83afa680555d
Annotate merge revision (combined diff against two parents without looking further)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
548
diff
changeset
|
893 } |
83afa680555d
Annotate merge revision (combined diff against two parents without looking further)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
548
diff
changeset
|
894 } |
83afa680555d
Annotate merge revision (combined diff against two parents without looking further)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
548
diff
changeset
|
895 } |
83afa680555d
Annotate merge revision (combined diff against two parents without looking further)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
548
diff
changeset
|
896 |
555
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
897 private static class AnnotateRev implements RevisionDescriptor { |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
898 public ContentBlock origin, target; |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
899 public int originCset, targetCset, mergeCset, fileRevIndex; |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
900 |
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
|
901 public void set(int fileRev) { |
e55f17a7a195
AnnotateFacility renamed to HgBlameFacility and exposed, API shapes out and got some javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
555
diff
changeset
|
902 fileRevIndex = fileRev; |
e55f17a7a195
AnnotateFacility renamed to HgBlameFacility and exposed, API shapes out and got some javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
555
diff
changeset
|
903 } |
555
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
904 public void set(ContentBlock o, ContentBlock t) { |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
905 origin = o; |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
906 target = t; |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
907 } |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
908 public void set(int o, int t, int m) { |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
909 originCset = o; |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
910 targetCset = t; |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
911 mergeCset = m; |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
912 } |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
913 |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
914 public BlockData origin() { |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
915 return origin; |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
916 } |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
917 |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
918 public BlockData target() { |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
919 return target; |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
920 } |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
921 |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
922 public int originChangesetIndex() { |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
923 return originCset; |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
924 } |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
925 |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
926 public int targetChangesetIndex() { |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
927 return targetCset; |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
928 } |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
929 |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
930 public boolean isMerge() { |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
931 return mergeCset != NO_REVISION; |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
932 } |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
933 |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
934 public int mergeChangesetIndex() { |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
935 return mergeCset; |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
936 } |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
937 |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
938 public int fileRevisionIndex() { |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
939 return fileRevIndex; |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
940 } |
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
|
941 @Override |
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
|
942 public String toString() { |
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
|
943 if (isMerge()) { |
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
|
944 return String.format("[%d,%d->%d]", originCset, mergeCset, targetCset); |
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
|
945 } |
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
|
946 return String.format("[%d->%d]", originCset, targetCset); |
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
|
947 } |
555
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
948 } |
e623aa2ca526
Annotate: RevisionDescriptor provides extra knowledge about inspected/annotated revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
554
diff
changeset
|
949 |
549
83afa680555d
Annotate merge revision (combined diff against two parents without looking further)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
548
diff
changeset
|
950 public static void main(String[] args) { |
83afa680555d
Annotate merge revision (combined diff against two parents without looking further)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
548
diff
changeset
|
951 EqualBlocksCollector bc = new EqualBlocksCollector(); |
83afa680555d
Annotate merge revision (combined diff against two parents without looking further)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
548
diff
changeset
|
952 bc.match(-1, 5, 3); |
83afa680555d
Annotate merge revision (combined diff against two parents without looking further)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
548
diff
changeset
|
953 bc.match(-1, 10, 2); |
83afa680555d
Annotate merge revision (combined diff against two parents without looking further)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
548
diff
changeset
|
954 bc.match(-1, 15, 3); |
83afa680555d
Annotate merge revision (combined diff against two parents without looking further)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
548
diff
changeset
|
955 bc.match(-1, 20, 3); |
83afa680555d
Annotate merge revision (combined diff against two parents without looking further)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
548
diff
changeset
|
956 IntVector r = new IntVector(); |
83afa680555d
Annotate merge revision (combined diff against two parents without looking further)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
548
diff
changeset
|
957 bc.intersectWithTarget(7, 10, r); |
83afa680555d
Annotate merge revision (combined diff against two parents without looking further)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
548
diff
changeset
|
958 for (int i = 0; i < r.size(); i+=2) { |
83afa680555d
Annotate merge revision (combined diff against two parents without looking further)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
548
diff
changeset
|
959 System.out.printf("[%d..%d) ", r.get(i), r.get(i) + r.get(i+1)); |
83afa680555d
Annotate merge revision (combined diff against two parents without looking further)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
548
diff
changeset
|
960 } |
83afa680555d
Annotate merge revision (combined diff against two parents without looking further)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
548
diff
changeset
|
961 System.out.println(); |
83afa680555d
Annotate merge revision (combined diff against two parents without looking further)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
548
diff
changeset
|
962 r.clear(); |
83afa680555d
Annotate merge revision (combined diff against two parents without looking further)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
548
diff
changeset
|
963 bc.combineAndMarkRangesWithTarget(0, 16, 508, 514, r); |
83afa680555d
Annotate merge revision (combined diff against two parents without looking further)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
548
diff
changeset
|
964 for (int i = 0; i < r.size(); i+=3) { |
83afa680555d
Annotate merge revision (combined diff against two parents without looking further)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
548
diff
changeset
|
965 System.out.printf("%d:[%d..%d) ", r.get(i), r.get(i+1), r.get(i+1) + r.get(i+2)); |
83afa680555d
Annotate merge revision (combined diff against two parents without looking further)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
548
diff
changeset
|
966 } |
83afa680555d
Annotate merge revision (combined diff against two parents without looking further)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
548
diff
changeset
|
967 } |
542
a71a05ec11bc
Towards annotate/blame support: general outline of the functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
968 } |