Mercurial > hg4j
annotate src/org/tmatesoft/hg/internal/BlameHelper.java @ 598:d29d9dc6c128
Utilize the fact nodeids are very different and are read anyway to speed up reverse lookup
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Fri, 03 May 2013 15:19:18 +0200 |
parents | c4fd1037bc6f |
children | 707b5c7c6fa4 |
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 |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
19 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
|
20 |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
21 import java.util.LinkedList; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
22 import java.util.ListIterator; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
23 |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
24 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
|
25 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
|
26 import org.tmatesoft.hg.internal.DiffHelper.LineSequence.ByteChain; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
27 import org.tmatesoft.hg.repo.HgBlameFacility.Block; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
28 import org.tmatesoft.hg.repo.HgBlameFacility.BlockData; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
29 import org.tmatesoft.hg.repo.HgBlameFacility.ChangeBlock; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
30 import org.tmatesoft.hg.repo.HgBlameFacility.EqualBlock; |
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.HgBlameFacility.Inspector; |
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.HgBlameFacility.RevisionDescriptor; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
33 import org.tmatesoft.hg.repo.HgBlameFacility.RevisionDescriptor.Recipient; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
34 import org.tmatesoft.hg.repo.HgBlameFacility; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
35 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
|
36 import org.tmatesoft.hg.repo.HgInvalidStateException; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
37 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
|
38 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
|
39 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
|
40 |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
41 /** |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
42 * Blame implementation |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
43 * @see HgBlameFacility |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
44 * @author Artem Tikhomirov |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
45 * @author TMate Software Ltd. |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
46 */ |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
47 public class BlameHelper { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
48 |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
49 private final Inspector insp; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
50 private FileLinesCache linesCache; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
51 |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
52 // FIXME exposing internals (use of FileLinesCache through cons arg and #useFileUpTo) smells bad, refactor! |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
53 |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
54 public BlameHelper(Inspector inspector, int cacheHint) { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
55 insp = inspector; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
56 linesCache = new FileLinesCache(cacheHint); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
57 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
58 |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
59 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
|
60 linesCache.useFileUpTo(df, clogRevIndex); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
61 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
62 |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
63 // NO_REVISION is not allowed as any argument |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
64 public void diff(int fileRevIndex1, int clogRevIndex1, int fileRevIndex2, int clogRevIndex2) throws HgCallbackTargetException { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
65 HgDataFile targetFile = linesCache.getFile(clogRevIndex2); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
66 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
|
67 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
|
68 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
|
69 pg.init(c1, c2); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
70 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
|
71 pg.findMatchingBlocks(bbi); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
72 bbi.checkErrors(); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
73 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
74 |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
75 public void annotateChange(int fileRevIndex, int csetRevIndex, int[] fileParentRevs, int[] fileParentClogRevs) throws HgCallbackTargetException { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
76 HgDataFile targetFile = linesCache.getFile(csetRevIndex); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
77 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
|
78 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
|
79 int p1ClogIndex = fileParentClogRevs[0]; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
80 int p2ClogIndex = fileParentClogRevs[1]; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
81 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
|
82 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
|
83 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
|
84 pg.init(p2Lines, fileRevLines); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
85 EqualBlocksCollector p2MergeCommon = new EqualBlocksCollector(); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
86 pg.findMatchingBlocks(p2MergeCommon); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
87 // |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
88 pg.init(p1Lines); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
89 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
|
90 bbi.setMergeParent2(p2MergeCommon, p2ClogIndex); |
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 } 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
|
94 // 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
|
95 assert fileParentClogRevs[0] == NO_REVISION; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
96 // everything added |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
97 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
|
98 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
|
99 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
|
100 bbi.end(); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
101 bbi.checkErrors(); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
102 } else { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
103 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
|
104 assert fileParentClogRevs[soleParentIndex] != NO_REVISION; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
105 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
|
106 |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
107 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
|
108 pg.init(parentLines, fileRevLines); |
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, fileParentClogRevs[soleParentIndex], csetRevIndex); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
110 pg.findMatchingBlocks(bbi); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
111 bbi.checkErrors(); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
112 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
113 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
114 |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
115 private static class FileLinesCache { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
116 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
|
117 private final int limit; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
118 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
|
119 |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
120 public FileLinesCache(int lruLimit) { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
121 limit = lruLimit; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
122 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
|
123 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
|
124 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
125 |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
126 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
|
127 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
|
128 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
|
129 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
|
130 if (e.first() == clogRevIndex) { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
131 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
|
132 return; |
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 if (e.first() > clogRevIndex) { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
135 // insert new entry before current |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
136 it.previous(); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
137 it.add(newEntry); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
138 return; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
139 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
140 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
141 files.add(newEntry); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
142 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
143 |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
144 public HgDataFile getFile(int clogRevIndex) { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
145 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
|
146 if (e.first() >= clogRevIndex) { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
147 return e.second(); |
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 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
150 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
|
151 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
152 |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
153 public LineSequence lines(int clogRevIndex, int fileRevIndex) { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
154 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
|
155 if (cached != null) { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
156 return cached.second(); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
157 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
158 HgDataFile df = getFile(clogRevIndex); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
159 try { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
160 ByteArrayChannel c; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
161 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
|
162 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
|
163 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
|
164 if (lruCache.size() > limit) { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
165 lruCache.removeLast(); |
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 return rv; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
168 } catch (CancelledException ex) { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
169 // 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
|
170 // deprecate and provide alternative? |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
171 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
|
172 ise.initCause(ex); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
173 throw ise; |
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 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
176 |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
177 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
|
178 Pair<Integer, LineSequence> rv = null; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
179 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
|
180 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
|
181 if (p.first() == fileRevIndex) { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
182 rv = p; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
183 it.remove(); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
184 break; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
185 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
186 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
187 if (rv != null) { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
188 lruCache.addFirst(rv); |
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 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
192 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
193 |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
194 private static class BlameBlockInspector extends DiffHelper.DeltaInspector<LineSequence> { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
195 private final Inspector insp; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
196 private final int csetOrigin; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
197 private final int csetTarget; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
198 private EqualBlocksCollector p2MergeCommon; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
199 private int csetMergeParent; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
200 private IntVector mergeRanges; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
201 private final AnnotateRev annotatedRevision; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
202 private HgCallbackTargetException error; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
203 |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
204 public BlameBlockInspector(HgDataFile df, int fileRevIndex, Inspector inspector, int originCset, int targetCset) { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
205 assert inspector != null; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
206 insp = inspector; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
207 annotatedRevision = new AnnotateRev(); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
208 annotatedRevision.set(df, fileRevIndex); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
209 csetOrigin = originCset; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
210 csetTarget = targetCset; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
211 } |
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 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
|
214 p2MergeCommon = p2Merge; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
215 csetMergeParent = parentCset2; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
216 mergeRanges = new IntVector(3*10, 3*10); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
217 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
218 |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
219 @Override |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
220 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
|
221 super.begin(s1, s2); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
222 if (shallStop()) { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
223 return; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
224 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
225 ContentBlock originContent = new ContentBlock(s1); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
226 ContentBlock targetContent = new ContentBlock(s2); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
227 annotatedRevision.set(originContent, targetContent); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
228 annotatedRevision.set(csetOrigin, csetTarget, p2MergeCommon != null ? csetMergeParent : NO_REVISION); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
229 Recipient curious = Adaptable.Factory.getAdapter(insp, Recipient.class, null); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
230 if (curious != null) { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
231 try { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
232 curious.start(annotatedRevision); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
233 } catch (HgCallbackTargetException ex) { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
234 error = ex; |
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 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
237 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
238 |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
239 @Override |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
240 public void end() { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
241 super.end(); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
242 if (shallStop()) { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
243 return; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
244 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
245 Recipient curious = Adaptable.Factory.getAdapter(insp, Recipient.class, null); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
246 if (curious != null) { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
247 try { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
248 curious.done(annotatedRevision); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
249 } catch (HgCallbackTargetException ex) { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
250 error = ex; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
251 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
252 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
253 p2MergeCommon = null; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
254 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
255 |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
256 @Override |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
257 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
|
258 if (shallStop()) { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
259 return; |
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 try { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
262 if (p2MergeCommon != null) { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
263 mergeRanges.clear(); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
264 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
|
265 |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
266 /* |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
267 * 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
|
268 * 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
|
269 * 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
|
270 * |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
271 * 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
|
272 * 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
|
273 * |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
274 * 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
|
275 * 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
|
276 */ |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
277 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
|
278 |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
279 for (int i = 0; i < mergeRanges.size(); i += 3) { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
280 final int rangeOrigin = mergeRanges.get(i); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
281 final int rangeStart = mergeRanges.get(i+1); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
282 final int rangeLen = mergeRanges.get(i+2); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
283 final boolean lastRange = i+3 >= mergeRanges.size(); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
284 final int s1LinesLeft = s1TotalLines - s1ConsumedLines; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
285 // 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
|
286 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
|
287 if (rangeOrigin != csetMergeParent && s1LinesToBorrow > 0) { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
288 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
|
289 block.setOriginAndTarget(rangeOrigin, csetTarget); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
290 insp.changed(block); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
291 s1ConsumedLines += s1LinesToBorrow; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
292 s1Start += s1LinesToBorrow; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
293 } else { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
294 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
|
295 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
|
296 block.setOriginAndTarget(rangeOrigin, csetTarget); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
297 insp.added(block); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
298 } |
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 if (s1ConsumedLines != s1TotalLines) { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
301 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
|
302 // 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
|
303 // 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
|
304 // 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
|
305 int s2DeletePoint = s2From + s1ConsumedLines; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
306 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
|
307 block.setOriginAndTarget(csetOrigin, csetTarget); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
308 insp.deleted(block); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
309 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
310 } else { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
311 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
|
312 block.setOriginAndTarget(csetOrigin, csetTarget); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
313 insp.changed(block); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
314 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
315 } catch (HgCallbackTargetException ex) { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
316 error = ex; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
317 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
318 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
319 |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
320 @Override |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
321 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
|
322 if (shallStop()) { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
323 return; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
324 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
325 try { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
326 if (p2MergeCommon != null) { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
327 mergeRanges.clear(); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
328 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
|
329 int insPoint = s1InsertPoint; // track changes to insertion point |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
330 for (int i = 0; i < mergeRanges.size(); i += 3) { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
331 int rangeOrigin = mergeRanges.get(i); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
332 int rangeStart = mergeRanges.get(i+1); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
333 int rangeLen = mergeRanges.get(i+2); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
334 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
|
335 block.setOriginAndTarget(rangeOrigin, csetTarget); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
336 insp.added(block); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
337 // 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
|
338 insPoint += rangeLen; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
339 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
340 } else { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
341 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
|
342 block.setOriginAndTarget(csetOrigin, csetTarget); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
343 insp.added(block); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
344 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
345 } catch (HgCallbackTargetException ex) { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
346 error = ex; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
347 } |
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 |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
350 @Override |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
351 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
|
352 if (shallStop()) { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
353 return; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
354 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
355 try { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
356 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
|
357 block.setOriginAndTarget(csetOrigin, csetTarget); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
358 insp.deleted(block); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
359 } catch (HgCallbackTargetException ex) { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
360 error = ex; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
361 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
362 } |
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 @Override |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
365 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
|
366 if (shallStop()) { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
367 return; |
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 try { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
370 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
|
371 block.setOriginAndTarget(csetOrigin, csetTarget); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
372 insp.same(block); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
373 } catch (HgCallbackTargetException ex) { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
374 error = ex; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
375 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
376 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
377 |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
378 void checkErrors() throws HgCallbackTargetException { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
379 if (error != null) { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
380 throw error; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
381 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
382 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
383 |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
384 private boolean shallStop() { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
385 return error != null; |
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 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
|
389 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
|
390 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
391 |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
392 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
|
393 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
|
394 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
395 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
396 |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
397 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
|
398 private int originCset; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
399 private int targetCset; |
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 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
|
402 // 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
|
403 // 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
|
404 // 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
|
405 originCset = originChangesetIndex; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
406 targetCset = targetChangesetIndex; |
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 |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
409 public int originChangesetIndex() { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
410 return originCset; |
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 |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
413 public int targetChangesetIndex() { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
414 return targetCset; |
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 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
417 |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
418 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
|
419 private final int start1, start2; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
420 private final int length; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
421 private final ContentBlock fullContent; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
422 private FilterBlock myContent; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
423 |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
424 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
|
425 start1 = blockStartSeq1; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
426 start2 = blockStartSeq2; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
427 length = blockLength; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
428 fullContent = targetContent; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
429 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
430 |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
431 public int originStart() { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
432 return start1; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
433 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
434 |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
435 public int targetStart() { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
436 return start2; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
437 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
438 |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
439 public int length() { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
440 return length; |
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 |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
443 public BlockData content() { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
444 if (myContent == null) { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
445 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
|
446 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
447 return myContent; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
448 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
449 |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
450 @Override |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
451 public String toString() { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
452 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
|
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 |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
456 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
|
457 private final ContentBlock oldContent; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
458 private final ContentBlock newContent; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
459 private final int s1Start; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
460 private final int s1Len; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
461 private final int s2Start; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
462 private final int s2Len; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
463 private final int s1InsertPoint; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
464 private final int s2DeletePoint; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
465 private FilterBlock addedBlock, removedBlock; |
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 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
|
468 oldContent = c1; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
469 newContent = c2; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
470 this.s1Start = s1Start; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
471 this.s1Len = s1Len; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
472 this.s2Start = s2Start; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
473 this.s2Len = s2Len; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
474 this.s1InsertPoint = s1InsertPoint; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
475 this.s2DeletePoint = s2DeletePoint; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
476 } |
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 public int insertedAt() { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
479 return s1InsertPoint; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
480 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
481 |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
482 public int firstAddedLine() { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
483 return s2Start; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
484 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
485 |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
486 public int totalAddedLines() { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
487 return s2Len; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
488 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
489 |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
490 public BlockData addedLines() { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
491 if (addedBlock == null) { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
492 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
|
493 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
494 return addedBlock; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
495 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
496 |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
497 public int removedAt() { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
498 return s2DeletePoint; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
499 } |
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 public int firstRemovedLine() { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
502 return s1Start; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
503 } |
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 public int totalRemovedLines() { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
506 return s1Len; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
507 } |
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 public BlockData removedLines() { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
510 if (removedBlock == null) { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
511 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
|
512 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
513 return removedBlock; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
514 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
515 |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
516 @Override |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
517 public String toString() { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
518 if (s2DeletePoint == -1) { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
519 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
|
520 } else if (s1InsertPoint == -1) { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
521 // delete only |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
522 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
|
523 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
524 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
|
525 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
526 } |
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 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
|
529 private final ByteChain line; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
530 |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
531 public SingleLine(ByteChain lineContent) { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
532 line = lineContent; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
533 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
534 |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
535 public BlockData elementAt(int index) { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
536 assert false; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
537 return null; |
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 public int elementCount() { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
541 return 0; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
542 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
543 |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
544 public byte[] asArray() { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
545 return line.data(); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
546 } |
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 |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
549 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
|
550 private final LineSequence seq; |
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 public ContentBlock(LineSequence sequence) { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
553 seq = sequence; |
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 |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
556 public BlockData elementAt(int index) { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
557 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
|
558 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
559 |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
560 public int elementCount() { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
561 return seq.chunkCount() - 1; |
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 byte[] asArray() { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
565 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
|
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 |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
569 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
|
570 private final ContentBlock contentBlock; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
571 private final int from; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
572 private final int length; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
573 |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
574 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
|
575 assert bd != null; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
576 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
|
577 contentBlock = bd; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
578 from = startFrom; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
579 length = len; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
580 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
581 |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
582 public BlockData elementAt(int index) { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
583 if (index < 0 || index >= length) { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
584 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
|
585 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
586 return contentBlock.elementAt(from + index); |
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 |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
589 public int elementCount() { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
590 return length; |
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 public byte[] asArray() { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
594 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
|
595 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
596 } |
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 |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
599 private static class EqualBlocksCollector implements DiffHelper.MatchInspector<LineSequence> { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
600 private final RangeSeq matches = new RangeSeq(); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
601 |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
602 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
|
603 } |
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 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
|
606 matches.add(startSeq1, startSeq2, matchLength); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
607 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
608 |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
609 public void end() { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
610 } |
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 public int reverseMapLine(int ln) { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
613 return matches.reverseMapLine(ln); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
614 } |
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 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
|
617 int s = start; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
618 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
|
619 if (!matches.includesTargetLine(l)) { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
620 if (l - s > 0) { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
621 result.add(s); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
622 result.add(l - s); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
623 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
624 s = l+1; |
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 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
627 if (s < start+length) { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
628 result.add(s); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
629 result.add((start + length) - s); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
630 } |
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 /* |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
634 * 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
|
635 * 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
|
636 * 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
|
637 * (markerTarget) |
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 public void combineAndMarkRangesWithTarget(int start, int length, int markerSource, int markerTarget, IntVector result) { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
640 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
|
641 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
|
642 if (matches.includesTargetLine(l)) { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
643 // l is from target |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
644 if (sourceStart < l) { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
645 // few lines from source range were not in the target, report them |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
646 result.add(markerSource); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
647 result.add(sourceStart); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
648 result.add(l - sourceStart); |
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 // 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
|
651 sourceStart = l + 1; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
652 } else { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
653 // l is not in target |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
654 if (targetStart < l) { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
655 // report lines from target range |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
656 result.add(markerTarget); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
657 result.add(targetStart); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
658 result.add(l - targetStart); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
659 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
660 // 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
|
661 targetStart = l + 1; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
662 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
663 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
664 // 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
|
665 // 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
|
666 if (sourceStart < sourceEnd) { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
667 assert targetStart == sourceEnd; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
668 // something left from the source range |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
669 result.add(markerSource); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
670 result.add(sourceStart); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
671 result.add(sourceEnd - sourceStart); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
672 } else if (targetStart < sourceEnd) { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
673 assert sourceStart == sourceEnd; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
674 result.add(markerTarget); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
675 result.add(targetStart); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
676 result.add(sourceEnd - targetStart); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
677 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
678 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
679 } |
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 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
|
682 public ContentBlock origin, target; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
683 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
|
684 public HgDataFile df; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
685 |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
686 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
|
687 df = file; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
688 fileRevIndex = fileRev; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
689 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
690 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
|
691 origin = o; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
692 target = t; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
693 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
694 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
|
695 originCset = o; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
696 targetCset = t; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
697 mergeCset = m; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
698 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
699 |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
700 public BlockData origin() { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
701 return origin; |
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 |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
704 public BlockData target() { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
705 return target; |
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 |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
708 public int originChangesetIndex() { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
709 return originCset; |
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 |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
712 public int targetChangesetIndex() { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
713 return targetCset; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
714 } |
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 public boolean isMerge() { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
717 return mergeCset != NO_REVISION; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
718 } |
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 public int mergeChangesetIndex() { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
721 return mergeCset; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
722 } |
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 public int fileRevisionIndex() { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
725 return fileRevIndex; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
726 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
727 public HgDataFile file() { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
728 return df; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
729 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
730 @Override |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
731 public String toString() { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
732 if (isMerge()) { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
733 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
|
734 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
735 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
|
736 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
737 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
738 |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
739 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
|
740 EqualBlocksCollector bc = new EqualBlocksCollector(); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
741 bc.match(-1, 5, 3); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
742 bc.match(-1, 10, 2); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
743 bc.match(-1, 15, 3); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
744 bc.match(-1, 20, 3); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
745 IntVector r = new IntVector(); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
746 bc.intersectWithTarget(7, 10, r); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
747 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
|
748 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
|
749 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
750 System.out.println(); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
751 r.clear(); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
752 bc.combineAndMarkRangesWithTarget(0, 16, 508, 514, r); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
753 for (int i = 0; i < r.size(); i+=3) { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
754 System.out.printf("%d:[%d..%d) ", r.get(i), r.get(i+1), r.get(i+1) + r.get(i+2)); |
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 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
757 } |