diff 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
line wrap: on
line diff
--- a/src/org/tmatesoft/hg/repo/HgStatusCollector.java	Thu Dec 08 15:34:13 2011 +0100
+++ b/src/org/tmatesoft/hg/repo/HgStatusCollector.java	Thu Dec 08 22:19:27 2011 +0100
@@ -271,9 +271,9 @@
 						inspector.added(copyTarget);
 					}
 				} catch (HgException ex) {
-					ex.printStackTrace();
-					// FIXME perhaps, shall record this exception to dedicated mediator and continue
+					// record exception to a mediator and continue, 
 					// for a single file not to be irresolvable obstacle for a status operation
+					inspector.invalid(r2fname, ex);
 				}
 			}
 		}
@@ -329,6 +329,7 @@
 	public static class Record implements HgStatusInspector {
 		private List<Path> modified, added, removed, clean, missing, unknown, ignored;
 		private Map<Path, Path> copied;
+		private Map<Path, Exception> failures;
 		
 		private int startRev, endRev;
 		private HgStatusCollector statusHelper;
@@ -402,6 +403,13 @@
 		public List<Path> getIgnored() {
 			return proper(ignored);
 		}
+
+		public Map<Path, Exception> getInvalid() {
+			if (failures == null) {
+				return Collections.emptyMap();
+			}
+			return Collections.unmodifiableMap(failures);
+		}
 		
 		private static List<Path> proper(List<Path> l) {
 			if (l == null) {
@@ -448,6 +456,13 @@
 		public void ignored(Path fname) {
 			ignored = doAdd(ignored, fname);
 		}
+		
+		public void invalid(Path fname, Exception ex) {
+			if (failures == null) {
+				failures = new LinkedHashMap<Path, Exception>();
+			}
+			failures.put(fname, ex);
+		}
 
 		private static List<Path> doAdd(List<Path> l, Path p) {
 			if (l == null) {