comparison src/org/tmatesoft/hg/repo/HgStatusCollector.java @ 360:150500515714

Report non-critical errors during status operation to handler/inspector
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Thu, 08 Dec 2011 22:19:27 +0100
parents 5f9073eabf06
children 189dc6dc1c3e
comparison
equal deleted inserted replaced
359:1d9bcab9c50f 360:150500515714
269 inspector.copied(getPathPool().path(copyOrigin) /*pipe through pool, just in case*/, copyTarget); 269 inspector.copied(getPathPool().path(copyOrigin) /*pipe through pool, just in case*/, copyTarget);
270 } else { 270 } else {
271 inspector.added(copyTarget); 271 inspector.added(copyTarget);
272 } 272 }
273 } catch (HgException ex) { 273 } catch (HgException ex) {
274 ex.printStackTrace(); 274 // record exception to a mediator and continue,
275 // FIXME perhaps, shall record this exception to dedicated mediator and continue
276 // for a single file not to be irresolvable obstacle for a status operation 275 // for a single file not to be irresolvable obstacle for a status operation
276 inspector.invalid(r2fname, ex);
277 } 277 }
278 } 278 }
279 } 279 }
280 for (Path r1fname : r1Files) { 280 for (Path r1fname : r1Files) {
281 if (scope.accept(r1fname)) { 281 if (scope.accept(r1fname)) {
327 * from {@link #getAdded()}. 327 * from {@link #getAdded()}.
328 */ 328 */
329 public static class Record implements HgStatusInspector { 329 public static class Record implements HgStatusInspector {
330 private List<Path> modified, added, removed, clean, missing, unknown, ignored; 330 private List<Path> modified, added, removed, clean, missing, unknown, ignored;
331 private Map<Path, Path> copied; 331 private Map<Path, Path> copied;
332 private Map<Path, Exception> failures;
332 333
333 private int startRev, endRev; 334 private int startRev, endRev;
334 private HgStatusCollector statusHelper; 335 private HgStatusCollector statusHelper;
335 336
336 // XXX StatusCollector may additionally initialize Record instance to speed lookup of changed file revisions 337 // XXX StatusCollector may additionally initialize Record instance to speed lookup of changed file revisions
400 } 401 }
401 402
402 public List<Path> getIgnored() { 403 public List<Path> getIgnored() {
403 return proper(ignored); 404 return proper(ignored);
404 } 405 }
406
407 public Map<Path, Exception> getInvalid() {
408 if (failures == null) {
409 return Collections.emptyMap();
410 }
411 return Collections.unmodifiableMap(failures);
412 }
405 413
406 private static List<Path> proper(List<Path> l) { 414 private static List<Path> proper(List<Path> l) {
407 if (l == null) { 415 if (l == null) {
408 return Collections.emptyList(); 416 return Collections.emptyList();
409 } 417 }
446 } 454 }
447 455
448 public void ignored(Path fname) { 456 public void ignored(Path fname) {
449 ignored = doAdd(ignored, fname); 457 ignored = doAdd(ignored, fname);
450 } 458 }
459
460 public void invalid(Path fname, Exception ex) {
461 if (failures == null) {
462 failures = new LinkedHashMap<Path, Exception>();
463 }
464 failures.put(fname, ex);
465 }
451 466
452 private static List<Path> doAdd(List<Path> l, Path p) { 467 private static List<Path> doAdd(List<Path> l, Path p) {
453 if (l == null) { 468 if (l == null) {
454 l = new LinkedList<Path>(); 469 l = new LinkedList<Path>();
455 } 470 }