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