changeset 190:9b99d27aeddc

More debug printouts
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Thu, 14 Apr 2011 02:48:06 +0200
parents e9d275fb0bc0
children b777502a06f5
files cmdline/org/tmatesoft/hg/console/Bundle.java src/org/tmatesoft/hg/core/HgCloneCommand.java src/org/tmatesoft/hg/repo/HgRemoteRepository.java
diffstat 3 files changed, 19 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/cmdline/org/tmatesoft/hg/console/Bundle.java	Thu Apr 14 02:47:47 2011 +0200
+++ b/cmdline/org/tmatesoft/hg/console/Bundle.java	Thu Apr 14 02:48:06 2011 +0200
@@ -40,9 +40,12 @@
 			System.err.printf("Can't find repository in: %s\n", hgRepo.getLocation());
 			return;
 		}
-		File bundleFile = new File("/temp/hg/hg-bundle-a78c980749e3.tmp");
+		File bundleFile = new File("/temp/hg/hg-bundle-cpython.tmp");
 		HgBundle hgBundle = new HgLookup().loadBundle(bundleFile);
-//		hgBundle.dump();
+		hgBundle.inspectFiles(new HgBundle.Dump());
+		if (Boolean.parseBoolean("true")) {
+			return;
+		}
 		/* pass -R <path-to-repo-with-less-revisions-than-bundle>, e.g. for bundle with tip=168 and -R \temp\hg4j-50 with tip:159
 		+Changeset {User: ..., Comment: Integer ....}
 		+Changeset {User: ..., Comment: Approach with ...}
--- a/src/org/tmatesoft/hg/core/HgCloneCommand.java	Thu Apr 14 02:47:47 2011 +0200
+++ b/src/org/tmatesoft/hg/core/HgCloneCommand.java	Thu Apr 14 02:48:06 2011 +0200
@@ -109,8 +109,9 @@
 	// 3. process every file, using map from 3, and consult set from step 4 to ensure repo is correct
 	private static class WriteDownMate implements HgBundle.Inspector {
 		private final File hgDir;
+		private final PathRewrite storagePathHelper;
 		private FileOutputStream indexFile;
-		private final PathRewrite storagePathHelper;
+		private String filename; // human-readable name of the file being written, for log/exception purposes 
 
 		private final TreeMap<Nodeid, Integer> changelogIndexes = new TreeMap<Nodeid, Integer>();
 		private boolean collectChangelogIndexes = false;
@@ -152,7 +153,7 @@
 				base = -1;
 				offset = 0;
 				revisionSequence.clear();
-				indexFile = new FileOutputStream(new File(hgDir, "store/00changelog.i"));
+				indexFile = new FileOutputStream(new File(hgDir, filename = "store/00changelog.i"));
 				collectChangelogIndexes = true;
 			} catch (IOException ex) {
 				throw new HgBadStateException(ex);
@@ -168,6 +169,7 @@
 				collectChangelogIndexes = false;
 				indexFile.close();
 				indexFile = null;
+				filename = null;
 			} catch (IOException ex) {
 				throw new HgBadStateException(ex);
 			}
@@ -178,7 +180,7 @@
 				base = -1;
 				offset = 0;
 				revisionSequence.clear();
-				indexFile = new FileOutputStream(new File(hgDir, "store/00manifest.i"));
+				indexFile = new FileOutputStream(new File(hgDir, filename = "store/00manifest.i"));
 			} catch (IOException ex) {
 				throw new HgBadStateException(ex);
 			}
@@ -192,6 +194,7 @@
 				}
 				indexFile.close();
 				indexFile = null;
+				filename = null;
 			} catch (IOException ex) {
 				throw new HgBadStateException(ex);
 			}
@@ -204,7 +207,7 @@
 				revisionSequence.clear();
 				fncacheFiles.add("data/" + name + ".i"); // FIXME this is pure guess, 
 				// need to investigate more how filenames are kept in fncache
-				File file = new File(hgDir, storagePathHelper.rewrite(name));
+				File file = new File(hgDir, filename = storagePathHelper.rewrite(name));
 				file.getParentFile().mkdirs();
 				indexFile = new FileOutputStream(file);
 			} catch (IOException ex) {
@@ -220,6 +223,7 @@
 				}
 				indexFile.close();
 				indexFile = null;
+				filename = null;
 			} catch (IOException ex) {
 				throw new HgBadStateException(ex);
 			}
@@ -235,7 +239,7 @@
 					}
 				}
 			}
-			throw new HgBadStateException(String.format("Can't find index of %s", p.shortNotation()));
+			throw new HgBadStateException(String.format("Can't find index of %s for file %s", p.shortNotation(), filename));
 		}
 
 		public boolean element(GroupElement ge) {
@@ -252,7 +256,7 @@
 				byte[] calculated = dh.sha1(p1, p2, content).asBinary();
 				final Nodeid node = ge.node();
 				if (!node.equalsTo(calculated)) {
-					throw new HgBadStateException("Checksum failed");
+					throw new HgBadStateException(String.format("Checksum failed: expected %s, calculated %s. File %s", node, calculated, filename));
 				}
 				final int link;
 				if (collectChangelogIndexes) {
@@ -261,7 +265,7 @@
 				} else {
 					Integer csRev = changelogIndexes.get(ge.cset());
 					if (csRev == null) {
-						throw new HgBadStateException(String.format("Changelog doesn't contain revision %s", ge.cset().shortNotation()));
+						throw new HgBadStateException(String.format("Changelog doesn't contain revision %s of %s", ge.cset().shortNotation(), filename));
 					}
 					link = csRev.intValue();
 				}
--- a/src/org/tmatesoft/hg/repo/HgRemoteRepository.java	Thu Apr 14 02:47:47 2011 +0200
+++ b/src/org/tmatesoft/hg/repo/HgRemoteRepository.java	Thu Apr 14 02:48:06 2011 +0200
@@ -334,6 +334,9 @@
 				dumpResponseHeader(u, c);
 			}
 			File tf = writeBundle(c.getInputStream(), false, "HG10GZ" /*didn't see any other that zip*/);
+			if (debug) {
+				System.out.printf("Wrote bundle %s for roots %s", tf, sb);
+			}
 			return getLookupHelper().loadBundle(tf);
 		} catch (MalformedURLException ex) {
 			throw new HgException(ex);