diff cmdline/org/tmatesoft/hg/console/Main.java @ 348:a0864b2892cd

Expose errors reading mercurial control files with exception
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Thu, 24 Nov 2011 02:57:03 +0100
parents 58725dd511b3
children 33eaed1ad130
line wrap: on
line diff
--- a/cmdline/org/tmatesoft/hg/console/Main.java	Tue Nov 22 05:25:57 2011 +0100
+++ b/cmdline/org/tmatesoft/hg/console/Main.java	Thu Nov 24 02:57:03 2011 +0100
@@ -420,9 +420,22 @@
 			System.out.println("Ignored " + toCheck[i] + ": " + ignore.isIgnored(Path.create(toCheck[i])));
 		}
 	}
+
+	static class DirstateDump implements HgDirstate.Inspector {
+		private final char[] x = new char[] {'n', 'a', 'r', 'm' };
+
+		public boolean next(EntryKind kind, Record entry) {
+			System.out.printf("%c %3o%6d %30tc\t\t%s", x[kind.ordinal()], entry.mode(), entry.size(), (long) entry.modificationTime() * 1000, entry.name());
+			if (entry.copySource() != null) {
+				System.out.printf(" --> %s", entry.copySource());
+			}
+			System.out.println();
+			return true;
+		}
+	}
 	
-	private void dumpDirstate() {
-		new HgInternals(hgRepo).dumpDirstate();
+	private void dumpDirstate() throws Exception {
+		new HgInternals(hgRepo).getDirstate().walk(new DirstateDump());
 		HgWorkingCopyStatusCollector wcc = HgWorkingCopyStatusCollector.create(hgRepo, new Path.Matcher.Any());
 		wcc.getDirstate().walk(new HgDirstate.Inspector() {
 			
@@ -508,8 +521,6 @@
 	}
 
 	private void bunchOfTests() throws Exception {
-		HgInternals debug = new HgInternals(hgRepo);
-		debug.dumpDirstate();
 		final StatusDump dump = new StatusDump();
 		dump.showIgnored = false;
 		dump.showClean = false;