comparison src/org/tmatesoft/hg/core/HgAnnotateCommand.java @ 628:6526d8adbc0f

Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Wed, 22 May 2013 15:52:31 +0200
parents 5afc7eedb3dd
children 5f52074707b2
comparison
equal deleted inserted replaced
627:5153eb73b18d 628:6526d8adbc0f
26 import org.tmatesoft.hg.internal.FileAnnotation.LineDescriptor; 26 import org.tmatesoft.hg.internal.FileAnnotation.LineDescriptor;
27 import org.tmatesoft.hg.internal.FileAnnotation.LineInspector; 27 import org.tmatesoft.hg.internal.FileAnnotation.LineInspector;
28 import org.tmatesoft.hg.repo.HgBlameInspector.BlockData; 28 import org.tmatesoft.hg.repo.HgBlameInspector.BlockData;
29 import org.tmatesoft.hg.repo.HgDataFile; 29 import org.tmatesoft.hg.repo.HgDataFile;
30 import org.tmatesoft.hg.repo.HgRepository; 30 import org.tmatesoft.hg.repo.HgRepository;
31 import org.tmatesoft.hg.repo.HgRuntimeException;
31 import org.tmatesoft.hg.util.CancelSupport; 32 import org.tmatesoft.hg.util.CancelSupport;
32 import org.tmatesoft.hg.util.CancelledException; 33 import org.tmatesoft.hg.util.CancelledException;
33 import org.tmatesoft.hg.util.Path; 34 import org.tmatesoft.hg.util.Path;
34 import org.tmatesoft.hg.util.ProgressSupport; 35 import org.tmatesoft.hg.util.ProgressSupport;
35 36
105 } 106 }
106 final ProgressSupport progress = getProgressSupport(inspector); 107 final ProgressSupport progress = getProgressSupport(inspector);
107 final CancelSupport cancellation = getCancelSupport(inspector, true); 108 final CancelSupport cancellation = getCancelSupport(inspector, true);
108 cancellation.checkCancelled(); 109 cancellation.checkCancelled();
109 progress.start(2); 110 progress.start(2);
110 HgDataFile df = repo.getFileNode(file); 111 try {
111 if (!df.exists()) { 112 HgDataFile df = repo.getFileNode(file);
112 return; 113 if (!df.exists()) {
113 } 114 return;
114 final int changesetStart = followRename ? 0 : df.getChangesetRevisionIndex(0); 115 }
115 Collector c = new Collector(cancellation); 116 final int changesetStart = followRename ? 0 : df.getChangesetRevisionIndex(0);
116 FileAnnotation fa = new FileAnnotation(c); 117 Collector c = new Collector(cancellation);
117 df.annotate(changesetStart, annotateRevision.get(), fa, HgIterateDirection.NewToOld); 118 FileAnnotation fa = new FileAnnotation(c);
118 progress.worked(1); 119 df.annotate(changesetStart, annotateRevision.get(), fa, HgIterateDirection.NewToOld);
119 c.throwIfCancelled(); 120 progress.worked(1);
120 cancellation.checkCancelled(); 121 c.throwIfCancelled();
121 ProgressSupport.Sub subProgress = new ProgressSupport.Sub(progress, 1);
122 subProgress.start(c.lineRevisions.length);
123 LineImpl li = new LineImpl();
124 for (int i = 0; i < c.lineRevisions.length; i++) {
125 li.init(i+1, c.lineRevisions[i], c.line(i));
126 inspector.next(li);
127 subProgress.worked(1);
128 cancellation.checkCancelled(); 122 cancellation.checkCancelled();
129 } 123 ProgressSupport.Sub subProgress = new ProgressSupport.Sub(progress, 1);
130 subProgress.done(); 124 subProgress.start(c.lineRevisions.length);
125 LineImpl li = new LineImpl();
126 for (int i = 0; i < c.lineRevisions.length; i++) {
127 li.init(i+1, c.lineRevisions[i], c.line(i));
128 inspector.next(li);
129 subProgress.worked(1);
130 cancellation.checkCancelled();
131 }
132 subProgress.done();
133 } catch (HgRuntimeException ex) {
134 throw new HgLibraryFailureException(ex);
135 }
131 progress.done(); 136 progress.done();
132 } 137 }
133 138
134 /** 139 /**
135 * Callback to receive annotated lines 140 * Callback to receive annotated lines