Mercurial > hg4j
comparison src/org/tmatesoft/hg/core/HgLogCommand.java @ 370:a2341e761609
Let callback implementations deliver errors (e,g. own exceptions) to client code
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Thu, 22 Dec 2011 02:37:10 +0300 |
parents | 8107b95f4280 |
children | 9517df1ef7ec |
comparison
equal
deleted
inserted
replaced
369:091666b87f62 | 370:a2341e761609 |
---|---|
201 } | 201 } |
202 | 202 |
203 /** | 203 /** |
204 * | 204 * |
205 * @param handler callback to process changesets. | 205 * @param handler callback to process changesets. |
206 * @throws HgCallbackTargetException FIXME | |
207 * @throws HgException FIXME | |
208 * @throws CancelledException FIXME | |
206 * @throws IllegalArgumentException when inspector argument is null | 209 * @throws IllegalArgumentException when inspector argument is null |
207 * @throws ConcurrentModificationException if this log command instance is already running | 210 * @throws ConcurrentModificationException if this log command instance is already running |
208 */ | 211 */ |
209 public void execute(HgChangesetHandler handler) throws HgDataStreamException, HgInvalidControlFileException, HgCallbackTargetException, CancelledException { | 212 public void execute(HgChangesetHandler handler) throws HgCallbackTargetException, HgException, CancelledException { |
210 if (handler == null) { | 213 if (handler == null) { |
211 throw new IllegalArgumentException(); | 214 throw new IllegalArgumentException(); |
212 } | 215 } |
213 if (csetTransform != null) { | 216 if (csetTransform != null) { |
214 throw new ConcurrentModificationException(); | 217 throw new ConcurrentModificationException(); |
235 if (handler instanceof FileHistoryHandler) { | 238 if (handler instanceof FileHistoryHandler) { |
236 HgFileRevision src = new HgFileRevision(repo, fileNode.getCopySourceRevision(), fileNode.getCopySourceName()); | 239 HgFileRevision src = new HgFileRevision(repo, fileNode.getCopySourceRevision(), fileNode.getCopySourceName()); |
237 HgFileRevision dst = new HgFileRevision(repo, fileNode.getRevision(0), fileNode.getPath(), src.getPath()); | 240 HgFileRevision dst = new HgFileRevision(repo, fileNode.getRevision(0), fileNode.getPath(), src.getPath()); |
238 try { | 241 try { |
239 ((FileHistoryHandler) handler).copy(src, dst); | 242 ((FileHistoryHandler) handler).copy(src, dst); |
240 } catch (RuntimeException ex) { | 243 } catch (HgCallbackTargetException.Wrap ex) { |
241 throw new HgCallbackTargetException(ex).setRevision(fileNode.getCopySourceRevision()).setFileName(fileNode.getCopySourceName()); | 244 throw new HgCallbackTargetException(ex).setRevision(fileNode.getCopySourceRevision()).setFileName(fileNode.getCopySourceName()); |
242 } | 245 } |
243 } | 246 } |
244 if (limit > 0 && count >= limit) { | 247 if (limit > 0 && count >= limit) { |
245 // if limit reach, follow is useless. | 248 // if limit reach, follow is useless. |
257 csetTransform = null; | 260 csetTransform = null; |
258 progressHelper.done(); | 261 progressHelper.done(); |
259 } | 262 } |
260 } | 263 } |
261 | 264 |
262 public void execute(HgChangesetTreeHandler handler) throws CancelledException, HgException { | 265 /** |
266 * | |
267 * @param handler | |
268 * @throws HgCallbackTargetException | |
269 * @throws HgException | |
270 * @throws CancelledException | |
271 */ | |
272 public void execute(HgChangesetTreeHandler handler) throws HgCallbackTargetException, HgException, CancelledException { | |
263 if (handler == null) { | 273 if (handler == null) { |
264 throw new IllegalArgumentException(); | 274 throw new IllegalArgumentException(); |
265 } | 275 } |
266 if (csetTransform != null) { | 276 if (csetTransform != null) { |
267 throw new ConcurrentModificationException(); | 277 throw new ConcurrentModificationException(); |
316 progressHelper.worked(1); | 326 progressHelper.worked(1); |
317 ph2 = new ProgressSupport.Sub(progressHelper, 2); | 327 ph2 = new ProgressSupport.Sub(progressHelper, 2); |
318 } else { | 328 } else { |
319 ph2 = new ProgressSupport.Sub(progressHelper, 3); | 329 ph2 = new ProgressSupport.Sub(progressHelper, 3); |
320 } | 330 } |
321 ph2.start(completeHistory.length); | 331 try { |
322 // XXX shall sort completeHistory according to changeset numbers? | 332 ph2.start(completeHistory.length); |
323 for (int i = 0; i < completeHistory.length; i++ ) { | 333 // XXX shall sort completeHistory according to changeset numbers? |
324 final HistoryNode n = completeHistory[i]; | 334 for (int i = 0; i < completeHistory.length; i++ ) { |
325 handler.next(ei.init(n)); | 335 final HistoryNode n = completeHistory[i]; |
326 ph2.worked(1); | 336 handler.next(ei.init(n)); |
327 cancelHelper.checkCancelled(); | 337 ph2.worked(1); |
338 cancelHelper.checkCancelled(); | |
339 } | |
340 } catch (HgCallbackTargetException.Wrap ex) { | |
341 throw new HgCallbackTargetException(ex); | |
328 } | 342 } |
329 progressHelper.done(); | 343 progressHelper.done(); |
330 } | 344 } |
331 | 345 |
332 // | 346 // |
377 * followed by any changesets. | 391 * followed by any changesets. |
378 * | 392 * |
379 * @author Artem Tikhomirov | 393 * @author Artem Tikhomirov |
380 * @author TMate Software Ltd. | 394 * @author TMate Software Ltd. |
381 */ | 395 */ |
382 public interface FileHistoryHandler extends HgChangesetHandler { | 396 public interface FileHistoryHandler extends HgChangesetHandler { // FIXME move to stanalone class file, perhaps? |
383 // XXX perhaps, should distinguish copy from rename? And what about merged revisions and following them? | 397 // XXX perhaps, should distinguish copy from rename? And what about merged revisions and following them? |
384 void copy(HgFileRevision from, HgFileRevision to); | 398 /** |
399 * @throws HgCallbackTargetException.Wrap wrapper object for any exception user code may produce. Wrapped exception would get re-thrown with {@link HgCallbackTargetException} | |
400 */ | |
401 void copy(HgFileRevision from, HgFileRevision to) throws HgCallbackTargetException.Wrap; | |
385 } | 402 } |
386 | 403 |
387 public static class CollectHandler implements HgChangesetHandler { | 404 public static class CollectHandler implements HgChangesetHandler { |
388 private final List<HgChangeset> result = new LinkedList<HgChangeset>(); | 405 private final List<HgChangeset> result = new LinkedList<HgChangeset>(); |
389 | 406 |