Mercurial > hg4j
annotate src/org/tmatesoft/hg/core/HgDiffCommand.java @ 713:661e77dc88ba tip
Mac support: respect Mac alternatives of command-line arguments for common unix tools
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Sun, 03 Aug 2014 18:09:00 +0200 |
parents | 497e697636fc |
children |
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 |
630
72c979555cb8
HgDiffCommand. Do not use deprecated code. Javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
629
diff
changeset
|
22 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
|
23 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
|
24 import org.tmatesoft.hg.internal.FileRevisionHistoryChunk; |
703
7839ff0bfd78
Refactor: move diff/blame related code to a separate package
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
683
diff
changeset
|
25 import org.tmatesoft.hg.internal.diff.BlameHelper; |
629
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 /** |
683
98ff1fb49abe
Update commands to use changeset Nodeid and int in uniform way, clients of core.* classes shall not go back and forth from int to Nodeid
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
675
diff
changeset
|
97 * Select range of file history, limited by changesets. |
98ff1fb49abe
Update commands to use changeset Nodeid and int in uniform way, clients of core.* classes shall not go back and forth from int to Nodeid
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
675
diff
changeset
|
98 * @see #range(int, int) |
98ff1fb49abe
Update commands to use changeset Nodeid and int in uniform way, clients of core.* classes shall not go back and forth from int to Nodeid
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
675
diff
changeset
|
99 * @param cset1 changelog revision, left range boundary |
98ff1fb49abe
Update commands to use changeset Nodeid and int in uniform way, clients of core.* classes shall not go back and forth from int to Nodeid
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
675
diff
changeset
|
100 * @param cset2 changelog revision, right range boundary |
98ff1fb49abe
Update commands to use changeset Nodeid and int in uniform way, clients of core.* classes shall not go back and forth from int to Nodeid
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
675
diff
changeset
|
101 * @return <code>this</code> for convenience |
98ff1fb49abe
Update commands to use changeset Nodeid and int in uniform way, clients of core.* classes shall not go back and forth from int to Nodeid
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
675
diff
changeset
|
102 * @throws HgBadArgumentException if revisions are not valid changeset identifiers |
98ff1fb49abe
Update commands to use changeset Nodeid and int in uniform way, clients of core.* classes shall not go back and forth from int to Nodeid
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
675
diff
changeset
|
103 */ |
98ff1fb49abe
Update commands to use changeset Nodeid and int in uniform way, clients of core.* classes shall not go back and forth from int to Nodeid
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
675
diff
changeset
|
104 public HgDiffCommand range(Nodeid cset1, Nodeid cset2) throws HgBadArgumentException { |
98ff1fb49abe
Update commands to use changeset Nodeid and int in uniform way, clients of core.* classes shall not go back and forth from int to Nodeid
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
675
diff
changeset
|
105 clogRevIndexStart.set(cset1); |
98ff1fb49abe
Update commands to use changeset Nodeid and int in uniform way, clients of core.* classes shall not go back and forth from int to Nodeid
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
675
diff
changeset
|
106 clogRevIndexEnd.set(cset2); |
98ff1fb49abe
Update commands to use changeset Nodeid and int in uniform way, clients of core.* classes shall not go back and forth from int to Nodeid
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
675
diff
changeset
|
107 return this; |
98ff1fb49abe
Update commands to use changeset Nodeid and int in uniform way, clients of core.* classes shall not go back and forth from int to Nodeid
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
675
diff
changeset
|
108 } |
98ff1fb49abe
Update commands to use changeset Nodeid and int in uniform way, clients of core.* classes shall not go back and forth from int to Nodeid
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
675
diff
changeset
|
109 |
98ff1fb49abe
Update commands to use changeset Nodeid and int in uniform way, clients of core.* classes shall not go back and forth from int to Nodeid
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
675
diff
changeset
|
110 /** |
632
54e16ab771ec
Progress/cancel for HgDiffCommand. Renamed execute method
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
630
diff
changeset
|
111 * 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
|
112 * to diff against its parents. |
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 * 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
|
115 * (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
|
116 * |
72c979555cb8
HgDiffCommand. Do not use deprecated code. Javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
629
diff
changeset
|
117 * @param changelogRevIndex index of changelog revision |
72c979555cb8
HgDiffCommand. Do not use deprecated code. Javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
629
diff
changeset
|
118 * @return <code>this</code> for convenience |
72c979555cb8
HgDiffCommand. Do not use deprecated code. Javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
629
diff
changeset
|
119 * @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
|
120 */ |
72c979555cb8
HgDiffCommand. Do not use deprecated code. Javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
629
diff
changeset
|
121 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
|
122 clogRevIndexStart.set(0); |
72c979555cb8
HgDiffCommand. Do not use deprecated code. Javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
629
diff
changeset
|
123 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
|
124 return this; |
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
125 } |
683
98ff1fb49abe
Update commands to use changeset Nodeid and int in uniform way, clients of core.* classes shall not go back and forth from int to Nodeid
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
675
diff
changeset
|
126 |
98ff1fb49abe
Update commands to use changeset Nodeid and int in uniform way, clients of core.* classes shall not go back and forth from int to Nodeid
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
675
diff
changeset
|
127 /** |
98ff1fb49abe
Update commands to use changeset Nodeid and int in uniform way, clients of core.* classes shall not go back and forth from int to Nodeid
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
675
diff
changeset
|
128 * Select specific changeset or a range [0..changeset], like {@link #changeset(int)} |
98ff1fb49abe
Update commands to use changeset Nodeid and int in uniform way, clients of core.* classes shall not go back and forth from int to Nodeid
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
675
diff
changeset
|
129 * |
98ff1fb49abe
Update commands to use changeset Nodeid and int in uniform way, clients of core.* classes shall not go back and forth from int to Nodeid
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
675
diff
changeset
|
130 * @param nid changeset |
98ff1fb49abe
Update commands to use changeset Nodeid and int in uniform way, clients of core.* classes shall not go back and forth from int to Nodeid
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
675
diff
changeset
|
131 * @return <code>this</code> for convenience |
98ff1fb49abe
Update commands to use changeset Nodeid and int in uniform way, clients of core.* classes shall not go back and forth from int to Nodeid
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
675
diff
changeset
|
132 * @throws HgBadArgumentException if failed to find supplied changeset revision |
98ff1fb49abe
Update commands to use changeset Nodeid and int in uniform way, clients of core.* classes shall not go back and forth from int to Nodeid
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
675
diff
changeset
|
133 */ |
98ff1fb49abe
Update commands to use changeset Nodeid and int in uniform way, clients of core.* classes shall not go back and forth from int to Nodeid
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
675
diff
changeset
|
134 public HgDiffCommand changeset(Nodeid nid) throws HgBadArgumentException { |
98ff1fb49abe
Update commands to use changeset Nodeid and int in uniform way, clients of core.* classes shall not go back and forth from int to Nodeid
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
675
diff
changeset
|
135 clogRevIndexStart.set(0); |
98ff1fb49abe
Update commands to use changeset Nodeid and int in uniform way, clients of core.* classes shall not go back and forth from int to Nodeid
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
675
diff
changeset
|
136 clogRevIndexEnd.set(nid); |
98ff1fb49abe
Update commands to use changeset Nodeid and int in uniform way, clients of core.* classes shall not go back and forth from int to Nodeid
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
675
diff
changeset
|
137 return this; |
98ff1fb49abe
Update commands to use changeset Nodeid and int in uniform way, clients of core.* classes shall not go back and forth from int to Nodeid
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
675
diff
changeset
|
138 } |
98ff1fb49abe
Update commands to use changeset Nodeid and int in uniform way, clients of core.* classes shall not go back and forth from int to Nodeid
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
675
diff
changeset
|
139 |
629
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
140 |
630
72c979555cb8
HgDiffCommand. Do not use deprecated code. Javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
629
diff
changeset
|
141 /** |
72c979555cb8
HgDiffCommand. Do not use deprecated code. Javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
629
diff
changeset
|
142 * 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
|
143 * 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
|
144 * {@link #executeAnnotate(HgBlameInspector)}. |
72c979555cb8
HgDiffCommand. Do not use deprecated code. Javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
629
diff
changeset
|
145 * <p> |
632
54e16ab771ec
Progress/cancel for HgDiffCommand. Renamed execute method
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
630
diff
changeset
|
146 * 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
|
147 * {@link #executeDiff(HgBlameInspector)} |
72c979555cb8
HgDiffCommand. Do not use deprecated code. Javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
629
diff
changeset
|
148 * |
72c979555cb8
HgDiffCommand. Do not use deprecated code. Javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
629
diff
changeset
|
149 * @param order desired iteration order |
72c979555cb8
HgDiffCommand. Do not use deprecated code. Javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
629
diff
changeset
|
150 * @return <code>this</code> for convenience |
72c979555cb8
HgDiffCommand. Do not use deprecated code. Javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
629
diff
changeset
|
151 */ |
629
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
152 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
|
153 iterateDirection = order; |
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
154 return this; |
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
155 } |
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 /** |
630
72c979555cb8
HgDiffCommand. Do not use deprecated code. Javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
629
diff
changeset
|
158 * 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
|
159 * <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
|
160 * |
72c979555cb8
HgDiffCommand. Do not use deprecated code. Javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
629
diff
changeset
|
161 * @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
|
162 * @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
|
163 * @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
|
164 */ |
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
165 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
|
166 checkFile(); |
632
54e16ab771ec
Progress/cancel for HgDiffCommand. Renamed execute method
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
630
diff
changeset
|
167 final ProgressSupport progress = getProgressSupport(insp); |
54e16ab771ec
Progress/cancel for HgDiffCommand. Renamed execute method
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
630
diff
changeset
|
168 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
|
169 try { |
675
a20121a2bba6
Respect default range (0..tip)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
632
diff
changeset
|
170 final int startRevIndex = clogRevIndexStart.get(0); |
a20121a2bba6
Respect default range (0..tip)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
632
diff
changeset
|
171 final int endRevIndex = clogRevIndexEnd.get(TIP); |
632
54e16ab771ec
Progress/cancel for HgDiffCommand. Renamed execute method
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
630
diff
changeset
|
172 final CancelSupport cancel = getCancelSupport(insp, true); |
675
a20121a2bba6
Respect default range (0..tip)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
632
diff
changeset
|
173 int fileRevIndex1 = fileRevIndex(df, startRevIndex); |
a20121a2bba6
Respect default range (0..tip)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
632
diff
changeset
|
174 int fileRevIndex2 = fileRevIndex(df, endRevIndex); |
629
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
175 BlameHelper bh = new BlameHelper(insp); |
675
a20121a2bba6
Respect default range (0..tip)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
632
diff
changeset
|
176 bh.prepare(df, startRevIndex, endRevIndex); |
632
54e16ab771ec
Progress/cancel for HgDiffCommand. Renamed execute method
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
630
diff
changeset
|
177 progress.worked(1); |
54e16ab771ec
Progress/cancel for HgDiffCommand. Renamed execute method
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
630
diff
changeset
|
178 cancel.checkCancelled(); |
675
a20121a2bba6
Respect default range (0..tip)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
632
diff
changeset
|
179 bh.diff(fileRevIndex1, startRevIndex, fileRevIndex2, endRevIndex); |
632
54e16ab771ec
Progress/cancel for HgDiffCommand. Renamed execute method
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
630
diff
changeset
|
180 progress.worked(1); |
54e16ab771ec
Progress/cancel for HgDiffCommand. Renamed execute method
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
630
diff
changeset
|
181 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
|
182 } 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
|
183 throw new HgLibraryFailureException(ex); |
632
54e16ab771ec
Progress/cancel for HgDiffCommand. Renamed execute method
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
630
diff
changeset
|
184 } finally { |
54e16ab771ec
Progress/cancel for HgDiffCommand. Renamed execute method
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
630
diff
changeset
|
185 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
|
186 } |
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
187 } |
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
188 |
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
189 /** |
630
72c979555cb8
HgDiffCommand. Do not use deprecated code. Javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
629
diff
changeset
|
190 * 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
|
191 * |
72c979555cb8
HgDiffCommand. Do not use deprecated code. Javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
629
diff
changeset
|
192 * @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
|
193 * @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
|
194 * @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
|
195 */ |
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
196 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
|
197 checkFile(); |
632
54e16ab771ec
Progress/cancel for HgDiffCommand. Renamed execute method
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
630
diff
changeset
|
198 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
|
199 try { |
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
200 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
|
201 return; |
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
202 } |
632
54e16ab771ec
Progress/cancel for HgDiffCommand. Renamed execute method
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
630
diff
changeset
|
203 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
|
204 BlameHelper bh = new BlameHelper(insp); |
675
a20121a2bba6
Respect default range (0..tip)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
632
diff
changeset
|
205 final int startRevIndex = clogRevIndexStart.get(0); |
a20121a2bba6
Respect default range (0..tip)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
632
diff
changeset
|
206 final int endRevIndex = clogRevIndexEnd.get(TIP); |
a20121a2bba6
Respect default range (0..tip)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
632
diff
changeset
|
207 FileHistory fileHistory = bh.prepare(df, startRevIndex, endRevIndex); |
632
54e16ab771ec
Progress/cancel for HgDiffCommand. Renamed execute method
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
630
diff
changeset
|
208 // |
54e16ab771ec
Progress/cancel for HgDiffCommand. Renamed execute method
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
630
diff
changeset
|
209 cancel.checkCancelled(); |
54e16ab771ec
Progress/cancel for HgDiffCommand. Renamed execute method
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
630
diff
changeset
|
210 int totalWork = 0; |
54e16ab771ec
Progress/cancel for HgDiffCommand. Renamed execute method
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
630
diff
changeset
|
211 for (FileRevisionHistoryChunk fhc : fileHistory.iterate(iterateDirection)) { |
54e16ab771ec
Progress/cancel for HgDiffCommand. Renamed execute method
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
630
diff
changeset
|
212 totalWork += fhc.revisionCount(); |
54e16ab771ec
Progress/cancel for HgDiffCommand. Renamed execute method
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
630
diff
changeset
|
213 } |
54e16ab771ec
Progress/cancel for HgDiffCommand. Renamed execute method
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
630
diff
changeset
|
214 progress = getProgressSupport(insp); |
54e16ab771ec
Progress/cancel for HgDiffCommand. Renamed execute method
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
630
diff
changeset
|
215 progress.start(totalWork + 1); |
54e16ab771ec
Progress/cancel for HgDiffCommand. Renamed execute method
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
630
diff
changeset
|
216 progress.worked(1); // BlameHelper.prepare |
54e16ab771ec
Progress/cancel for HgDiffCommand. Renamed execute method
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
630
diff
changeset
|
217 // |
629
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
218 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
|
219 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
|
220 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
|
221 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
|
222 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
|
223 // the way we built fileHistory ensures we won't walk past [changelogRevIndexStart..changelogRevIndexEnd] |
675
a20121a2bba6
Respect default range (0..tip)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
632
diff
changeset
|
224 assert clogRevIndex >= startRevIndex; |
a20121a2bba6
Respect default range (0..tip)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
632
diff
changeset
|
225 assert clogRevIndex <= endRevIndex; |
629
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
226 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
|
227 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
|
228 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
|
229 progress.worked(1); |
54e16ab771ec
Progress/cancel for HgDiffCommand. Renamed execute method
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
630
diff
changeset
|
230 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
|
231 } |
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 } 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
|
234 throw new HgLibraryFailureException(ex); |
632
54e16ab771ec
Progress/cancel for HgDiffCommand. Renamed execute method
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
630
diff
changeset
|
235 } finally { |
54e16ab771ec
Progress/cancel for HgDiffCommand. Renamed execute method
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
630
diff
changeset
|
236 if (progress != null) { |
54e16ab771ec
Progress/cancel for HgDiffCommand. Renamed execute method
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
630
diff
changeset
|
237 progress.done(); |
54e16ab771ec
Progress/cancel for HgDiffCommand. Renamed execute method
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
630
diff
changeset
|
238 } |
629
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
239 } |
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
240 } |
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
241 |
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
242 /** |
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
243 * 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
|
244 * 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
|
245 * 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
|
246 * |
72c979555cb8
HgDiffCommand. Do not use deprecated code. Javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
629
diff
changeset
|
247 * @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
|
248 * @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
|
249 * @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
|
250 */ |
632
54e16ab771ec
Progress/cancel for HgDiffCommand. Renamed execute method
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
630
diff
changeset
|
251 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
|
252 checkFile(); |
632
54e16ab771ec
Progress/cancel for HgDiffCommand. Renamed execute method
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
630
diff
changeset
|
253 final ProgressSupport progress = getProgressSupport(insp); |
54e16ab771ec
Progress/cancel for HgDiffCommand. Renamed execute method
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
630
diff
changeset
|
254 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
|
255 try { |
632
54e16ab771ec
Progress/cancel for HgDiffCommand. Renamed execute method
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
630
diff
changeset
|
256 final CancelSupport cancel = getCancelSupport(insp, true); |
709
497e697636fc
Report merged lines as changed block if possible, not as a sequence of added/deleted blocks. To facilitate access to merge parent lines AddBlock got mergeLineAt() method that reports index of the line in the second parent (if any), while insertedAt() has been changed to report index in the first parent always
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
703
diff
changeset
|
257 int changelogRevisionIndex = clogRevIndexEnd.get(TIP); |
629
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
258 // 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
|
259 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
|
260 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
|
261 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
|
262 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
|
263 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
|
264 } |
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
265 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
|
266 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
|
267 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
|
268 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
|
269 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
|
270 bh.prepare(df, clogIndexStart, changelogRevisionIndex); |
632
54e16ab771ec
Progress/cancel for HgDiffCommand. Renamed execute method
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
630
diff
changeset
|
271 progress.worked(1); |
54e16ab771ec
Progress/cancel for HgDiffCommand. Renamed execute method
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
630
diff
changeset
|
272 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
|
273 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
|
274 progress.worked(1); |
54e16ab771ec
Progress/cancel for HgDiffCommand. Renamed execute method
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
630
diff
changeset
|
275 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
|
276 } 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
|
277 throw new HgLibraryFailureException(ex); |
632
54e16ab771ec
Progress/cancel for HgDiffCommand. Renamed execute method
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
630
diff
changeset
|
278 } finally { |
54e16ab771ec
Progress/cancel for HgDiffCommand. Renamed execute method
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
630
diff
changeset
|
279 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
|
280 } |
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
281 } |
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
282 |
630
72c979555cb8
HgDiffCommand. Do not use deprecated code. Javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
629
diff
changeset
|
283 private void checkFile() { |
72c979555cb8
HgDiffCommand. Do not use deprecated code. Javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
629
diff
changeset
|
284 if (df == null) { |
72c979555cb8
HgDiffCommand. Do not use deprecated code. Javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
629
diff
changeset
|
285 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
|
286 } |
72c979555cb8
HgDiffCommand. Do not use deprecated code. Javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
629
diff
changeset
|
287 } |
629
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
288 |
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
289 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
|
290 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
|
291 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
|
292 } |
5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
293 } |