Mercurial > jhg
annotate src/org/tmatesoft/hg/core/HgDiffCommand.java @ 643:a8ce405da1f5
v1.2 line of dev: update versions, use patch merge code by default
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Wed, 19 Jun 2013 16:03:11 +0200 |
parents | 54e16ab771ec |
children | a20121a2bba6 |
rev | line source |
---|---|
629
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
1 /* |
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
2 * Copyright (c) 2013 TMate Software Ltd |
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
3 * |
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
4 * This program is free software; you can redistribute it and/or modify |
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
5 * it under the terms of the GNU General Public License as published by |
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
6 * the Free Software Foundation; version 2 of the License. |
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
7 * |
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
8 * This program is distributed in the hope that it will be useful, |
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
11 * GNU General Public License for more details. |
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
12 * |
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
13 * For information on how to redistribute this software under |
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
14 * the terms of a license other than GNU General Public License |
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
15 * contact TMate Software at support@hg4j.com |
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
16 */ |
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
17 package org.tmatesoft.hg.core; |
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
18 |
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
19 import static org.tmatesoft.hg.repo.HgRepository.NO_REVISION; |
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
20 import static org.tmatesoft.hg.repo.HgRepository.TIP; |
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
21 |
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
22 import org.tmatesoft.hg.internal.BlameHelper; |
630
72c979555cb8
HgDiffCommand. Do not use deprecated code. Javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
629
diff
changeset
|
23 import org.tmatesoft.hg.internal.CsetParamKeeper; |
629
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
24 import org.tmatesoft.hg.internal.FileHistory; |
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
25 import org.tmatesoft.hg.internal.FileRevisionHistoryChunk; |
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
26 import org.tmatesoft.hg.repo.HgDataFile; |
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
27 import org.tmatesoft.hg.repo.HgRepository; |
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
28 import org.tmatesoft.hg.repo.HgRuntimeException; |
632
54e16ab771ec
Progress/cancel for HgDiffCommand. Renamed execute method
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
630
diff
changeset
|
29 import org.tmatesoft.hg.util.CancelSupport; |
629
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
30 import org.tmatesoft.hg.util.CancelledException; |
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
31 import org.tmatesoft.hg.util.Path; |
632
54e16ab771ec
Progress/cancel for HgDiffCommand. Renamed execute method
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
630
diff
changeset
|
32 import org.tmatesoft.hg.util.ProgressSupport; |
629
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
33 |
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
34 /** |
632
54e16ab771ec
Progress/cancel for HgDiffCommand. Renamed execute method
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
630
diff
changeset
|
35 * 'hg diff' counterpart, with similar, although not identical, functionality. |
54e16ab771ec
Progress/cancel for HgDiffCommand. Renamed execute method
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
630
diff
changeset
|
36 * Despite both 'hg diff' and this command are diff-based, implementation |
54e16ab771ec
Progress/cancel for HgDiffCommand. Renamed execute method
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
630
diff
changeset
|
37 * peculiarities may lead to slightly different diff results. Either is valid |
54e16ab771ec
Progress/cancel for HgDiffCommand. Renamed execute method
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
630
diff
changeset
|
38 * as there's no strict diff specification. |
54e16ab771ec
Progress/cancel for HgDiffCommand. Renamed execute method
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
630
diff
changeset
|
39 * |
54e16ab771ec
Progress/cancel for HgDiffCommand. Renamed execute method
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
630
diff
changeset
|
40 * <p> |
54e16ab771ec
Progress/cancel for HgDiffCommand. Renamed execute method
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
630
diff
changeset
|
41 * <strong>Note</strong>, at the moment this command annotates single file only. Diff over |
54e16ab771ec
Progress/cancel for HgDiffCommand. Renamed execute method
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
630
diff
changeset
|
42 * complete repository (all the file changed in a given changeset) might |
54e16ab771ec
Progress/cancel for HgDiffCommand. Renamed execute method
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
630
diff
changeset
|
43 * be added later. |
629
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
44 * |
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
45 * @since 1.1 |
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
46 * @author Artem Tikhomirov |
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
47 * @author TMate Software Ltd. |
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
48 */ |
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
49 public class HgDiffCommand extends HgAbstractCommand<HgDiffCommand> { |
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
50 |
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
51 private final HgRepository repo; |
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
52 private HgDataFile df; |
630
72c979555cb8
HgDiffCommand. Do not use deprecated code. Javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
629
diff
changeset
|
53 private final CsetParamKeeper clogRevIndexStart, clogRevIndexEnd; |
629
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
54 private HgIterateDirection iterateDirection = HgIterateDirection.NewToOld; |
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
55 |
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
56 public HgDiffCommand(HgRepository hgRepo) { |
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
57 repo = hgRepo; |
630
72c979555cb8
HgDiffCommand. Do not use deprecated code. Javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
629
diff
changeset
|
58 clogRevIndexStart = new CsetParamKeeper(hgRepo); |
72c979555cb8
HgDiffCommand. Do not use deprecated code. Javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
629
diff
changeset
|
59 clogRevIndexEnd = new CsetParamKeeper(hgRepo); |
629
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
60 } |
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
61 |
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
62 public HgDiffCommand file(Path file) { |
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
63 df = repo.getFileNode(file); |
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
64 return this; |
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
65 } |
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
66 |
630
72c979555cb8
HgDiffCommand. Do not use deprecated code. Javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
629
diff
changeset
|
67 /** |
72c979555cb8
HgDiffCommand. Do not use deprecated code. Javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
629
diff
changeset
|
68 * Selects the file which history to blame, mandatory. |
72c979555cb8
HgDiffCommand. Do not use deprecated code. Javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
629
diff
changeset
|
69 * |
72c979555cb8
HgDiffCommand. Do not use deprecated code. Javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
629
diff
changeset
|
70 * @param file repository file |
72c979555cb8
HgDiffCommand. Do not use deprecated code. Javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
629
diff
changeset
|
71 * @return <code>this</code> for convenience |
72c979555cb8
HgDiffCommand. Do not use deprecated code. Javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
629
diff
changeset
|
72 */ |
629
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
73 public HgDiffCommand file(HgDataFile file) { |
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
74 df = file; |
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
75 return this; |
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
76 } |
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
77 |
630
72c979555cb8
HgDiffCommand. Do not use deprecated code. Javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
629
diff
changeset
|
78 /** |
72c979555cb8
HgDiffCommand. Do not use deprecated code. Javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
629
diff
changeset
|
79 * Select range of file's history for {@link #executeDiff(HgBlameInspector)} |
72c979555cb8
HgDiffCommand. Do not use deprecated code. Javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
629
diff
changeset
|
80 * and {@link #executeAnnotate(HgBlameInspector)}. |
72c979555cb8
HgDiffCommand. Do not use deprecated code. Javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
629
diff
changeset
|
81 * <p> |
72c979555cb8
HgDiffCommand. Do not use deprecated code. Javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
629
diff
changeset
|
82 * {@link #executeDiff(HgBlameInspector) diff} uses these as revisions to diff against each other, while |
72c979555cb8
HgDiffCommand. Do not use deprecated code. Javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
629
diff
changeset
|
83 * {@link #executeAnnotate(HgBlameInspector) annotate} walks the range. |
72c979555cb8
HgDiffCommand. Do not use deprecated code. Javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
629
diff
changeset
|
84 * |
72c979555cb8
HgDiffCommand. Do not use deprecated code. Javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
629
diff
changeset
|
85 * @param changelogRevIndexStart index of changelog revision, left range boundary |
72c979555cb8
HgDiffCommand. Do not use deprecated code. Javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
629
diff
changeset
|
86 * @param changelogRevIndexEnd index of changelog revision, right range boundary |
72c979555cb8
HgDiffCommand. Do not use deprecated code. Javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
629
diff
changeset
|
87 * @return <code>this</code> for convenience |
72c979555cb8
HgDiffCommand. Do not use deprecated code. Javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
629
diff
changeset
|
88 * @throws HgBadArgumentException if failed to find any of supplied changeset |
72c979555cb8
HgDiffCommand. Do not use deprecated code. Javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
629
diff
changeset
|
89 */ |
72c979555cb8
HgDiffCommand. Do not use deprecated code. Javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
629
diff
changeset
|
90 public HgDiffCommand range(int changelogRevIndexStart, int changelogRevIndexEnd) throws HgBadArgumentException { |
72c979555cb8
HgDiffCommand. Do not use deprecated code. Javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
629
diff
changeset
|
91 clogRevIndexStart.set(changelogRevIndexStart); |
72c979555cb8
HgDiffCommand. Do not use deprecated code. Javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
629
diff
changeset
|
92 clogRevIndexEnd.set(changelogRevIndexEnd); |
629
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
93 return this; |
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
94 } |
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
95 |
630
72c979555cb8
HgDiffCommand. Do not use deprecated code. Javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
629
diff
changeset
|
96 /** |
632
54e16ab771ec
Progress/cancel for HgDiffCommand. Renamed execute method
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
630
diff
changeset
|
97 * Selects revision for {@link #executeParentsAnnotate(HgBlameInspector)}, the one |
630
72c979555cb8
HgDiffCommand. Do not use deprecated code. Javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
629
diff
changeset
|
98 * to diff against its parents. |
72c979555cb8
HgDiffCommand. Do not use deprecated code. Javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
629
diff
changeset
|
99 * |
72c979555cb8
HgDiffCommand. Do not use deprecated code. Javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
629
diff
changeset
|
100 * Besides, it is handy when range of interest spans up to the very beginning of the file history |
72c979555cb8
HgDiffCommand. Do not use deprecated code. Javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
629
diff
changeset
|
101 * (and thus is equivalent to <code>range(0, changelogRevIndex)</code>) |
72c979555cb8
HgDiffCommand. Do not use deprecated code. Javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
629
diff
changeset
|
102 * |
72c979555cb8
HgDiffCommand. Do not use deprecated code. Javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
629
diff
changeset
|
103 * @param changelogRevIndex index of changelog revision |
72c979555cb8
HgDiffCommand. Do not use deprecated code. Javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
629
diff
changeset
|
104 * @return <code>this</code> for convenience |
72c979555cb8
HgDiffCommand. Do not use deprecated code. Javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
629
diff
changeset
|
105 * @throws HgBadArgumentException if failed to find supplied changeset |
72c979555cb8
HgDiffCommand. Do not use deprecated code. Javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
629
diff
changeset
|
106 */ |
72c979555cb8
HgDiffCommand. Do not use deprecated code. Javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
629
diff
changeset
|
107 public HgDiffCommand changeset(int changelogRevIndex) throws HgBadArgumentException { |
72c979555cb8
HgDiffCommand. Do not use deprecated code. Javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
629
diff
changeset
|
108 clogRevIndexStart.set(0); |
72c979555cb8
HgDiffCommand. Do not use deprecated code. Javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
629
diff
changeset
|
109 clogRevIndexEnd.set(changelogRevIndex); |
629
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
110 return this; |
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
111 } |
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
112 |
630
72c979555cb8
HgDiffCommand. Do not use deprecated code. Javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
629
diff
changeset
|
113 /** |
72c979555cb8
HgDiffCommand. Do not use deprecated code. Javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
629
diff
changeset
|
114 * Revision differences are reported in selected order when |
72c979555cb8
HgDiffCommand. Do not use deprecated code. Javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
629
diff
changeset
|
115 * annotating {@link #range(int, int) range} of changesets with |
72c979555cb8
HgDiffCommand. Do not use deprecated code. Javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
629
diff
changeset
|
116 * {@link #executeAnnotate(HgBlameInspector)}. |
72c979555cb8
HgDiffCommand. Do not use deprecated code. Javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
629
diff
changeset
|
117 * <p> |
632
54e16ab771ec
Progress/cancel for HgDiffCommand. Renamed execute method
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
630
diff
changeset
|
118 * This method doesn't affect {@link #executeParentsAnnotate(HgBlameInspector)} and |
630
72c979555cb8
HgDiffCommand. Do not use deprecated code. Javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
629
diff
changeset
|
119 * {@link #executeDiff(HgBlameInspector)} |
72c979555cb8
HgDiffCommand. Do not use deprecated code. Javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
629
diff
changeset
|
120 * |
72c979555cb8
HgDiffCommand. Do not use deprecated code. Javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
629
diff
changeset
|
121 * @param order desired iteration order |
72c979555cb8
HgDiffCommand. Do not use deprecated code. Javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
629
diff
changeset
|
122 * @return <code>this</code> for convenience |
72c979555cb8
HgDiffCommand. Do not use deprecated code. Javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
629
diff
changeset
|
123 */ |
629
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
124 public HgDiffCommand order(HgIterateDirection order) { |
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
125 iterateDirection = order; |
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
126 return this; |
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
127 } |
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
128 |
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
129 /** |
630
72c979555cb8
HgDiffCommand. Do not use deprecated code. Javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
629
diff
changeset
|
130 * Diff two revisions selected with {@link #range(int, int)} against each other. |
72c979555cb8
HgDiffCommand. Do not use deprecated code. Javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
629
diff
changeset
|
131 * <p>mimics 'hg diff -r clogRevIndex1 -r clogRevIndex2' |
72c979555cb8
HgDiffCommand. Do not use deprecated code. Javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
629
diff
changeset
|
132 * |
72c979555cb8
HgDiffCommand. Do not use deprecated code. Javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
629
diff
changeset
|
133 * @throws HgCallbackTargetException propagated exception from the handler |
72c979555cb8
HgDiffCommand. Do not use deprecated code. Javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
629
diff
changeset
|
134 * @throws CancelledException if execution of the command was cancelled |
72c979555cb8
HgDiffCommand. Do not use deprecated code. Javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
629
diff
changeset
|
135 * @throws HgException subclass thereof to indicate specific issue with the command arguments or repository state |
629
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
136 */ |
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
137 public void executeDiff(HgBlameInspector insp) throws HgCallbackTargetException, CancelledException, HgException { |
630
72c979555cb8
HgDiffCommand. Do not use deprecated code. Javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
629
diff
changeset
|
138 checkFile(); |
632
54e16ab771ec
Progress/cancel for HgDiffCommand. Renamed execute method
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
630
diff
changeset
|
139 final ProgressSupport progress = getProgressSupport(insp); |
54e16ab771ec
Progress/cancel for HgDiffCommand. Renamed execute method
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
630
diff
changeset
|
140 progress.start(2); |
629
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
141 try { |
632
54e16ab771ec
Progress/cancel for HgDiffCommand. Renamed execute method
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
630
diff
changeset
|
142 final CancelSupport cancel = getCancelSupport(insp, true); |
630
72c979555cb8
HgDiffCommand. Do not use deprecated code. Javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
629
diff
changeset
|
143 int fileRevIndex1 = fileRevIndex(df, clogRevIndexStart.get()); |
72c979555cb8
HgDiffCommand. Do not use deprecated code. Javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
629
diff
changeset
|
144 int fileRevIndex2 = fileRevIndex(df, clogRevIndexEnd.get()); |
629
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
145 BlameHelper bh = new BlameHelper(insp); |
630
72c979555cb8
HgDiffCommand. Do not use deprecated code. Javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
629
diff
changeset
|
146 bh.prepare(df, clogRevIndexStart.get(), clogRevIndexEnd.get()); |
632
54e16ab771ec
Progress/cancel for HgDiffCommand. Renamed execute method
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
630
diff
changeset
|
147 progress.worked(1); |
54e16ab771ec
Progress/cancel for HgDiffCommand. Renamed execute method
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
630
diff
changeset
|
148 cancel.checkCancelled(); |
630
72c979555cb8
HgDiffCommand. Do not use deprecated code. Javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
629
diff
changeset
|
149 bh.diff(fileRevIndex1, clogRevIndexStart.get(), fileRevIndex2, clogRevIndexEnd.get()); |
632
54e16ab771ec
Progress/cancel for HgDiffCommand. Renamed execute method
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
630
diff
changeset
|
150 progress.worked(1); |
54e16ab771ec
Progress/cancel for HgDiffCommand. Renamed execute method
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
630
diff
changeset
|
151 cancel.checkCancelled(); |
629
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
152 } catch (HgRuntimeException ex) { |
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
153 throw new HgLibraryFailureException(ex); |
632
54e16ab771ec
Progress/cancel for HgDiffCommand. Renamed execute method
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
630
diff
changeset
|
154 } finally { |
54e16ab771ec
Progress/cancel for HgDiffCommand. Renamed execute method
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
630
diff
changeset
|
155 progress.done(); |
629
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
156 } |
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
157 } |
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
158 |
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
159 /** |
630
72c979555cb8
HgDiffCommand. Do not use deprecated code. Javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
629
diff
changeset
|
160 * Walk file history {@link #range(int, int) range} and report changes (diff) for each revision |
72c979555cb8
HgDiffCommand. Do not use deprecated code. Javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
629
diff
changeset
|
161 * |
72c979555cb8
HgDiffCommand. Do not use deprecated code. Javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
629
diff
changeset
|
162 * @throws HgCallbackTargetException propagated exception from the handler |
72c979555cb8
HgDiffCommand. Do not use deprecated code. Javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
629
diff
changeset
|
163 * @throws CancelledException if execution of the command was cancelled |
72c979555cb8
HgDiffCommand. Do not use deprecated code. Javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
629
diff
changeset
|
164 * @throws HgException subclass thereof to indicate specific issue with the command arguments or repository state |
629
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
165 */ |
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
166 public void executeAnnotate(HgBlameInspector insp) throws HgCallbackTargetException, CancelledException, HgException { |
630
72c979555cb8
HgDiffCommand. Do not use deprecated code. Javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
629
diff
changeset
|
167 checkFile(); |
632
54e16ab771ec
Progress/cancel for HgDiffCommand. Renamed execute method
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
630
diff
changeset
|
168 ProgressSupport progress = null; |
629
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
169 try { |
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
170 if (!df.exists()) { |
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
171 return; |
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
172 } |
632
54e16ab771ec
Progress/cancel for HgDiffCommand. Renamed execute method
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
630
diff
changeset
|
173 final CancelSupport cancel = getCancelSupport(insp, true); |
629
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
174 BlameHelper bh = new BlameHelper(insp); |
630
72c979555cb8
HgDiffCommand. Do not use deprecated code. Javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
629
diff
changeset
|
175 FileHistory fileHistory = bh.prepare(df, clogRevIndexStart.get(), clogRevIndexEnd.get()); |
632
54e16ab771ec
Progress/cancel for HgDiffCommand. Renamed execute method
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
630
diff
changeset
|
176 // |
54e16ab771ec
Progress/cancel for HgDiffCommand. Renamed execute method
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
630
diff
changeset
|
177 cancel.checkCancelled(); |
54e16ab771ec
Progress/cancel for HgDiffCommand. Renamed execute method
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
630
diff
changeset
|
178 int totalWork = 0; |
54e16ab771ec
Progress/cancel for HgDiffCommand. Renamed execute method
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
630
diff
changeset
|
179 for (FileRevisionHistoryChunk fhc : fileHistory.iterate(iterateDirection)) { |
54e16ab771ec
Progress/cancel for HgDiffCommand. Renamed execute method
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
630
diff
changeset
|
180 totalWork += fhc.revisionCount(); |
54e16ab771ec
Progress/cancel for HgDiffCommand. Renamed execute method
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
630
diff
changeset
|
181 } |
54e16ab771ec
Progress/cancel for HgDiffCommand. Renamed execute method
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
630
diff
changeset
|
182 progress = getProgressSupport(insp); |
54e16ab771ec
Progress/cancel for HgDiffCommand. Renamed execute method
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
630
diff
changeset
|
183 progress.start(totalWork + 1); |
54e16ab771ec
Progress/cancel for HgDiffCommand. Renamed execute method
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
630
diff
changeset
|
184 progress.worked(1); // BlameHelper.prepare |
54e16ab771ec
Progress/cancel for HgDiffCommand. Renamed execute method
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
630
diff
changeset
|
185 // |
629
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
186 int[] fileClogParentRevs = new int[2]; |
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
187 int[] fileParentRevs = new int[2]; |
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
188 for (FileRevisionHistoryChunk fhc : fileHistory.iterate(iterateDirection)) { |
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
189 for (int fri : fhc.fileRevisions(iterateDirection)) { |
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
190 int clogRevIndex = fhc.changeset(fri); |
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
191 // the way we built fileHistory ensures we won't walk past [changelogRevIndexStart..changelogRevIndexEnd] |
630
72c979555cb8
HgDiffCommand. Do not use deprecated code. Javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
629
diff
changeset
|
192 assert clogRevIndex >= clogRevIndexStart.get(); |
72c979555cb8
HgDiffCommand. Do not use deprecated code. Javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
629
diff
changeset
|
193 assert clogRevIndex <= clogRevIndexEnd.get(); |
629
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
194 fhc.fillFileParents(fri, fileParentRevs); |
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
195 fhc.fillCsetParents(fri, fileClogParentRevs); |
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
196 bh.annotateChange(fri, clogRevIndex, fileParentRevs, fileClogParentRevs); |
632
54e16ab771ec
Progress/cancel for HgDiffCommand. Renamed execute method
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
630
diff
changeset
|
197 progress.worked(1); |
54e16ab771ec
Progress/cancel for HgDiffCommand. Renamed execute method
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
630
diff
changeset
|
198 cancel.checkCancelled(); |
629
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
199 } |
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
200 } |
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
201 } catch (HgRuntimeException ex) { |
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
202 throw new HgLibraryFailureException(ex); |
632
54e16ab771ec
Progress/cancel for HgDiffCommand. Renamed execute method
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
630
diff
changeset
|
203 } finally { |
54e16ab771ec
Progress/cancel for HgDiffCommand. Renamed execute method
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
630
diff
changeset
|
204 if (progress != null) { |
54e16ab771ec
Progress/cancel for HgDiffCommand. Renamed execute method
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
630
diff
changeset
|
205 progress.done(); |
54e16ab771ec
Progress/cancel for HgDiffCommand. Renamed execute method
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
630
diff
changeset
|
206 } |
629
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
207 } |
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
208 } |
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
209 |
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
210 /** |
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
211 * Annotates changes of the file against its parent(s). |
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
212 * Unlike {@link #annotate(HgDataFile, int, Inspector, HgIterateDirection)}, doesn't |
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
213 * walk file history, looks at the specified revision only. Handles both parents (if merge revision). |
630
72c979555cb8
HgDiffCommand. Do not use deprecated code. Javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
629
diff
changeset
|
214 * |
72c979555cb8
HgDiffCommand. Do not use deprecated code. Javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
629
diff
changeset
|
215 * @throws HgCallbackTargetException propagated exception from the handler |
72c979555cb8
HgDiffCommand. Do not use deprecated code. Javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
629
diff
changeset
|
216 * @throws CancelledException if execution of the command was cancelled |
72c979555cb8
HgDiffCommand. Do not use deprecated code. Javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
629
diff
changeset
|
217 * @throws HgException subclass thereof to indicate specific issue with the command arguments or repository state |
629
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
218 */ |
632
54e16ab771ec
Progress/cancel for HgDiffCommand. Renamed execute method
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
630
diff
changeset
|
219 public void executeParentsAnnotate(HgBlameInspector insp) throws HgCallbackTargetException, CancelledException, HgException { |
630
72c979555cb8
HgDiffCommand. Do not use deprecated code. Javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
629
diff
changeset
|
220 checkFile(); |
632
54e16ab771ec
Progress/cancel for HgDiffCommand. Renamed execute method
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
630
diff
changeset
|
221 final ProgressSupport progress = getProgressSupport(insp); |
54e16ab771ec
Progress/cancel for HgDiffCommand. Renamed execute method
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
630
diff
changeset
|
222 progress.start(2); |
629
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
223 try { |
632
54e16ab771ec
Progress/cancel for HgDiffCommand. Renamed execute method
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
630
diff
changeset
|
224 final CancelSupport cancel = getCancelSupport(insp, true); |
630
72c979555cb8
HgDiffCommand. Do not use deprecated code. Javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
629
diff
changeset
|
225 int changelogRevisionIndex = clogRevIndexEnd.get(); |
629
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
226 // TODO detect if file is text/binary (e.g. looking for chars < ' ' and not \t\r\n\f |
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
227 int fileRevIndex = fileRevIndex(df, changelogRevisionIndex); |
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
228 int[] fileRevParents = new int[2]; |
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
229 df.parents(fileRevIndex, fileRevParents, null, null); |
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
230 if (changelogRevisionIndex == TIP) { |
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
231 changelogRevisionIndex = df.getChangesetRevisionIndex(fileRevIndex); |
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
232 } |
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
233 int[] fileClogParentRevs = new int[2]; |
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
234 fileClogParentRevs[0] = fileRevParents[0] == NO_REVISION ? NO_REVISION : df.getChangesetRevisionIndex(fileRevParents[0]); |
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
235 fileClogParentRevs[1] = fileRevParents[1] == NO_REVISION ? NO_REVISION : df.getChangesetRevisionIndex(fileRevParents[1]); |
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
236 BlameHelper bh = new BlameHelper(insp); |
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
237 int clogIndexStart = fileClogParentRevs[0] == NO_REVISION ? (fileClogParentRevs[1] == NO_REVISION ? 0 : fileClogParentRevs[1]) : fileClogParentRevs[0]; |
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
238 bh.prepare(df, clogIndexStart, changelogRevisionIndex); |
632
54e16ab771ec
Progress/cancel for HgDiffCommand. Renamed execute method
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
630
diff
changeset
|
239 progress.worked(1); |
54e16ab771ec
Progress/cancel for HgDiffCommand. Renamed execute method
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
630
diff
changeset
|
240 cancel.checkCancelled(); |
629
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
241 bh.annotateChange(fileRevIndex, changelogRevisionIndex, fileRevParents, fileClogParentRevs); |
632
54e16ab771ec
Progress/cancel for HgDiffCommand. Renamed execute method
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
630
diff
changeset
|
242 progress.worked(1); |
54e16ab771ec
Progress/cancel for HgDiffCommand. Renamed execute method
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
630
diff
changeset
|
243 cancel.checkCancelled(); |
629
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
244 } catch (HgRuntimeException ex) { |
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
245 throw new HgLibraryFailureException(ex); |
632
54e16ab771ec
Progress/cancel for HgDiffCommand. Renamed execute method
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
630
diff
changeset
|
246 } finally { |
54e16ab771ec
Progress/cancel for HgDiffCommand. Renamed execute method
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
630
diff
changeset
|
247 progress.done(); |
629
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
248 } |
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
249 } |
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
250 |
630
72c979555cb8
HgDiffCommand. Do not use deprecated code. Javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
629
diff
changeset
|
251 private void checkFile() { |
72c979555cb8
HgDiffCommand. Do not use deprecated code. Javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
629
diff
changeset
|
252 if (df == null) { |
72c979555cb8
HgDiffCommand. Do not use deprecated code. Javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
629
diff
changeset
|
253 throw new IllegalArgumentException("File is not set"); |
72c979555cb8
HgDiffCommand. Do not use deprecated code. Javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
629
diff
changeset
|
254 } |
72c979555cb8
HgDiffCommand. Do not use deprecated code. Javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
629
diff
changeset
|
255 } |
629
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
256 |
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
257 private static int fileRevIndex(HgDataFile df, int csetRevIndex) throws HgRuntimeException { |
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
258 Nodeid fileRev = df.getRepo().getManifest().getFileRevision(csetRevIndex, df.getPath()); |
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
259 return df.getRevisionIndex(fileRev); |
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
260 } |
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
261 } |