annotate src/org/tmatesoft/hg/core/HgDiffCommand.java @ 681:4f93bbc73b64

Do not instantiate thousands of small arrays(numerous readInt/readLong calls)
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Sun, 21 Jul 2013 17:48:05 +0200
parents a20121a2bba6
children 98ff1fb49abe
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 {
675
a20121a2bba6 Respect default range (0..tip)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 632
diff changeset
142 final int startRevIndex = clogRevIndexStart.get(0);
a20121a2bba6 Respect default range (0..tip)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 632
diff changeset
143 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
144 final CancelSupport cancel = getCancelSupport(insp, true);
675
a20121a2bba6 Respect default range (0..tip)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 632
diff changeset
145 int fileRevIndex1 = fileRevIndex(df, startRevIndex);
a20121a2bba6 Respect default range (0..tip)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 632
diff changeset
146 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
147 BlameHelper bh = new BlameHelper(insp);
675
a20121a2bba6 Respect default range (0..tip)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 632
diff changeset
148 bh.prepare(df, startRevIndex, endRevIndex);
632
54e16ab771ec Progress/cancel for HgDiffCommand. Renamed execute method
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 630
diff changeset
149 progress.worked(1);
54e16ab771ec Progress/cancel for HgDiffCommand. Renamed execute method
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 630
diff changeset
150 cancel.checkCancelled();
675
a20121a2bba6 Respect default range (0..tip)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 632
diff changeset
151 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
152 progress.worked(1);
54e16ab771ec Progress/cancel for HgDiffCommand. Renamed execute method
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 630
diff changeset
153 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
154 } 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
155 throw new HgLibraryFailureException(ex);
632
54e16ab771ec Progress/cancel for HgDiffCommand. Renamed execute method
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 630
diff changeset
156 } finally {
54e16ab771ec Progress/cancel for HgDiffCommand. Renamed execute method
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 630
diff changeset
157 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
158 }
5f52074707b2 Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
159 }
5f52074707b2 Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
160
5f52074707b2 Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
161 /**
630
72c979555cb8 HgDiffCommand. Do not use deprecated code. Javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 629
diff changeset
162 * 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
163 *
72c979555cb8 HgDiffCommand. Do not use deprecated code. Javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 629
diff changeset
164 * @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
165 * @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
166 * @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
167 */
5f52074707b2 Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
168 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
169 checkFile();
632
54e16ab771ec Progress/cancel for HgDiffCommand. Renamed execute method
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 630
diff changeset
170 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
171 try {
5f52074707b2 Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
172 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
173 return;
5f52074707b2 Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
174 }
632
54e16ab771ec Progress/cancel for HgDiffCommand. Renamed execute method
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 630
diff changeset
175 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
176 BlameHelper bh = new BlameHelper(insp);
675
a20121a2bba6 Respect default range (0..tip)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 632
diff changeset
177 final int startRevIndex = clogRevIndexStart.get(0);
a20121a2bba6 Respect default range (0..tip)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 632
diff changeset
178 final int endRevIndex = clogRevIndexEnd.get(TIP);
a20121a2bba6 Respect default range (0..tip)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 632
diff changeset
179 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
180 //
54e16ab771ec Progress/cancel for HgDiffCommand. Renamed execute method
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 630
diff changeset
181 cancel.checkCancelled();
54e16ab771ec Progress/cancel for HgDiffCommand. Renamed execute method
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 630
diff changeset
182 int totalWork = 0;
54e16ab771ec Progress/cancel for HgDiffCommand. Renamed execute method
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 630
diff changeset
183 for (FileRevisionHistoryChunk fhc : fileHistory.iterate(iterateDirection)) {
54e16ab771ec Progress/cancel for HgDiffCommand. Renamed execute method
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 630
diff changeset
184 totalWork += fhc.revisionCount();
54e16ab771ec Progress/cancel for HgDiffCommand. Renamed execute method
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 630
diff changeset
185 }
54e16ab771ec Progress/cancel for HgDiffCommand. Renamed execute method
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 630
diff changeset
186 progress = getProgressSupport(insp);
54e16ab771ec Progress/cancel for HgDiffCommand. Renamed execute method
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 630
diff changeset
187 progress.start(totalWork + 1);
54e16ab771ec Progress/cancel for HgDiffCommand. Renamed execute method
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 630
diff changeset
188 progress.worked(1); // BlameHelper.prepare
54e16ab771ec Progress/cancel for HgDiffCommand. Renamed execute method
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 630
diff changeset
189 //
629
5f52074707b2 Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
190 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
191 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
192 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
193 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
194 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
195 // 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
196 assert clogRevIndex >= startRevIndex;
a20121a2bba6 Respect default range (0..tip)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 632
diff changeset
197 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
198 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
199 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
200 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
201 progress.worked(1);
54e16ab771ec Progress/cancel for HgDiffCommand. Renamed execute method
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 630
diff changeset
202 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
203 }
5f52074707b2 Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
204 }
5f52074707b2 Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
205 } 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
206 throw new HgLibraryFailureException(ex);
632
54e16ab771ec Progress/cancel for HgDiffCommand. Renamed execute method
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 630
diff changeset
207 } finally {
54e16ab771ec Progress/cancel for HgDiffCommand. Renamed execute method
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 630
diff changeset
208 if (progress != null) {
54e16ab771ec Progress/cancel for HgDiffCommand. Renamed execute method
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 630
diff changeset
209 progress.done();
54e16ab771ec Progress/cancel for HgDiffCommand. Renamed execute method
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 630
diff changeset
210 }
629
5f52074707b2 Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
211 }
5f52074707b2 Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
212 }
5f52074707b2 Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
213
5f52074707b2 Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
214 /**
5f52074707b2 Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
215 * 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
216 * 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
217 * 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
218 *
72c979555cb8 HgDiffCommand. Do not use deprecated code. Javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 629
diff changeset
219 * @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
220 * @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
221 * @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
222 */
632
54e16ab771ec Progress/cancel for HgDiffCommand. Renamed execute method
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 630
diff changeset
223 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
224 checkFile();
632
54e16ab771ec Progress/cancel for HgDiffCommand. Renamed execute method
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 630
diff changeset
225 final ProgressSupport progress = getProgressSupport(insp);
54e16ab771ec Progress/cancel for HgDiffCommand. Renamed execute method
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 630
diff changeset
226 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
227 try {
632
54e16ab771ec Progress/cancel for HgDiffCommand. Renamed execute method
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 630
diff changeset
228 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
229 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
230 // 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
231 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
232 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
233 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
234 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
235 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
236 }
5f52074707b2 Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
237 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
238 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
239 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
240 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
241 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
242 bh.prepare(df, clogIndexStart, changelogRevisionIndex);
632
54e16ab771ec Progress/cancel for HgDiffCommand. Renamed execute method
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 630
diff changeset
243 progress.worked(1);
54e16ab771ec Progress/cancel for HgDiffCommand. Renamed execute method
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 630
diff changeset
244 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
245 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
246 progress.worked(1);
54e16ab771ec Progress/cancel for HgDiffCommand. Renamed execute method
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 630
diff changeset
247 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
248 } 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
249 throw new HgLibraryFailureException(ex);
632
54e16ab771ec Progress/cancel for HgDiffCommand. Renamed execute method
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 630
diff changeset
250 } finally {
54e16ab771ec Progress/cancel for HgDiffCommand. Renamed execute method
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 630
diff changeset
251 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
252 }
5f52074707b2 Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
253 }
5f52074707b2 Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
254
630
72c979555cb8 HgDiffCommand. Do not use deprecated code. Javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 629
diff changeset
255 private void checkFile() {
72c979555cb8 HgDiffCommand. Do not use deprecated code. Javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 629
diff changeset
256 if (df == null) {
72c979555cb8 HgDiffCommand. Do not use deprecated code. Javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 629
diff changeset
257 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
258 }
72c979555cb8 HgDiffCommand. Do not use deprecated code. Javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 629
diff changeset
259 }
629
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 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
262 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
263 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
264 }
5f52074707b2 Diff/blame methods as command, their residence in HgDataFile was a mistake
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
265 }