Mercurial > hg4j
comparison src/com/tmate/hgkit/console/Bundle.java @ 32:42585c7cd641
Initial dump of a bundle
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Thu, 13 Jan 2011 03:41:10 +0100 |
parents | |
children | 51bc56c0addd |
comparison
equal
deleted
inserted
replaced
31:346b66add79d | 32:42585c7cd641 |
---|---|
1 /* | |
2 * Copyright (c) 2011 Artem Tikhomirov | |
3 */ | |
4 package com.tmate.hgkit.console; | |
5 | |
6 import java.io.File; | |
7 | |
8 import com.tmate.hgkit.fs.DataAccess; | |
9 import com.tmate.hgkit.fs.DataAccessProvider; | |
10 import com.tmate.hgkit.ll.Nodeid; | |
11 | |
12 /** | |
13 * @see http://mercurial.selenic.com/wiki/BundleFormat | |
14 * | |
15 * @author artem | |
16 */ | |
17 public class Bundle { | |
18 | |
19 public static void main(String[] args) throws Exception { | |
20 File bundleFile = new File("/temp/hg/hg-bundle-a78c980749e3.tmp"); | |
21 DataAccessProvider dap = new DataAccessProvider(); | |
22 DataAccess da = dap.create(bundleFile); | |
23 while (!da.isEmpty()) { | |
24 int len = da.readInt(); | |
25 while (len > 4) { | |
26 byte[] nb = new byte[20]; | |
27 da.readBytes(nb, 0, 20); | |
28 Nodeid node = new Nodeid(nb, true); | |
29 da.readBytes(nb, 0, 20); | |
30 Nodeid p1 = new Nodeid(nb, true); | |
31 da.readBytes(nb, 0, 20); | |
32 Nodeid p2 = new Nodeid(nb, true); | |
33 da.readBytes(nb, 0, 20); | |
34 Nodeid cs = new Nodeid(nb, true); | |
35 da.skip(len - 84); | |
36 System.out.printf("%6d %s %s %s %s\n", len, node, p1, p2, cs); | |
37 len = da.isEmpty() ? 0 : da.readInt(); | |
38 } | |
39 System.out.println("Group done"); | |
40 } | |
41 } | |
42 } |