changeset 32:42585c7cd641

Initial dump of a bundle
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Thu, 13 Jan 2011 03:41:10 +0100
parents 346b66add79d
children 565ce0835674
files src/com/tmate/hgkit/console/Bundle.java
diffstat 1 files changed, 42 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/com/tmate/hgkit/console/Bundle.java	Thu Jan 13 03:41:10 2011 +0100
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2011 Artem Tikhomirov 
+ */
+package com.tmate.hgkit.console;
+
+import java.io.File;
+
+import com.tmate.hgkit.fs.DataAccess;
+import com.tmate.hgkit.fs.DataAccessProvider;
+import com.tmate.hgkit.ll.Nodeid;
+
+/**
+ * @see http://mercurial.selenic.com/wiki/BundleFormat
+ *
+ * @author artem
+ */
+public class Bundle {
+
+	public static void main(String[] args) throws Exception {
+		File bundleFile = new File("/temp/hg/hg-bundle-a78c980749e3.tmp");
+		DataAccessProvider dap = new DataAccessProvider();
+		DataAccess da = dap.create(bundleFile);
+		while (!da.isEmpty()) {
+			int len = da.readInt();
+			while (len > 4) {
+				byte[] nb = new byte[20];
+				da.readBytes(nb, 0, 20);
+				Nodeid node = new Nodeid(nb, true);
+				da.readBytes(nb, 0, 20);
+				Nodeid p1 = new Nodeid(nb, true);
+				da.readBytes(nb, 0, 20);
+				Nodeid p2 = new Nodeid(nb, true);
+				da.readBytes(nb, 0, 20);
+				Nodeid cs = new Nodeid(nb, true);
+				da.skip(len - 84);
+				System.out.printf("%6d %s %s %s %s\n", len, node, p1, p2, cs);
+				len = da.isEmpty() ? 0 : da.readInt();
+			}
+			System.out.println("Group done");
+		}
+	}
+}