tikhomirov@32: /* tikhomirov@32: * Copyright (c) 2011 Artem Tikhomirov tikhomirov@32: */ tikhomirov@32: package com.tmate.hgkit.console; tikhomirov@32: tikhomirov@32: import java.io.File; tikhomirov@32: tikhomirov@32: import com.tmate.hgkit.fs.DataAccess; tikhomirov@32: import com.tmate.hgkit.fs.DataAccessProvider; tikhomirov@32: import com.tmate.hgkit.ll.Nodeid; tikhomirov@32: tikhomirov@32: /** tikhomirov@32: * @see http://mercurial.selenic.com/wiki/BundleFormat tikhomirov@32: * tikhomirov@32: * @author artem tikhomirov@32: */ tikhomirov@32: public class Bundle { tikhomirov@32: tikhomirov@32: public static void main(String[] args) throws Exception { tikhomirov@32: File bundleFile = new File("/temp/hg/hg-bundle-a78c980749e3.tmp"); tikhomirov@32: DataAccessProvider dap = new DataAccessProvider(); tikhomirov@32: DataAccess da = dap.create(bundleFile); tikhomirov@34: try { tikhomirov@34: while (!da.isEmpty()) { tikhomirov@34: int len = da.readInt(); tikhomirov@34: while (len > 4) { tikhomirov@34: byte[] nb = new byte[80]; tikhomirov@34: da.readBytes(nb, 0, 80); tikhomirov@34: Nodeid node = Nodeid.fromBinary(nb, 0); tikhomirov@34: Nodeid p1 = Nodeid.fromBinary(nb, 20); tikhomirov@34: Nodeid p2 = Nodeid.fromBinary(nb, 40); tikhomirov@34: Nodeid cs = Nodeid.fromBinary(nb, 60); tikhomirov@34: da.skip(len - 84); tikhomirov@34: System.out.printf("%6d %s %s %s %s\n", len, node, p1, p2, cs); tikhomirov@34: len = da.isEmpty() ? 0 : da.readInt(); tikhomirov@34: } tikhomirov@34: System.out.println("Group done"); tikhomirov@32: } tikhomirov@34: } finally { tikhomirov@34: da.done(); tikhomirov@32: } tikhomirov@32: } tikhomirov@32: }