Mercurial > hg4j
annotate src/org/tmatesoft/hg/core/HgAnnotateCommand.java @ 568:8ed4f4f4f0a6
Blame facility refactored, get ready for follow/no-follow support
| author | Artem Tikhomirov <tikhomirov.artem@gmail.com> | 
|---|---|
| date | Wed, 10 Apr 2013 15:45:53 +0200 | 
| parents | 32453f30de07 | 
| children | c4fd1037bc6f | 
| 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 static org.tmatesoft.hg.repo.HgRepository.NO_REVISION; | 
| 
 
32453f30de07
Annotate command with command-line example
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
20 | 
| 
 
32453f30de07
Annotate command with command-line example
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
21 import java.util.Arrays; | 
| 
 
32453f30de07
Annotate command with command-line example
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
22 | 
| 
 
32453f30de07
Annotate command with command-line example
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
23 import org.tmatesoft.hg.internal.Callback; | 
| 
 
32453f30de07
Annotate command with command-line example
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
24 import org.tmatesoft.hg.internal.CsetParamKeeper; | 
| 
 
32453f30de07
Annotate command with command-line example
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
25 import org.tmatesoft.hg.internal.Experimental; | 
| 
 
32453f30de07
Annotate command with command-line example
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
26 import org.tmatesoft.hg.internal.FileAnnotation; | 
| 
 
32453f30de07
Annotate command with command-line example
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
27 import org.tmatesoft.hg.internal.FileAnnotation.LineDescriptor; | 
| 
 
32453f30de07
Annotate command with command-line example
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
28 import org.tmatesoft.hg.internal.FileAnnotation.LineInspector; | 
| 
 
32453f30de07
Annotate command with command-line example
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
29 import org.tmatesoft.hg.repo.HgBlameFacility.BlockData; | 
| 
 
32453f30de07
Annotate command with command-line example
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
30 import org.tmatesoft.hg.repo.HgDataFile; | 
| 
 
32453f30de07
Annotate command with command-line example
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
31 import org.tmatesoft.hg.repo.HgRepository; | 
| 
 
32453f30de07
Annotate command with command-line example
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
32 import org.tmatesoft.hg.util.CancelledException; | 
| 
 
32453f30de07
Annotate command with command-line example
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
33 | 
| 
 
32453f30de07
Annotate command with command-line example
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
34 /** | 
| 
 
32453f30de07
Annotate command with command-line example
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
35 * WORK IN PROGRESS. UNSTABLE API | 
| 
 
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 * '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
 | 
38 * | 
| 
 
32453f30de07
Annotate command with command-line example
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
39 * @author Artem Tikhomirov | 
| 
 
32453f30de07
Annotate command with command-line example
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
40 * @author TMate Software Ltd. | 
| 
 
32453f30de07
Annotate command with command-line example
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
41 */ | 
| 
 
32453f30de07
Annotate command with command-line example
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
42 @Experimental(reason="Work in progress. Unstable API") | 
| 
 
32453f30de07
Annotate command with command-line example
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
43 public class HgAnnotateCommand extends HgAbstractCommand<HgAnnotateCommand> { | 
| 
 
32453f30de07
Annotate command with command-line example
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
44 | 
| 
 
32453f30de07
Annotate command with command-line example
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
45 private final HgRepository repo; | 
| 
 
32453f30de07
Annotate command with command-line example
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
46 private final CsetParamKeeper annotateRevision; | 
| 
 
32453f30de07
Annotate command with command-line example
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
47 private HgDataFile file; | 
| 
 
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 public HgAnnotateCommand(HgRepository hgRepo) { | 
| 
 
32453f30de07
Annotate command with command-line example
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
50 repo = hgRepo; | 
| 
 
32453f30de07
Annotate command with command-line example
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
51 annotateRevision = new CsetParamKeeper(repo); | 
| 
 
32453f30de07
Annotate command with command-line example
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
52 annotateRevision.doSet(HgRepository.TIP); | 
| 
 
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(Nodeid nodeid) throws HgBadArgumentException { | 
| 
 
32453f30de07
Annotate command with command-line example
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
56 annotateRevision.set(nodeid); | 
| 
 
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 | 
| 
 
32453f30de07
Annotate command with command-line example
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
60 public HgAnnotateCommand changeset(int changelogRevIndex) throws HgBadArgumentException { | 
| 
 
32453f30de07
Annotate command with command-line example
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
61 annotateRevision.set(changelogRevIndex); | 
| 
 
32453f30de07
Annotate command with command-line example
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
62 return this; | 
| 
 
32453f30de07
Annotate command with command-line example
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
63 } | 
| 
 
32453f30de07
Annotate command with command-line example
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
64 | 
| 
 
32453f30de07
Annotate command with command-line example
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
65 public HgAnnotateCommand file(HgDataFile fileNode) { | 
| 
 
32453f30de07
Annotate command with command-line example
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
66 file = fileNode; | 
| 
 
32453f30de07
Annotate command with command-line example
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
67 return this; | 
| 
 
32453f30de07
Annotate command with command-line example
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
68 } | 
| 
 
32453f30de07
Annotate command with command-line example
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
69 | 
| 
 
32453f30de07
Annotate command with command-line example
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
70 // TODO [1.1] set encoding and provide String line content from LineInfo | 
| 
 
32453f30de07
Annotate command with command-line example
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
71 | 
| 
 
32453f30de07
Annotate command with command-line example
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
72 // FIXME [1.1] follow and no-follow parameters | 
| 
 
32453f30de07
Annotate command with command-line example
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
73 | 
| 
 
32453f30de07
Annotate command with command-line example
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
74 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
 | 
75 if (inspector == null) { | 
| 
 
32453f30de07
Annotate command with command-line example
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
76 throw new IllegalArgumentException(); | 
| 
 
32453f30de07
Annotate command with command-line example
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
77 } | 
| 
 
32453f30de07
Annotate command with command-line example
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
78 if (file == null) { | 
| 
 
32453f30de07
Annotate command with command-line example
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
79 throw new HgBadArgumentException("Command needs file argument", null); | 
| 
 
32453f30de07
Annotate command with command-line example
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
80 } | 
| 
 
32453f30de07
Annotate command with command-line example
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
81 Collector c = new Collector(); | 
| 
 
32453f30de07
Annotate command with command-line example
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
82 FileAnnotation.annotate(file, annotateRevision.get(), c); | 
| 
 
32453f30de07
Annotate command with command-line example
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
83 LineImpl li = new LineImpl(); | 
| 
 
32453f30de07
Annotate command with command-line example
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
84 for (int i = 0; i < c.lineRevisions.length; i++) { | 
| 
 
32453f30de07
Annotate command with command-line example
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
85 li.init(i+1, c.lineRevisions[i], c.line(i)); | 
| 
 
32453f30de07
Annotate command with command-line example
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
86 inspector.next(li); | 
| 
 
32453f30de07
Annotate command with command-line example
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
87 } | 
| 
 
32453f30de07
Annotate command with command-line example
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
88 } | 
| 
 
32453f30de07
Annotate command with command-line example
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
89 | 
| 
 
32453f30de07
Annotate command with command-line example
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
90 /** | 
| 
 
32453f30de07
Annotate command with command-line example
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
91 * Callback to receive annotated lines | 
| 
 
32453f30de07
Annotate command with command-line example
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
92 */ | 
| 
 
32453f30de07
Annotate command with command-line example
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
93 @Callback | 
| 
 
32453f30de07
Annotate command with command-line example
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
94 public interface Inspector { | 
| 
 
32453f30de07
Annotate command with command-line example
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
95 // start(FileDescriptor); | 
| 
 
32453f30de07
Annotate command with command-line example
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
96 void next(LineInfo lineInfo); | 
| 
 
32453f30de07
Annotate command with command-line example
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
97 // end(FileDescriptor); | 
| 
 
32453f30de07
Annotate command with command-line example
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
98 } | 
| 
 
32453f30de07
Annotate command with command-line example
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
99 | 
| 
 
32453f30de07
Annotate command with command-line example
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
100 /** | 
| 
 
32453f30de07
Annotate command with command-line example
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
101 * 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
 | 
102 * | 
| 
 
32453f30de07
Annotate command with command-line example
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
103 * Clients shall not implement this interface | 
| 
 
32453f30de07
Annotate command with command-line example
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
104 */ | 
| 
 
32453f30de07
Annotate command with command-line example
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
105 public interface LineInfo { | 
| 
 
32453f30de07
Annotate command with command-line example
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
106 int getLineNumber(); | 
| 
 
32453f30de07
Annotate command with command-line example
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
107 int getChangesetIndex(); | 
| 
 
32453f30de07
Annotate command with command-line example
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
108 byte[] getContent(); | 
| 
 
32453f30de07
Annotate command with command-line example
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
109 } | 
| 
 
32453f30de07
Annotate command with command-line example
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
110 | 
| 
 
32453f30de07
Annotate command with command-line example
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
111 // FIXME there's no need in FileAnnotation.LineInspector, merge it here | 
| 
 
32453f30de07
Annotate command with command-line example
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
112 private static class Collector implements LineInspector { | 
| 
 
32453f30de07
Annotate command with command-line example
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
113 private int[] lineRevisions; | 
| 
 
32453f30de07
Annotate command with command-line example
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
114 private byte[][] lines; | 
| 
 
32453f30de07
Annotate command with command-line example
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
115 | 
| 
 
32453f30de07
Annotate command with command-line example
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
116 Collector() { | 
| 
 
32453f30de07
Annotate command with command-line example
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
117 } | 
| 
 
32453f30de07
Annotate command with command-line example
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
118 | 
| 
 
32453f30de07
Annotate command with command-line example
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
119 public void line(int lineNumber, int changesetRevIndex, BlockData lineContent, LineDescriptor ld) { | 
| 
 
32453f30de07
Annotate command with command-line example
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
120 if (lineRevisions == null) { | 
| 
 
32453f30de07
Annotate command with command-line example
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
121 lineRevisions = new int [ld.totalLines()]; | 
| 
 
32453f30de07
Annotate command with command-line example
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
122 Arrays.fill(lineRevisions, NO_REVISION); | 
| 
 
32453f30de07
Annotate command with command-line example
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
123 lines = new byte[ld.totalLines()][]; | 
| 
 
32453f30de07
Annotate command with command-line example
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
124 } | 
| 
 
32453f30de07
Annotate command with command-line example
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
125 lineRevisions[lineNumber] = changesetRevIndex; | 
| 
 
32453f30de07
Annotate command with command-line example
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
126 lines[lineNumber] = lineContent.asArray(); | 
| 
 
32453f30de07
Annotate command with command-line example
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
127 } | 
| 
 
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 public byte[] line(int i) { | 
| 
 
32453f30de07
Annotate command with command-line example
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
130 return lines[i]; | 
| 
 
32453f30de07
Annotate command with command-line example
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
131 } | 
| 
 
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 | 
| 
 
32453f30de07
Annotate command with command-line example
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
134 | 
| 
 
32453f30de07
Annotate command with command-line example
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
135 private static class LineImpl implements LineInfo { | 
| 
 
32453f30de07
Annotate command with command-line example
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
136 private int ln; | 
| 
 
32453f30de07
Annotate command with command-line example
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
137 private int rev; | 
| 
 
32453f30de07
Annotate command with command-line example
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
138 private byte[] content; | 
| 
 
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 void init(int line, int csetRev, byte[] cnt) { | 
| 
 
32453f30de07
Annotate command with command-line example
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
141 ln = line; | 
| 
 
32453f30de07
Annotate command with command-line example
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
142 rev = csetRev; | 
| 
 
32453f30de07
Annotate command with command-line example
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
143 content = cnt; | 
| 
 
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 | 
| 
 
32453f30de07
Annotate command with command-line example
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
146 public int getLineNumber() { | 
| 
 
32453f30de07
Annotate command with command-line example
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
147 return ln; | 
| 
 
32453f30de07
Annotate command with command-line example
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
148 } | 
| 
 
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 public int getChangesetIndex() { | 
| 
 
32453f30de07
Annotate command with command-line example
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
151 return rev; | 
| 
 
32453f30de07
Annotate command with command-line example
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
152 } | 
| 
 
32453f30de07
Annotate command with command-line example
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
153 | 
| 
 
32453f30de07
Annotate command with command-line example
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
154 public byte[] getContent() { | 
| 
 
32453f30de07
Annotate command with command-line example
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
155 return content; | 
| 
 
32453f30de07
Annotate command with command-line example
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
156 } | 
| 
 
32453f30de07
Annotate command with command-line example
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
157 } | 
| 
 
32453f30de07
Annotate command with command-line example
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
158 } | 
