comparison src/com/tmate/hgkit/console/Bundle.java @ 34:51bc56c0addd

Static Nodeid creation methods to reuse NULL id
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Thu, 13 Jan 2011 04:03:13 +0100
parents 42585c7cd641
children 6061aa826a9e
comparison
equal deleted inserted replaced
33:565ce0835674 34:51bc56c0addd
18 18
19 public static void main(String[] args) throws Exception { 19 public static void main(String[] args) throws Exception {
20 File bundleFile = new File("/temp/hg/hg-bundle-a78c980749e3.tmp"); 20 File bundleFile = new File("/temp/hg/hg-bundle-a78c980749e3.tmp");
21 DataAccessProvider dap = new DataAccessProvider(); 21 DataAccessProvider dap = new DataAccessProvider();
22 DataAccess da = dap.create(bundleFile); 22 DataAccess da = dap.create(bundleFile);
23 while (!da.isEmpty()) { 23 try {
24 int len = da.readInt(); 24 while (!da.isEmpty()) {
25 while (len > 4) { 25 int len = da.readInt();
26 byte[] nb = new byte[20]; 26 while (len > 4) {
27 da.readBytes(nb, 0, 20); 27 byte[] nb = new byte[80];
28 Nodeid node = new Nodeid(nb, true); 28 da.readBytes(nb, 0, 80);
29 da.readBytes(nb, 0, 20); 29 Nodeid node = Nodeid.fromBinary(nb, 0);
30 Nodeid p1 = new Nodeid(nb, true); 30 Nodeid p1 = Nodeid.fromBinary(nb, 20);
31 da.readBytes(nb, 0, 20); 31 Nodeid p2 = Nodeid.fromBinary(nb, 40);
32 Nodeid p2 = new Nodeid(nb, true); 32 Nodeid cs = Nodeid.fromBinary(nb, 60);
33 da.readBytes(nb, 0, 20); 33 da.skip(len - 84);
34 Nodeid cs = new Nodeid(nb, true); 34 System.out.printf("%6d %s %s %s %s\n", len, node, p1, p2, cs);
35 da.skip(len - 84); 35 len = da.isEmpty() ? 0 : da.readInt();
36 System.out.printf("%6d %s %s %s %s\n", len, node, p1, p2, cs); 36 }
37 len = da.isEmpty() ? 0 : da.readInt(); 37 System.out.println("Group done");
38 } 38 }
39 System.out.println("Group done"); 39 } finally {
40 da.done();
40 } 41 }
41 } 42 }
42 } 43 }