Mercurial > jhg
annotate src/org/tmatesoft/hg/core/HgAnnotateCommand.java @ 676:3219cfadda49
Switch to alternative annotate producer (walks from parents to children). Refactor FileAnnotation to match updated annotate approach
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Thu, 18 Jul 2013 18:03:51 +0200 |
parents | 5f52074707b2 |
children | 1c49c0cee540 |
rev | line source |
---|---|
566
32453f30de07
Annotate command with command-line example
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
1 /* |
32453f30de07
Annotate command with command-line example
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
2 * Copyright (c) 2013 TMate Software Ltd |
32453f30de07
Annotate command with command-line example
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
3 * |
32453f30de07
Annotate command with command-line example
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
4 * This program is free software; you can redistribute it and/or modify |
32453f30de07
Annotate command with command-line example
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
5 * it under the terms of the GNU General Public License as published by |
32453f30de07
Annotate command with command-line example
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
6 * the Free Software Foundation; version 2 of the License. |
32453f30de07
Annotate command with command-line example
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
7 * |
32453f30de07
Annotate command with command-line example
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
8 * This program is distributed in the hope that it will be useful, |
32453f30de07
Annotate command with command-line example
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
32453f30de07
Annotate command with command-line example
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
32453f30de07
Annotate command with command-line example
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
11 * GNU General Public License for more details. |
32453f30de07
Annotate command with command-line example
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
12 * |
32453f30de07
Annotate command with command-line example
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
13 * For information on how to redistribute this software under |
32453f30de07
Annotate command with command-line example
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
14 * the terms of a license other than GNU General Public License |
32453f30de07
Annotate command with command-line example
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
15 * contact TMate Software at support@hg4j.com |
32453f30de07
Annotate command with command-line example
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
16 */ |
32453f30de07
Annotate command with command-line example
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
17 package org.tmatesoft.hg.core; |
32453f30de07
Annotate command with command-line example
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
18 |
32453f30de07
Annotate command with command-line example
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
19 import org.tmatesoft.hg.internal.Callback; |
32453f30de07
Annotate command with command-line example
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
20 import org.tmatesoft.hg.internal.CsetParamKeeper; |
676
3219cfadda49
Switch to alternative annotate producer (walks from parents to children). Refactor FileAnnotation to match updated annotate approach
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
629
diff
changeset
|
21 import org.tmatesoft.hg.internal.ForwardAnnotateInspector; |
566
32453f30de07
Annotate command with command-line example
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
22 import org.tmatesoft.hg.repo.HgDataFile; |
32453f30de07
Annotate command with command-line example
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
23 import org.tmatesoft.hg.repo.HgRepository; |
628
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
626
diff
changeset
|
24 import org.tmatesoft.hg.repo.HgRuntimeException; |
581
0890628ed51e
Progress/cancel support in new commands
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
569
diff
changeset
|
25 import org.tmatesoft.hg.util.CancelSupport; |
566
32453f30de07
Annotate command with command-line example
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
26 import org.tmatesoft.hg.util.CancelledException; |
569
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
566
diff
changeset
|
27 import org.tmatesoft.hg.util.Path; |
581
0890628ed51e
Progress/cancel support in new commands
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
569
diff
changeset
|
28 import org.tmatesoft.hg.util.ProgressSupport; |
566
32453f30de07
Annotate command with command-line example
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
29 |
32453f30de07
Annotate command with command-line example
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
30 /** |
32453f30de07
Annotate command with command-line example
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
31 * 'hg annotate' counterpart, report origin revision and file line-by-line |
32453f30de07
Annotate command with command-line example
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
32 * |
613
f41dd9a3b8af
Remove few Experimental annotations as the API they've marked graduates
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
603
diff
changeset
|
33 * @since 1.1 |
566
32453f30de07
Annotate command with command-line example
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
34 * @author Artem Tikhomirov |
32453f30de07
Annotate command with command-line example
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
35 * @author TMate Software Ltd. |
32453f30de07
Annotate command with command-line example
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
36 */ |
32453f30de07
Annotate command with command-line example
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
37 public class HgAnnotateCommand extends HgAbstractCommand<HgAnnotateCommand> { |
32453f30de07
Annotate command with command-line example
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
38 |
32453f30de07
Annotate command with command-line example
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
39 private final HgRepository repo; |
32453f30de07
Annotate command with command-line example
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
40 private final CsetParamKeeper annotateRevision; |
569
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
566
diff
changeset
|
41 private Path file; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
566
diff
changeset
|
42 private boolean followRename; |
566
32453f30de07
Annotate command with command-line example
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
43 |
32453f30de07
Annotate command with command-line example
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
44 public HgAnnotateCommand(HgRepository hgRepo) { |
32453f30de07
Annotate command with command-line example
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
45 repo = hgRepo; |
32453f30de07
Annotate command with command-line example
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
46 annotateRevision = new CsetParamKeeper(repo); |
32453f30de07
Annotate command with command-line example
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
47 annotateRevision.doSet(HgRepository.TIP); |
32453f30de07
Annotate command with command-line example
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
48 } |
32453f30de07
Annotate command with command-line example
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
49 |
32453f30de07
Annotate command with command-line example
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
50 public HgAnnotateCommand changeset(Nodeid nodeid) throws HgBadArgumentException { |
32453f30de07
Annotate command with command-line example
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
51 annotateRevision.set(nodeid); |
32453f30de07
Annotate command with command-line example
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
52 return this; |
32453f30de07
Annotate command with command-line example
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
53 } |
32453f30de07
Annotate command with command-line example
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
54 |
32453f30de07
Annotate command with command-line example
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
55 public HgAnnotateCommand changeset(int changelogRevIndex) throws HgBadArgumentException { |
32453f30de07
Annotate command with command-line example
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
56 annotateRevision.set(changelogRevIndex); |
32453f30de07
Annotate command with command-line example
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
57 return this; |
32453f30de07
Annotate command with command-line example
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
58 } |
32453f30de07
Annotate command with command-line example
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
59 |
569
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
566
diff
changeset
|
60 /** |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
566
diff
changeset
|
61 * Select file to annotate, origin of renamed/copied file would be followed, too. |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
566
diff
changeset
|
62 * |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
566
diff
changeset
|
63 * @param filePath path relative to repository root |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
566
diff
changeset
|
64 * @return <code>this</code> for convenience |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
566
diff
changeset
|
65 */ |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
566
diff
changeset
|
66 public HgAnnotateCommand file(Path filePath) { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
566
diff
changeset
|
67 return file(filePath, true); |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
566
diff
changeset
|
68 } |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
566
diff
changeset
|
69 |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
566
diff
changeset
|
70 /** |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
566
diff
changeset
|
71 * Select file to annotate. |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
566
diff
changeset
|
72 * |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
566
diff
changeset
|
73 * @param filePath path relative to repository root |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
566
diff
changeset
|
74 * @param followCopyRename true to follow copies/renames. |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
566
diff
changeset
|
75 * @return <code>this</code> for convenience |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
566
diff
changeset
|
76 */ |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
566
diff
changeset
|
77 public HgAnnotateCommand file(Path filePath, boolean followCopyRename) { |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
566
diff
changeset
|
78 file = filePath; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
566
diff
changeset
|
79 followRename = followCopyRename; |
566
32453f30de07
Annotate command with command-line example
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
80 return this; |
32453f30de07
Annotate command with command-line example
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
81 } |
32453f30de07
Annotate command with command-line example
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
82 |
626
5afc7eedb3dd
@since, TODOs. Tests: add 1 sec to deal with fs timestamp granularity on linux
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
613
diff
changeset
|
83 // TODO [post-1.1] set encoding and provide String line content from LineInfo |
676
3219cfadda49
Switch to alternative annotate producer (walks from parents to children). Refactor FileAnnotation to match updated annotate approach
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
629
diff
changeset
|
84 // TODO FWIW: diff algorithms: http://bramcohen.livejournal.com/73318.html |
566
32453f30de07
Annotate command with command-line example
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
85 |
586
73c20c648c1f
HgCommitCommand initial support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
584
diff
changeset
|
86 /** |
73c20c648c1f
HgCommitCommand initial support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
584
diff
changeset
|
87 * Annotate selected file |
73c20c648c1f
HgCommitCommand initial support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
584
diff
changeset
|
88 * |
73c20c648c1f
HgCommitCommand initial support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
584
diff
changeset
|
89 * @param inspector |
73c20c648c1f
HgCommitCommand initial support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
584
diff
changeset
|
90 * @throws HgException subclass thereof to indicate specific issue with the command arguments or repository state |
73c20c648c1f
HgCommitCommand initial support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
584
diff
changeset
|
91 * @throws HgCallbackTargetException |
73c20c648c1f
HgCommitCommand initial support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
584
diff
changeset
|
92 * @throws CancelledException if execution of the command was cancelled |
73c20c648c1f
HgCommitCommand initial support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
584
diff
changeset
|
93 */ |
566
32453f30de07
Annotate command with command-line example
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
94 public void execute(Inspector inspector) throws HgException, HgCallbackTargetException, CancelledException { |
32453f30de07
Annotate command with command-line example
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
95 if (inspector == null) { |
32453f30de07
Annotate command with command-line example
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
96 throw new IllegalArgumentException(); |
32453f30de07
Annotate command with command-line example
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
97 } |
32453f30de07
Annotate command with command-line example
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
98 if (file == null) { |
32453f30de07
Annotate command with command-line example
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
99 throw new HgBadArgumentException("Command needs file argument", null); |
32453f30de07
Annotate command with command-line example
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
100 } |
581
0890628ed51e
Progress/cancel support in new commands
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
569
diff
changeset
|
101 final ProgressSupport progress = getProgressSupport(inspector); |
0890628ed51e
Progress/cancel support in new commands
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
569
diff
changeset
|
102 final CancelSupport cancellation = getCancelSupport(inspector, true); |
0890628ed51e
Progress/cancel support in new commands
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
569
diff
changeset
|
103 cancellation.checkCancelled(); |
676
3219cfadda49
Switch to alternative annotate producer (walks from parents to children). Refactor FileAnnotation to match updated annotate approach
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
629
diff
changeset
|
104 progress.start(200); |
628
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
626
diff
changeset
|
105 try { |
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
626
diff
changeset
|
106 HgDataFile df = repo.getFileNode(file); |
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
626
diff
changeset
|
107 if (!df.exists()) { |
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
626
diff
changeset
|
108 return; |
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
626
diff
changeset
|
109 } |
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
626
diff
changeset
|
110 final int changesetStart = followRename ? 0 : df.getChangesetRevisionIndex(0); |
676
3219cfadda49
Switch to alternative annotate producer (walks from parents to children). Refactor FileAnnotation to match updated annotate approach
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
629
diff
changeset
|
111 final int annotateRevIndex = annotateRevision.get(); |
3219cfadda49
Switch to alternative annotate producer (walks from parents to children). Refactor FileAnnotation to match updated annotate approach
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
629
diff
changeset
|
112 HgDiffCommand cmd = new HgDiffCommand(repo).file(df); |
3219cfadda49
Switch to alternative annotate producer (walks from parents to children). Refactor FileAnnotation to match updated annotate approach
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
629
diff
changeset
|
113 cmd.range(changesetStart, annotateRevIndex); |
3219cfadda49
Switch to alternative annotate producer (walks from parents to children). Refactor FileAnnotation to match updated annotate approach
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
629
diff
changeset
|
114 cmd.set(cancellation); |
3219cfadda49
Switch to alternative annotate producer (walks from parents to children). Refactor FileAnnotation to match updated annotate approach
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
629
diff
changeset
|
115 cmd.set(new ProgressSupport.Sub(progress, 100)); |
3219cfadda49
Switch to alternative annotate producer (walks from parents to children). Refactor FileAnnotation to match updated annotate approach
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
629
diff
changeset
|
116 // |
3219cfadda49
Switch to alternative annotate producer (walks from parents to children). Refactor FileAnnotation to match updated annotate approach
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
629
diff
changeset
|
117 // ReverseAnnotateInspector ai = new ReverseAnnotateInspector(); |
3219cfadda49
Switch to alternative annotate producer (walks from parents to children). Refactor FileAnnotation to match updated annotate approach
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
629
diff
changeset
|
118 ForwardAnnotateInspector ai = new ForwardAnnotateInspector(); |
3219cfadda49
Switch to alternative annotate producer (walks from parents to children). Refactor FileAnnotation to match updated annotate approach
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
629
diff
changeset
|
119 cmd.order(ai.iterateDirection()); |
3219cfadda49
Switch to alternative annotate producer (walks from parents to children). Refactor FileAnnotation to match updated annotate approach
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
629
diff
changeset
|
120 // |
3219cfadda49
Switch to alternative annotate producer (walks from parents to children). Refactor FileAnnotation to match updated annotate approach
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
629
diff
changeset
|
121 cmd.executeAnnotate(ai); |
628
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
626
diff
changeset
|
122 cancellation.checkCancelled(); |
676
3219cfadda49
Switch to alternative annotate producer (walks from parents to children). Refactor FileAnnotation to match updated annotate approach
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
629
diff
changeset
|
123 ai.report(annotateRevIndex, inspector, new ProgressSupport.Sub(progress, 100), cancellation); |
628
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
626
diff
changeset
|
124 } catch (HgRuntimeException ex) { |
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
626
diff
changeset
|
125 throw new HgLibraryFailureException(ex); |
569
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
566
diff
changeset
|
126 } |
581
0890628ed51e
Progress/cancel support in new commands
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
569
diff
changeset
|
127 progress.done(); |
566
32453f30de07
Annotate command with command-line example
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
128 } |
32453f30de07
Annotate command with command-line example
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
129 |
32453f30de07
Annotate command with command-line example
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
130 /** |
32453f30de07
Annotate command with command-line example
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
131 * Callback to receive annotated lines |
32453f30de07
Annotate command with command-line example
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
132 */ |
32453f30de07
Annotate command with command-line example
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
133 @Callback |
32453f30de07
Annotate command with command-line example
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
134 public interface Inspector { |
569
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
566
diff
changeset
|
135 // start(FileDescriptor) throws HgCallbackTargetException; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
566
diff
changeset
|
136 void next(LineInfo lineInfo) throws HgCallbackTargetException; |
c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
566
diff
changeset
|
137 // end(FileDescriptor) throws HgCallbackTargetException; |
566
32453f30de07
Annotate command with command-line example
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
138 } |
32453f30de07
Annotate command with command-line example
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
139 |
32453f30de07
Annotate command with command-line example
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
140 /** |
32453f30de07
Annotate command with command-line example
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
141 * Describes a line reported through {@link Inspector#next(LineInfo)} |
32453f30de07
Annotate command with command-line example
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
142 * |
32453f30de07
Annotate command with command-line example
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
143 * Clients shall not implement this interface |
32453f30de07
Annotate command with command-line example
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
144 */ |
32453f30de07
Annotate command with command-line example
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
145 public interface LineInfo { |
32453f30de07
Annotate command with command-line example
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
146 int getLineNumber(); |
32453f30de07
Annotate command with command-line example
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
147 int getChangesetIndex(); |
32453f30de07
Annotate command with command-line example
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
148 byte[] getContent(); |
32453f30de07
Annotate command with command-line example
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
149 } |
32453f30de07
Annotate command with command-line example
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
150 } |