Mercurial > jhg
annotate src/org/tmatesoft/hg/internal/BlameHelper.java @ 675:a20121a2bba6
Respect default range (0..tip)
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Thu, 18 Jul 2013 18:02:36 +0200 |
parents | cce0387c6041 |
children | 8625cba0a5a8 |
rev | line source |
---|---|
569
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
1 /* |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
2 * Copyright (c) 2013 TMate Software Ltd |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
3 * |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
4 * This program is free software; you can redistribute it and/or modify |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
5 * it under the terms of the GNU General Public License as published by |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
6 * the Free Software Foundation; version 2 of the License. |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
7 * |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
8 * This program is distributed in the hope that it will be useful, |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
11 * GNU General Public License for more details. |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
12 * |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
13 * For information on how to redistribute this software under |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
14 * the terms of a license other than GNU General Public License |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
15 * contact TMate Software at support@hg4j.com |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
16 */ |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
17 package org.tmatesoft.hg.internal; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
18 |
625
b4948b159ab1
Refactor internals of blame support, tests
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
603
diff
changeset
|
19 import static org.tmatesoft.hg.core.HgIterateDirection.OldToNew; |
569
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
20 import static org.tmatesoft.hg.repo.HgRepository.NO_REVISION; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
21 |
674
cce0387c6041
Introduced dedicated IntSliceSeq/IntTuple in place of IntArray with subsequences
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
629
diff
changeset
|
22 import java.util.Iterator; |
569
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
23 import java.util.LinkedList; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
24 import java.util.ListIterator; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
25 |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
26 import org.tmatesoft.hg.core.HgCallbackTargetException; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
27 import org.tmatesoft.hg.internal.DiffHelper.LineSequence; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
28 import org.tmatesoft.hg.internal.DiffHelper.LineSequence.ByteChain; |
629
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
628
diff
changeset
|
29 import org.tmatesoft.hg.core.HgBlameInspector; |
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
628
diff
changeset
|
30 import org.tmatesoft.hg.core.HgBlameInspector.*; |
569
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
31 import org.tmatesoft.hg.repo.HgDataFile; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
32 import org.tmatesoft.hg.repo.HgInvalidStateException; |
628
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
625
diff
changeset
|
33 import org.tmatesoft.hg.repo.HgRuntimeException; |
569
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
34 import org.tmatesoft.hg.util.Adaptable; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
35 import org.tmatesoft.hg.util.CancelledException; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
36 import org.tmatesoft.hg.util.Pair; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
37 |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
38 /** |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
39 * Blame implementation |
603
707b5c7c6fa4
Refactor HgBlameFacility: relevant action methods moved to proper home (HgDataFile), as facility doesn't provide anything but packaging of relevant methods/interfaces
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
569
diff
changeset
|
40 * @see HgBlameInspector |
569
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
41 * @author Artem Tikhomirov |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
42 * @author TMate Software Ltd. |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
43 */ |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
44 public class BlameHelper { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
45 |
603
707b5c7c6fa4
Refactor HgBlameFacility: relevant action methods moved to proper home (HgDataFile), as facility doesn't provide anything but packaging of relevant methods/interfaces
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
569
diff
changeset
|
46 private final HgBlameInspector insp; |
569
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
47 private FileLinesCache linesCache; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
48 |
625
b4948b159ab1
Refactor internals of blame support, tests
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
603
diff
changeset
|
49 public BlameHelper(HgBlameInspector inspector) { |
569
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
50 insp = inspector; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
51 } |
625
b4948b159ab1
Refactor internals of blame support, tests
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
603
diff
changeset
|
52 |
b4948b159ab1
Refactor internals of blame support, tests
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
603
diff
changeset
|
53 /** |
b4948b159ab1
Refactor internals of blame support, tests
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
603
diff
changeset
|
54 * Build history of the file for the specified range (follow renames if necessary). This history |
b4948b159ab1
Refactor internals of blame support, tests
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
603
diff
changeset
|
55 * is used to access various file revision data during subsequent {@link #diff(int, int, int, int)} and |
b4948b159ab1
Refactor internals of blame support, tests
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
603
diff
changeset
|
56 * {@link #annotateChange(int, int, int[], int[])} calls. Callers can use returned history for own approaches |
b4948b159ab1
Refactor internals of blame support, tests
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
603
diff
changeset
|
57 * to iteration over file history. |
b4948b159ab1
Refactor internals of blame support, tests
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
603
diff
changeset
|
58 |
b4948b159ab1
Refactor internals of blame support, tests
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
603
diff
changeset
|
59 * <p>NOTE, clogRevIndexEnd has to list name of the supplied file in the corresponding manifest, |
b4948b159ab1
Refactor internals of blame support, tests
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
603
diff
changeset
|
60 * as it's not possible to trace rename history otherwise. |
b4948b159ab1
Refactor internals of blame support, tests
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
603
diff
changeset
|
61 */ |
628
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
625
diff
changeset
|
62 public FileHistory prepare(HgDataFile df, int clogRevIndexStart, int clogRevIndexEnd) throws HgRuntimeException { |
625
b4948b159ab1
Refactor internals of blame support, tests
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
603
diff
changeset
|
63 assert clogRevIndexStart <= clogRevIndexEnd; |
b4948b159ab1
Refactor internals of blame support, tests
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
603
diff
changeset
|
64 FileHistory fileHistory = new FileHistory(df, clogRevIndexStart, clogRevIndexEnd); |
b4948b159ab1
Refactor internals of blame support, tests
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
603
diff
changeset
|
65 fileHistory.build(); |
b4948b159ab1
Refactor internals of blame support, tests
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
603
diff
changeset
|
66 int cacheHint = 5; // cache comes useful when we follow merge branches and don't want to |
b4948b159ab1
Refactor internals of blame support, tests
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
603
diff
changeset
|
67 // parse base revision twice. There's no easy way to determine max(distance(all(base,merge))), |
b4948b159ab1
Refactor internals of blame support, tests
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
603
diff
changeset
|
68 // hence the heuristics to use the longest history chunk: |
b4948b159ab1
Refactor internals of blame support, tests
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
603
diff
changeset
|
69 for (FileRevisionHistoryChunk c : fileHistory.iterate(OldToNew)) { |
b4948b159ab1
Refactor internals of blame support, tests
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
603
diff
changeset
|
70 // iteration order is not important here |
b4948b159ab1
Refactor internals of blame support, tests
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
603
diff
changeset
|
71 if (c.revisionCount() > cacheHint) { |
b4948b159ab1
Refactor internals of blame support, tests
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
603
diff
changeset
|
72 cacheHint = c.revisionCount(); |
b4948b159ab1
Refactor internals of blame support, tests
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
603
diff
changeset
|
73 } |
b4948b159ab1
Refactor internals of blame support, tests
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
603
diff
changeset
|
74 } |
b4948b159ab1
Refactor internals of blame support, tests
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
603
diff
changeset
|
75 linesCache = new FileLinesCache(cacheHint); |
b4948b159ab1
Refactor internals of blame support, tests
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
603
diff
changeset
|
76 for (FileRevisionHistoryChunk fhc : fileHistory.iterate(OldToNew)) { |
b4948b159ab1
Refactor internals of blame support, tests
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
603
diff
changeset
|
77 // iteration order is not important here |
b4948b159ab1
Refactor internals of blame support, tests
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
603
diff
changeset
|
78 linesCache.useFileUpTo(fhc.getFile(), fhc.getEndChangeset()); |
b4948b159ab1
Refactor internals of blame support, tests
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
603
diff
changeset
|
79 } |
b4948b159ab1
Refactor internals of blame support, tests
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
603
diff
changeset
|
80 return fileHistory; |
569
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
81 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
82 |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
83 // NO_REVISION is not allowed as any argument |
628
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
625
diff
changeset
|
84 public void diff(int fileRevIndex1, int clogRevIndex1, int fileRevIndex2, int clogRevIndex2) throws HgCallbackTargetException, HgRuntimeException { |
569
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
85 HgDataFile targetFile = linesCache.getFile(clogRevIndex2); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
86 LineSequence c1 = linesCache.lines(clogRevIndex1, fileRevIndex1); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
87 LineSequence c2 = linesCache.lines(clogRevIndex2, fileRevIndex2); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
88 DiffHelper<LineSequence> pg = new DiffHelper<LineSequence>(); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
89 pg.init(c1, c2); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
90 BlameBlockInspector bbi = new BlameBlockInspector(targetFile, fileRevIndex2, insp, clogRevIndex1, clogRevIndex2); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
91 pg.findMatchingBlocks(bbi); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
92 bbi.checkErrors(); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
93 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
94 |
628
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
625
diff
changeset
|
95 public void annotateChange(int fileRevIndex, int csetRevIndex, int[] fileParentRevs, int[] fileParentClogRevs) throws HgCallbackTargetException, HgRuntimeException { |
569
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
96 HgDataFile targetFile = linesCache.getFile(csetRevIndex); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
97 final LineSequence fileRevLines = linesCache.lines(csetRevIndex, fileRevIndex); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
98 if (fileParentClogRevs[0] != NO_REVISION && fileParentClogRevs[1] != NO_REVISION) { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
99 int p1ClogIndex = fileParentClogRevs[0]; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
100 int p2ClogIndex = fileParentClogRevs[1]; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
101 LineSequence p1Lines = linesCache.lines(p1ClogIndex, fileParentRevs[0]); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
102 LineSequence p2Lines = linesCache.lines(p2ClogIndex, fileParentRevs[1]); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
103 DiffHelper<LineSequence> pg = new DiffHelper<LineSequence>(); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
104 pg.init(p2Lines, fileRevLines); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
105 EqualBlocksCollector p2MergeCommon = new EqualBlocksCollector(); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
106 pg.findMatchingBlocks(p2MergeCommon); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
107 // |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
108 pg.init(p1Lines); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
109 BlameBlockInspector bbi = new BlameBlockInspector(targetFile, fileRevIndex, insp, p1ClogIndex, csetRevIndex); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
110 bbi.setMergeParent2(p2MergeCommon, p2ClogIndex); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
111 pg.findMatchingBlocks(bbi); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
112 bbi.checkErrors(); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
113 } else if (fileParentClogRevs[0] == fileParentClogRevs[1]) { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
114 // may be equal iff both are unset |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
115 assert fileParentClogRevs[0] == NO_REVISION; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
116 // everything added |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
117 BlameBlockInspector bbi = new BlameBlockInspector(targetFile, fileRevIndex, insp, NO_REVISION, csetRevIndex); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
118 bbi.begin(LineSequence.newlines(new byte[0]), fileRevLines); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
119 bbi.match(0, fileRevLines.chunkCount()-1, 0); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
120 bbi.end(); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
121 bbi.checkErrors(); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
122 } else { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
123 int soleParentIndex = fileParentClogRevs[0] == NO_REVISION ? 1 : 0; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
124 assert fileParentClogRevs[soleParentIndex] != NO_REVISION; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
125 LineSequence parentLines = linesCache.lines(fileParentClogRevs[soleParentIndex], fileParentRevs[soleParentIndex]); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
126 |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
127 DiffHelper<LineSequence> pg = new DiffHelper<LineSequence>(); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
128 pg.init(parentLines, fileRevLines); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
129 BlameBlockInspector bbi = new BlameBlockInspector(targetFile, fileRevIndex, insp, fileParentClogRevs[soleParentIndex], csetRevIndex); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
130 pg.findMatchingBlocks(bbi); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
131 bbi.checkErrors(); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
132 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
133 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
134 |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
135 private static class FileLinesCache { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
136 private final LinkedList<Pair<Integer, LineSequence>> lruCache; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
137 private final int limit; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
138 private final LinkedList<Pair<Integer, HgDataFile>> files; // TODO in fact, need sparse array |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
139 |
625
b4948b159ab1
Refactor internals of blame support, tests
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
603
diff
changeset
|
140 /** |
b4948b159ab1
Refactor internals of blame support, tests
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
603
diff
changeset
|
141 * @param lruLimit how many parsed file revisions to keep |
b4948b159ab1
Refactor internals of blame support, tests
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
603
diff
changeset
|
142 */ |
569
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
143 public FileLinesCache(int lruLimit) { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
144 limit = lruLimit; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
145 lruCache = new LinkedList<Pair<Integer, LineSequence>>(); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
146 files = new LinkedList<Pair<Integer,HgDataFile>>(); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
147 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
148 |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
149 public void useFileUpTo(HgDataFile df, int clogRevIndex) { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
150 Pair<Integer, HgDataFile> newEntry = new Pair<Integer, HgDataFile>(clogRevIndex, df); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
151 for (ListIterator<Pair<Integer, HgDataFile>> it = files.listIterator(); it.hasNext();) { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
152 Pair<Integer, HgDataFile> e = it.next(); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
153 if (e.first() == clogRevIndex) { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
154 assert e.second().getPath().equals(df.getPath()); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
155 return; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
156 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
157 if (e.first() > clogRevIndex) { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
158 // insert new entry before current |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
159 it.previous(); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
160 it.add(newEntry); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
161 return; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
162 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
163 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
164 files.add(newEntry); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
165 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
166 |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
167 public HgDataFile getFile(int clogRevIndex) { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
168 for (Pair<Integer, HgDataFile> e : files) { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
169 if (e.first() >= clogRevIndex) { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
170 return e.second(); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
171 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
172 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
173 throw new HgInvalidStateException(String.format("Got %d file-changelog mappings, but no luck for revision %d.", files.size(), clogRevIndex)); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
174 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
175 |
628
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
625
diff
changeset
|
176 public LineSequence lines(int clogRevIndex, int fileRevIndex) throws HgRuntimeException { |
569
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
177 Pair<Integer, LineSequence> cached = checkCache(clogRevIndex); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
178 if (cached != null) { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
179 return cached.second(); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
180 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
181 HgDataFile df = getFile(clogRevIndex); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
182 try { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
183 ByteArrayChannel c; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
184 df.content(fileRevIndex, c = new ByteArrayChannel()); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
185 LineSequence rv = LineSequence.newlines(c.toArray()); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
186 lruCache.addFirst(new Pair<Integer, LineSequence>(clogRevIndex, rv)); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
187 if (lruCache.size() > limit) { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
188 lruCache.removeLast(); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
189 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
190 return rv; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
191 } catch (CancelledException ex) { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
192 // TODO likely it was bad idea to throw cancelled exception from content() |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
193 // deprecate and provide alternative? |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
194 HgInvalidStateException ise = new HgInvalidStateException("ByteArrayChannel never throws CancelledException"); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
195 ise.initCause(ex); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
196 throw ise; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
197 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
198 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
199 |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
200 private Pair<Integer,LineSequence> checkCache(int fileRevIndex) { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
201 Pair<Integer, LineSequence> rv = null; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
202 for (ListIterator<Pair<Integer, LineSequence>> it = lruCache.listIterator(); it.hasNext(); ) { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
203 Pair<Integer, LineSequence> p = it.next(); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
204 if (p.first() == fileRevIndex) { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
205 rv = p; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
206 it.remove(); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
207 break; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
208 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
209 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
210 if (rv != null) { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
211 lruCache.addFirst(rv); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
212 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
213 return rv; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
214 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
215 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
216 |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
217 private static class BlameBlockInspector extends DiffHelper.DeltaInspector<LineSequence> { |
603
707b5c7c6fa4
Refactor HgBlameFacility: relevant action methods moved to proper home (HgDataFile), as facility doesn't provide anything but packaging of relevant methods/interfaces
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
569
diff
changeset
|
218 private final HgBlameInspector insp; |
569
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
219 private final int csetOrigin; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
220 private final int csetTarget; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
221 private EqualBlocksCollector p2MergeCommon; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
222 private int csetMergeParent; |
674
cce0387c6041
Introduced dedicated IntSliceSeq/IntTuple in place of IntArray with subsequences
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
629
diff
changeset
|
223 private IntSliceSeq mergeRanges; |
569
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
224 private final AnnotateRev annotatedRevision; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
225 private HgCallbackTargetException error; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
226 |
603
707b5c7c6fa4
Refactor HgBlameFacility: relevant action methods moved to proper home (HgDataFile), as facility doesn't provide anything but packaging of relevant methods/interfaces
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
569
diff
changeset
|
227 public BlameBlockInspector(HgDataFile df, int fileRevIndex, HgBlameInspector inspector, int originCset, int targetCset) { |
569
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
228 assert inspector != null; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
229 insp = inspector; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
230 annotatedRevision = new AnnotateRev(); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
231 annotatedRevision.set(df, fileRevIndex); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
232 csetOrigin = originCset; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
233 csetTarget = targetCset; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
234 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
235 |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
236 public void setMergeParent2(EqualBlocksCollector p2Merge, int parentCset2) { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
237 p2MergeCommon = p2Merge; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
238 csetMergeParent = parentCset2; |
674
cce0387c6041
Introduced dedicated IntSliceSeq/IntTuple in place of IntArray with subsequences
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
629
diff
changeset
|
239 mergeRanges = new IntSliceSeq(3, 10, 10); |
569
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
240 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
241 |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
242 @Override |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
243 public void begin(LineSequence s1, LineSequence s2) { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
244 super.begin(s1, s2); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
245 if (shallStop()) { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
246 return; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
247 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
248 ContentBlock originContent = new ContentBlock(s1); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
249 ContentBlock targetContent = new ContentBlock(s2); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
250 annotatedRevision.set(originContent, targetContent); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
251 annotatedRevision.set(csetOrigin, csetTarget, p2MergeCommon != null ? csetMergeParent : NO_REVISION); |
629
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
628
diff
changeset
|
252 RevisionDescriptor.Recipient curious = Adaptable.Factory.getAdapter(insp, RevisionDescriptor.Recipient.class, null); |
569
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
253 if (curious != null) { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
254 try { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
255 curious.start(annotatedRevision); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
256 } catch (HgCallbackTargetException ex) { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
257 error = ex; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
258 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
259 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
260 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
261 |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
262 @Override |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
263 public void end() { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
264 super.end(); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
265 if (shallStop()) { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
266 return; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
267 } |
629
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
628
diff
changeset
|
268 RevisionDescriptor.Recipient curious = Adaptable.Factory.getAdapter(insp, RevisionDescriptor.Recipient.class, null); |
569
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
269 if (curious != null) { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
270 try { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
271 curious.done(annotatedRevision); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
272 } catch (HgCallbackTargetException ex) { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
273 error = ex; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
274 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
275 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
276 p2MergeCommon = null; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
277 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
278 |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
279 @Override |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
280 protected void changed(int s1From, int s1To, int s2From, int s2To) { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
281 if (shallStop()) { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
282 return; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
283 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
284 try { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
285 if (p2MergeCommon != null) { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
286 mergeRanges.clear(); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
287 p2MergeCommon.combineAndMarkRangesWithTarget(s2From, s2To - s2From, csetOrigin, csetMergeParent, mergeRanges); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
288 |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
289 /* |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
290 * Usecases, how it USED TO BE initially: |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
291 * 3 lines changed to 10 lines. range of 10 lines breaks down to 2 from p2, 3 from p1, and 5 from p2. |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
292 * We report: 2 lines changed to 2(p2), then 1 line changed with 3(p1) and 5 lines added from p2. |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
293 * |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
294 * 10 lines changed to 3 lines, range of 3 lines breaks down to 2 line from p1 and 1 line from p2. |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
295 * We report: 2 lines changed to 2(p1) and 8 lines changed to 1(p2) |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
296 * |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
297 * NOW, lines from p2 are always reported as pure add (since we need their insertion point to be in p2, not in p1) |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
298 * and we try to consume p1 changes as soon as we see first p1's range |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
299 */ |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
300 int s1TotalLines = s1To - s1From, s1ConsumedLines = 0, s1Start = s1From; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
301 |
674
cce0387c6041
Introduced dedicated IntSliceSeq/IntTuple in place of IntArray with subsequences
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
629
diff
changeset
|
302 for (Iterator<IntTuple> it = mergeRanges.iterator(); it.hasNext();) { |
cce0387c6041
Introduced dedicated IntSliceSeq/IntTuple in place of IntArray with subsequences
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
629
diff
changeset
|
303 IntTuple mergeRange = it.next(); |
cce0387c6041
Introduced dedicated IntSliceSeq/IntTuple in place of IntArray with subsequences
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
629
diff
changeset
|
304 final int rangeOrigin = mergeRange.at(0); |
cce0387c6041
Introduced dedicated IntSliceSeq/IntTuple in place of IntArray with subsequences
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
629
diff
changeset
|
305 final int rangeStart = mergeRange.at(1); |
cce0387c6041
Introduced dedicated IntSliceSeq/IntTuple in place of IntArray with subsequences
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
629
diff
changeset
|
306 final int rangeLen = mergeRange.at(2); |
cce0387c6041
Introduced dedicated IntSliceSeq/IntTuple in place of IntArray with subsequences
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
629
diff
changeset
|
307 final boolean lastRange = it.hasNext(); |
569
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
308 final int s1LinesLeft = s1TotalLines - s1ConsumedLines; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
309 // how many lines we may report as changed (don't use more than in range unless it's the very last range) |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
310 final int s1LinesToBorrow = lastRange ? s1LinesLeft : Math.min(s1LinesLeft, rangeLen); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
311 if (rangeOrigin != csetMergeParent && s1LinesToBorrow > 0) { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
312 ChangeBlockImpl block = getChangeBlock(s1Start, s1LinesToBorrow, rangeStart, rangeLen); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
313 block.setOriginAndTarget(rangeOrigin, csetTarget); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
314 insp.changed(block); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
315 s1ConsumedLines += s1LinesToBorrow; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
316 s1Start += s1LinesToBorrow; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
317 } else { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
318 int blockInsPoint = rangeOrigin != csetMergeParent ? s1Start : p2MergeCommon.reverseMapLine(rangeStart); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
319 ChangeBlockImpl block = getAddBlock(rangeStart, rangeLen, blockInsPoint); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
320 block.setOriginAndTarget(rangeOrigin, csetTarget); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
321 insp.added(block); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
322 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
323 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
324 if (s1ConsumedLines != s1TotalLines) { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
325 assert s1ConsumedLines < s1TotalLines : String.format("Expected to process %d lines, but actually was %d", s1TotalLines, s1ConsumedLines); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
326 // either there were no ranges from p1, whole s2From..s2To range came from p2, shall report as deleted |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
327 // or the ranges found were not enough to consume whole s2From..s2To |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
328 // The "deletion point" is shifted to the end of last csetOrigin->csetTarget change |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
329 int s2DeletePoint = s2From + s1ConsumedLines; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
330 ChangeBlockImpl block = new ChangeBlockImpl(annotatedRevision.origin, null, s1Start, s1To - s1Start, -1, -1, -1, s2DeletePoint); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
331 block.setOriginAndTarget(csetOrigin, csetTarget); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
332 insp.deleted(block); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
333 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
334 } else { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
335 ChangeBlockImpl block = getChangeBlock(s1From, s1To - s1From, s2From, s2To - s2From); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
336 block.setOriginAndTarget(csetOrigin, csetTarget); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
337 insp.changed(block); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
338 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
339 } catch (HgCallbackTargetException ex) { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
340 error = ex; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
341 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
342 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
343 |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
344 @Override |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
345 protected void added(int s1InsertPoint, int s2From, int s2To) { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
346 if (shallStop()) { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
347 return; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
348 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
349 try { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
350 if (p2MergeCommon != null) { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
351 mergeRanges.clear(); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
352 p2MergeCommon.combineAndMarkRangesWithTarget(s2From, s2To - s2From, csetOrigin, csetMergeParent, mergeRanges); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
353 int insPoint = s1InsertPoint; // track changes to insertion point |
674
cce0387c6041
Introduced dedicated IntSliceSeq/IntTuple in place of IntArray with subsequences
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
629
diff
changeset
|
354 for (IntTuple mergeRange : mergeRanges) { |
cce0387c6041
Introduced dedicated IntSliceSeq/IntTuple in place of IntArray with subsequences
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
629
diff
changeset
|
355 int rangeOrigin = mergeRange.at(0); |
cce0387c6041
Introduced dedicated IntSliceSeq/IntTuple in place of IntArray with subsequences
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
629
diff
changeset
|
356 int rangeStart = mergeRange.at(1); |
cce0387c6041
Introduced dedicated IntSliceSeq/IntTuple in place of IntArray with subsequences
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
629
diff
changeset
|
357 int rangeLen = mergeRange.at(2); |
569
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
358 ChangeBlockImpl block = getAddBlock(rangeStart, rangeLen, insPoint); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
359 block.setOriginAndTarget(rangeOrigin, csetTarget); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
360 insp.added(block); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
361 // indicate insPoint moved down number of lines we just reported |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
362 insPoint += rangeLen; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
363 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
364 } else { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
365 ChangeBlockImpl block = getAddBlock(s2From, s2To - s2From, s1InsertPoint); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
366 block.setOriginAndTarget(csetOrigin, csetTarget); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
367 insp.added(block); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
368 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
369 } catch (HgCallbackTargetException ex) { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
370 error = ex; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
371 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
372 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
373 |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
374 @Override |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
375 protected void deleted(int s2DeletePoint, int s1From, int s1To) { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
376 if (shallStop()) { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
377 return; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
378 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
379 try { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
380 ChangeBlockImpl block = new ChangeBlockImpl(annotatedRevision.origin, null, s1From, s1To - s1From, -1, -1, -1, s2DeletePoint); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
381 block.setOriginAndTarget(csetOrigin, csetTarget); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
382 insp.deleted(block); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
383 } catch (HgCallbackTargetException ex) { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
384 error = ex; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
385 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
386 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
387 |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
388 @Override |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
389 protected void unchanged(int s1From, int s2From, int length) { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
390 if (shallStop()) { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
391 return; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
392 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
393 try { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
394 EqualBlockImpl block = new EqualBlockImpl(s1From, s2From, length, annotatedRevision.target); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
395 block.setOriginAndTarget(csetOrigin, csetTarget); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
396 insp.same(block); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
397 } catch (HgCallbackTargetException ex) { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
398 error = ex; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
399 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
400 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
401 |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
402 void checkErrors() throws HgCallbackTargetException { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
403 if (error != null) { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
404 throw error; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
405 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
406 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
407 |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
408 private boolean shallStop() { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
409 return error != null; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
410 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
411 |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
412 private ChangeBlockImpl getAddBlock(int start, int len, int insPoint) { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
413 return new ChangeBlockImpl(null, annotatedRevision.target, -1, -1, start, len, insPoint, -1); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
414 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
415 |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
416 private ChangeBlockImpl getChangeBlock(int start1, int len1, int start2, int len2) { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
417 return new ChangeBlockImpl(annotatedRevision.origin, annotatedRevision.target, start1, len1, start2, len2, start1, start2); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
418 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
419 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
420 |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
421 private static class BlockImpl implements Block { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
422 private int originCset; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
423 private int targetCset; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
424 |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
425 void setOriginAndTarget(int originChangesetIndex, int targetChangesetIndex) { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
426 // XXX perhaps, shall be part of Inspector API, rather than Block's |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
427 // as they don't change between blocks (although the moment about merged revisions) |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
428 // is not yet clear to me |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
429 originCset = originChangesetIndex; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
430 targetCset = targetChangesetIndex; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
431 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
432 |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
433 public int originChangesetIndex() { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
434 return originCset; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
435 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
436 |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
437 public int targetChangesetIndex() { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
438 return targetCset; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
439 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
440 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
441 |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
442 private static class EqualBlockImpl extends BlockImpl implements EqualBlock { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
443 private final int start1, start2; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
444 private final int length; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
445 private final ContentBlock fullContent; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
446 private FilterBlock myContent; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
447 |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
448 EqualBlockImpl(int blockStartSeq1, int blockStartSeq2, int blockLength, ContentBlock targetContent) { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
449 start1 = blockStartSeq1; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
450 start2 = blockStartSeq2; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
451 length = blockLength; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
452 fullContent = targetContent; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
453 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
454 |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
455 public int originStart() { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
456 return start1; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
457 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
458 |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
459 public int targetStart() { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
460 return start2; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
461 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
462 |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
463 public int length() { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
464 return length; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
465 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
466 |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
467 public BlockData content() { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
468 if (myContent == null) { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
469 myContent = new FilterBlock(fullContent, start2, length); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
470 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
471 return myContent; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
472 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
473 |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
474 @Override |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
475 public String toString() { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
476 return String.format("@@ [%d..%d) == [%d..%d) @@", start1, start1+length, start2, start2+length); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
477 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
478 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
479 |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
480 private static class ChangeBlockImpl extends BlockImpl implements ChangeBlock { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
481 private final ContentBlock oldContent; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
482 private final ContentBlock newContent; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
483 private final int s1Start; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
484 private final int s1Len; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
485 private final int s2Start; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
486 private final int s2Len; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
487 private final int s1InsertPoint; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
488 private final int s2DeletePoint; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
489 private FilterBlock addedBlock, removedBlock; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
490 |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
491 public ChangeBlockImpl(ContentBlock c1, ContentBlock c2, int s1Start, int s1Len, int s2Start, int s2Len, int s1InsertPoint, int s2DeletePoint) { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
492 oldContent = c1; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
493 newContent = c2; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
494 this.s1Start = s1Start; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
495 this.s1Len = s1Len; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
496 this.s2Start = s2Start; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
497 this.s2Len = s2Len; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
498 this.s1InsertPoint = s1InsertPoint; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
499 this.s2DeletePoint = s2DeletePoint; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
500 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
501 |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
502 public int insertedAt() { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
503 return s1InsertPoint; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
504 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
505 |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
506 public int firstAddedLine() { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
507 return s2Start; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
508 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
509 |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
510 public int totalAddedLines() { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
511 return s2Len; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
512 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
513 |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
514 public BlockData addedLines() { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
515 if (addedBlock == null) { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
516 addedBlock = new FilterBlock(newContent, firstAddedLine(), totalAddedLines()); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
517 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
518 return addedBlock; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
519 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
520 |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
521 public int removedAt() { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
522 return s2DeletePoint; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
523 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
524 |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
525 public int firstRemovedLine() { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
526 return s1Start; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
527 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
528 |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
529 public int totalRemovedLines() { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
530 return s1Len; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
531 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
532 |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
533 public BlockData removedLines() { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
534 if (removedBlock == null) { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
535 removedBlock = new FilterBlock(oldContent, firstRemovedLine(), totalRemovedLines()); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
536 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
537 return removedBlock; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
538 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
539 |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
540 @Override |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
541 public String toString() { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
542 if (s2DeletePoint == -1) { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
543 return String.format("@@ -%d,0 +%d,%d @@", insertedAt(), firstAddedLine(), totalAddedLines()); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
544 } else if (s1InsertPoint == -1) { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
545 // delete only |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
546 return String.format("@@ -%d,%d +%d,0 @@", firstRemovedLine(), totalRemovedLines(), removedAt()); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
547 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
548 return String.format("@@ -%d,%d +%d,%d @@", firstRemovedLine(), totalRemovedLines(), firstAddedLine(), totalAddedLines()); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
549 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
550 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
551 |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
552 private static class SingleLine implements BlockData { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
553 private final ByteChain line; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
554 |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
555 public SingleLine(ByteChain lineContent) { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
556 line = lineContent; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
557 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
558 |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
559 public BlockData elementAt(int index) { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
560 assert false; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
561 return null; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
562 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
563 |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
564 public int elementCount() { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
565 return 0; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
566 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
567 |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
568 public byte[] asArray() { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
569 return line.data(); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
570 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
571 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
572 |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
573 private static class ContentBlock implements BlockData { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
574 private final LineSequence seq; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
575 |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
576 public ContentBlock(LineSequence sequence) { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
577 seq = sequence; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
578 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
579 |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
580 public BlockData elementAt(int index) { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
581 return new SingleLine(seq.chunk(index)); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
582 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
583 |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
584 public int elementCount() { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
585 return seq.chunkCount() - 1; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
586 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
587 |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
588 public byte[] asArray() { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
589 return seq.data(0, seq.chunkCount() - 1); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
590 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
591 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
592 |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
593 private static class FilterBlock implements BlockData { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
594 private final ContentBlock contentBlock; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
595 private final int from; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
596 private final int length; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
597 |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
598 public FilterBlock(ContentBlock bd, int startFrom, int len) { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
599 assert bd != null; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
600 assert startFrom + len < bd.seq.chunkCount(); // there's one extra chunk in the end, so strict less is ok |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
601 contentBlock = bd; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
602 from = startFrom; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
603 length = len; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
604 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
605 |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
606 public BlockData elementAt(int index) { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
607 if (index < 0 || index >= length) { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
608 throw new IllegalArgumentException(String.format("Expected value from [0..%d), got %d", length, index)); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
609 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
610 return contentBlock.elementAt(from + index); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
611 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
612 |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
613 public int elementCount() { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
614 return length; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
615 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
616 |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
617 public byte[] asArray() { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
618 return contentBlock.seq.data(from, from + length); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
619 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
620 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
621 |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
622 |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
623 private static class EqualBlocksCollector implements DiffHelper.MatchInspector<LineSequence> { |
674
cce0387c6041
Introduced dedicated IntSliceSeq/IntTuple in place of IntArray with subsequences
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
629
diff
changeset
|
624 private final RangePairSeq matches = new RangePairSeq(); |
569
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
625 |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
626 public void begin(LineSequence s1, LineSequence s2) { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
627 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
628 |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
629 public void match(int startSeq1, int startSeq2, int matchLength) { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
630 matches.add(startSeq1, startSeq2, matchLength); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
631 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
632 |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
633 public void end() { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
634 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
635 |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
636 public int reverseMapLine(int ln) { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
637 return matches.reverseMapLine(ln); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
638 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
639 |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
640 public void intersectWithTarget(int start, int length, IntVector result) { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
641 int s = start; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
642 for (int l = start, x = start + length; l < x; l++) { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
643 if (!matches.includesTargetLine(l)) { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
644 if (l - s > 0) { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
645 result.add(s); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
646 result.add(l - s); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
647 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
648 s = l+1; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
649 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
650 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
651 if (s < start+length) { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
652 result.add(s); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
653 result.add((start + length) - s); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
654 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
655 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
656 |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
657 /* |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
658 * intersects [start..start+length) with ranges of target lines, and based on the intersection |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
659 * breaks initial range into smaller ranges and records them into result, with marker to indicate |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
660 * whether the range is from initial range (markerSource) or is a result of the intersection with target |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
661 * (markerTarget) |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
662 */ |
674
cce0387c6041
Introduced dedicated IntSliceSeq/IntTuple in place of IntArray with subsequences
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
629
diff
changeset
|
663 public void combineAndMarkRangesWithTarget(int start, int length, int markerSource, int markerTarget, IntSliceSeq result) { |
cce0387c6041
Introduced dedicated IntSliceSeq/IntTuple in place of IntArray with subsequences
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
629
diff
changeset
|
664 assert result.sliceSize() == 3; |
569
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
665 int sourceStart = start, targetStart = start, sourceEnd = start + length; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
666 for (int l = sourceStart; l < sourceEnd; l++) { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
667 if (matches.includesTargetLine(l)) { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
668 // l is from target |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
669 if (sourceStart < l) { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
670 // few lines from source range were not in the target, report them |
674
cce0387c6041
Introduced dedicated IntSliceSeq/IntTuple in place of IntArray with subsequences
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
629
diff
changeset
|
671 result.add(markerSource, sourceStart, l - sourceStart); |
569
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
672 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
673 // indicate the earliest line from source range to use |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
674 sourceStart = l + 1; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
675 } else { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
676 // l is not in target |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
677 if (targetStart < l) { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
678 // report lines from target range |
674
cce0387c6041
Introduced dedicated IntSliceSeq/IntTuple in place of IntArray with subsequences
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
629
diff
changeset
|
679 result.add(markerTarget, targetStart, l - targetStart); |
569
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
680 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
681 // next line *may* be from target |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
682 targetStart = l + 1; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
683 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
684 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
685 // if source range end with line from target, sourceStart would be == sourceEnd, and we need to add range with markerTarget |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
686 // if source range doesn't end with target line, targetStart == sourceEnd, while sourceStart < sourceEnd |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
687 if (sourceStart < sourceEnd) { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
688 assert targetStart == sourceEnd; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
689 // something left from the source range |
674
cce0387c6041
Introduced dedicated IntSliceSeq/IntTuple in place of IntArray with subsequences
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
629
diff
changeset
|
690 result.add(markerSource, sourceStart, sourceEnd - sourceStart); |
569
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
691 } else if (targetStart < sourceEnd) { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
692 assert sourceStart == sourceEnd; |
674
cce0387c6041
Introduced dedicated IntSliceSeq/IntTuple in place of IntArray with subsequences
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
629
diff
changeset
|
693 result.add(markerTarget, targetStart, sourceEnd - targetStart); |
569
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
694 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
695 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
696 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
697 |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
698 private static class AnnotateRev implements RevisionDescriptor { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
699 public ContentBlock origin, target; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
700 public int originCset, targetCset, mergeCset, fileRevIndex; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
701 public HgDataFile df; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
702 |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
703 public void set(HgDataFile file, int fileRev) { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
704 df = file; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
705 fileRevIndex = fileRev; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
706 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
707 public void set(ContentBlock o, ContentBlock t) { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
708 origin = o; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
709 target = t; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
710 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
711 public void set(int o, int t, int m) { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
712 originCset = o; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
713 targetCset = t; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
714 mergeCset = m; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
715 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
716 |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
717 public BlockData origin() { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
718 return origin; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
719 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
720 |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
721 public BlockData target() { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
722 return target; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
723 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
724 |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
725 public int originChangesetIndex() { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
726 return originCset; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
727 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
728 |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
729 public int targetChangesetIndex() { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
730 return targetCset; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
731 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
732 |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
733 public boolean isMerge() { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
734 return mergeCset != NO_REVISION; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
735 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
736 |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
737 public int mergeChangesetIndex() { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
738 return mergeCset; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
739 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
740 |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
741 public int fileRevisionIndex() { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
742 return fileRevIndex; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
743 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
744 public HgDataFile file() { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
745 return df; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
746 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
747 @Override |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
748 public String toString() { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
749 if (isMerge()) { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
750 return String.format("[%d,%d->%d]", originCset, mergeCset, targetCset); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
751 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
752 return String.format("[%d->%d]", originCset, targetCset); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
753 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
754 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
755 |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
756 public static void main(String[] args) { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
757 EqualBlocksCollector bc = new EqualBlocksCollector(); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
758 bc.match(-1, 5, 3); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
759 bc.match(-1, 10, 2); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
760 bc.match(-1, 15, 3); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
761 bc.match(-1, 20, 3); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
762 IntVector r = new IntVector(); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
763 bc.intersectWithTarget(7, 10, r); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
764 for (int i = 0; i < r.size(); i+=2) { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
765 System.out.printf("[%d..%d) ", r.get(i), r.get(i) + r.get(i+1)); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
766 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
767 System.out.println(); |
674
cce0387c6041
Introduced dedicated IntSliceSeq/IntTuple in place of IntArray with subsequences
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
629
diff
changeset
|
768 IntSliceSeq mr = new IntSliceSeq(3); |
cce0387c6041
Introduced dedicated IntSliceSeq/IntTuple in place of IntArray with subsequences
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
629
diff
changeset
|
769 bc.combineAndMarkRangesWithTarget(0, 16, 508, 514, mr); |
cce0387c6041
Introduced dedicated IntSliceSeq/IntTuple in place of IntArray with subsequences
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
629
diff
changeset
|
770 for (IntTuple t : mr) { |
cce0387c6041
Introduced dedicated IntSliceSeq/IntTuple in place of IntArray with subsequences
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
629
diff
changeset
|
771 System.out.printf("%d:[%d..%d) ", t.at(0), t.at(1), t.at(1) + t.at(2)); |
569
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
772 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
773 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
774 } |