Mercurial > jhg
comparison src/org/tmatesoft/hg/core/HgStatusCommand.java @ 427:31a89587eb04
FIXMEs: consistent names, throws for commands and their handlers. Use of checked exceptions in hi-level api
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Thu, 29 Mar 2012 17:14:35 +0200 |
parents | 6437d261048a |
children | cd658b24a620 |
comparison
equal
deleted
inserted
replaced
426:063b0663495a | 427:31a89587eb04 |
---|---|
23 import java.io.IOException; | 23 import java.io.IOException; |
24 import java.util.ConcurrentModificationException; | 24 import java.util.ConcurrentModificationException; |
25 | 25 |
26 import org.tmatesoft.hg.internal.ChangelogHelper; | 26 import org.tmatesoft.hg.internal.ChangelogHelper; |
27 import org.tmatesoft.hg.repo.HgRepository; | 27 import org.tmatesoft.hg.repo.HgRepository; |
28 import org.tmatesoft.hg.repo.HgRuntimeException; | |
28 import org.tmatesoft.hg.repo.HgStatusCollector; | 29 import org.tmatesoft.hg.repo.HgStatusCollector; |
29 import org.tmatesoft.hg.repo.HgStatusInspector; | 30 import org.tmatesoft.hg.repo.HgStatusInspector; |
30 import org.tmatesoft.hg.repo.HgWorkingCopyStatusCollector; | 31 import org.tmatesoft.hg.repo.HgWorkingCopyStatusCollector; |
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; |
160 | 161 |
161 /** | 162 /** |
162 * Perform status operation according to parameters set. | 163 * Perform status operation according to parameters set. |
163 * | 164 * |
164 * @param statusHandler callback to get status information | 165 * @param statusHandler callback to get status information |
165 * @throws HgCallbackTargetException wrapper for any exception user callback code may produce | 166 * @throws HgCallbackTargetException propagated exception from the handler |
167 * @throws HgException subclass thereof to indicate specific issue with the command arguments or repository state | |
166 * @throws CancelledException if execution of the command was cancelled | 168 * @throws CancelledException if execution of the command was cancelled |
167 * @throws IOException FIXME EXCEPTIONS WTF it's doing here if there are (further unspecified) errors while walking working copy | 169 * @throws IOException FIXME EXCEPTIONS WTF it's doing here if there are (further unspecified) errors while walking working copy |
168 * @throws IllegalArgumentException if handler is <code>null</code> | 170 * @throws IllegalArgumentException if handler is <code>null</code> |
169 * @throws ConcurrentModificationException if this command already runs (i.e. being used from another thread) | 171 * @throws ConcurrentModificationException if this command already runs (i.e. being used from another thread) |
170 */ | 172 */ |
171 public void execute(HgStatusHandler statusHandler) throws HgCallbackTargetException, CancelledException, HgException, IOException { | 173 public void execute(HgStatusHandler statusHandler) throws HgCallbackTargetException, HgException, CancelledException, IOException { |
172 if (statusHandler == null) { | 174 if (statusHandler == null) { |
173 throw new IllegalArgumentException(); | 175 throw new IllegalArgumentException(); |
174 } | 176 } |
175 if (mediator.busy()) { | 177 if (mediator.busy()) { |
176 throw new ConcurrentModificationException(); | 178 throw new ConcurrentModificationException(); |
195 } | 197 } |
196 } catch (CancelledException ex) { | 198 } catch (CancelledException ex) { |
197 // this is our exception, thrown from Mediator. | 199 // this is our exception, thrown from Mediator. |
198 // next check shall throw original cause of the stop - either HgCallbackTargetException or original CancelledException | 200 // next check shall throw original cause of the stop - either HgCallbackTargetException or original CancelledException |
199 mediator.checkFailure(); | 201 mediator.checkFailure(); |
202 } catch (HgRuntimeException ex) { | |
203 throw new HgLibraryFailureException(ex); | |
200 } finally { | 204 } finally { |
201 mediator.done(); | 205 mediator.done(); |
202 } | 206 } |
203 } | 207 } |
204 | 208 |
262 } | 266 } |
263 } | 267 } |
264 | 268 |
265 private void dispatch(HgStatus s) { | 269 private void dispatch(HgStatus s) { |
266 try { | 270 try { |
267 handler.handleStatus(s); | 271 handler.status(s); |
268 handlerCancelSupport.checkCancelled(); | 272 handlerCancelSupport.checkCancelled(); |
269 } catch (HgCallbackTargetException ex) { | 273 } catch (HgCallbackTargetException ex) { |
270 failure = ex; | 274 failure = ex; |
271 } catch (CancelledException ex) { | 275 } catch (CancelledException ex) { |
272 cancellation = ex; | 276 cancellation = ex; |
315 } | 319 } |
316 } | 320 } |
317 | 321 |
318 public void invalid(Path fname, Exception err) { | 322 public void invalid(Path fname, Exception err) { |
319 try { | 323 try { |
320 handler.handleError(fname, new Status(Status.Kind.ERROR, "Failed to get file status", err)); | 324 handler.error(fname, new Status(Status.Kind.ERROR, "Failed to get file status", err)); |
321 handlerCancelSupport.checkCancelled(); | 325 handlerCancelSupport.checkCancelled(); |
322 } catch (HgCallbackTargetException ex) { | 326 } catch (HgCallbackTargetException ex) { |
323 failure = ex; | 327 failure = ex; |
324 } catch (CancelledException ex) { | 328 } catch (CancelledException ex) { |
325 cancellation = ex; | 329 cancellation = ex; |