Mercurial > hg4j
comparison src/org/tmatesoft/hg/core/HgAnnotateCommand.java @ 582:90df078d6418
Delegate cancel to original support, do not implement CancelSupport ourselves
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Mon, 22 Apr 2013 19:17:29 +0200 |
parents | 0890628ed51e |
children | ed243b668502 |
comparison
equal
deleted
inserted
replaced
581:0890628ed51e | 582:90df078d6418 |
---|---|
106 HgDataFile df = repo.getFileNode(file); | 106 HgDataFile df = repo.getFileNode(file); |
107 if (!df.exists()) { | 107 if (!df.exists()) { |
108 return; | 108 return; |
109 } | 109 } |
110 final int changesetStart = followRename ? 0 : df.getChangesetRevisionIndex(0); | 110 final int changesetStart = followRename ? 0 : df.getChangesetRevisionIndex(0); |
111 Collector c = new Collector(); | 111 Collector c = new Collector(cancellation); |
112 FileAnnotation fa = new FileAnnotation(c); | 112 FileAnnotation fa = new FileAnnotation(c); |
113 HgBlameFacility af = new HgBlameFacility(df); | 113 HgBlameFacility af = new HgBlameFacility(df); |
114 af.annotate(changesetStart, annotateRevision.get(), fa, HgIterateDirection.NewToOld); | 114 af.annotate(changesetStart, annotateRevision.get(), fa, HgIterateDirection.NewToOld); |
115 progress.worked(1); | 115 progress.worked(1); |
116 c.throwIfCancelled(); | |
117 cancellation.checkCancelled(); | |
116 ProgressSupport.Sub subProgress = new ProgressSupport.Sub(progress, 1); | 118 ProgressSupport.Sub subProgress = new ProgressSupport.Sub(progress, 1); |
117 LineImpl li = new LineImpl(); | 119 LineImpl li = new LineImpl(); |
118 for (int i = 0; i < c.lineRevisions.length; i++) { | 120 for (int i = 0; i < c.lineRevisions.length; i++) { |
119 li.init(i+1, c.lineRevisions[i], c.line(i)); | 121 li.init(i+1, c.lineRevisions[i], c.line(i)); |
120 inspector.next(li); | 122 inspector.next(li); |
148 | 150 |
149 // FIXME there's no need in FileAnnotation.LineInspector, merge it here | 151 // FIXME there's no need in FileAnnotation.LineInspector, merge it here |
150 private static class Collector implements LineInspector { | 152 private static class Collector implements LineInspector { |
151 private int[] lineRevisions; | 153 private int[] lineRevisions; |
152 private byte[][] lines; | 154 private byte[][] lines; |
153 | 155 private final CancelSupport cancelSupport; |
154 Collector() { | 156 private CancelledException cancelEx; |
157 | |
158 Collector(CancelSupport cancellation) { | |
159 cancelSupport = cancellation; | |
155 } | 160 } |
156 | 161 |
157 public void line(int lineNumber, int changesetRevIndex, BlockData lineContent, LineDescriptor ld) { | 162 public void line(int lineNumber, int changesetRevIndex, BlockData lineContent, LineDescriptor ld) { |
163 if (cancelEx != null) { | |
164 return; | |
165 } | |
158 if (lineRevisions == null) { | 166 if (lineRevisions == null) { |
159 lineRevisions = new int [ld.totalLines()]; | 167 lineRevisions = new int [ld.totalLines()]; |
160 Arrays.fill(lineRevisions, NO_REVISION); | 168 Arrays.fill(lineRevisions, NO_REVISION); |
161 lines = new byte[ld.totalLines()][]; | 169 lines = new byte[ld.totalLines()][]; |
162 } | 170 } |
163 lineRevisions[lineNumber] = changesetRevIndex; | 171 lineRevisions[lineNumber] = changesetRevIndex; |
164 lines[lineNumber] = lineContent.asArray(); | 172 lines[lineNumber] = lineContent.asArray(); |
173 try { | |
174 cancelSupport.checkCancelled(); | |
175 } catch (CancelledException ex) { | |
176 cancelEx = ex; | |
177 } | |
165 } | 178 } |
166 | 179 |
167 public byte[] line(int i) { | 180 public byte[] line(int i) { |
168 return lines[i]; | 181 return lines[i]; |
182 } | |
183 | |
184 public void throwIfCancelled() throws CancelledException { | |
185 if (cancelEx != null) { | |
186 throw cancelEx; | |
187 } | |
169 } | 188 } |
170 } | 189 } |
171 | 190 |
172 | 191 |
173 private static class LineImpl implements LineInfo { | 192 private static class LineImpl implements LineInfo { |