annotate src/com/tmate/hgkit/ll/HgBundle.java @ 51:9429c7bd1920 wrap-data-access

Try DataAccess to reach revision data instead of plain byte arrays
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Sun, 16 Jan 2011 01:20:26 +0100
parents b01500fe2604
children
rev   line source
36
205f9b59b400 Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
1 /*
205f9b59b400 Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
2 * Copyright (c) 2011 Artem Tikhomirov
205f9b59b400 Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
3 */
205f9b59b400 Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
4 package com.tmate.hgkit.ll;
205f9b59b400 Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
5
205f9b59b400 Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
6 import java.io.File;
205f9b59b400 Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
7 import java.io.IOException;
205f9b59b400 Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
8 import java.util.LinkedList;
205f9b59b400 Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
9 import java.util.List;
205f9b59b400 Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
10
51
9429c7bd1920 Try DataAccess to reach revision data instead of plain byte arrays
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 47
diff changeset
11 import com.tmate.hgkit.fs.ByteArrayDataAccess;
36
205f9b59b400 Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
12 import com.tmate.hgkit.fs.DataAccess;
205f9b59b400 Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
13 import com.tmate.hgkit.fs.DataAccessProvider;
205f9b59b400 Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
14
205f9b59b400 Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
15 /**
205f9b59b400 Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
16 * @see http://mercurial.selenic.com/wiki/BundleFormat
205f9b59b400 Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
17 *
205f9b59b400 Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
18 * @author artem
205f9b59b400 Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
19 */
205f9b59b400 Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
20 public class HgBundle {
205f9b59b400 Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
21
205f9b59b400 Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
22 private final File bundleFile;
205f9b59b400 Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
23 private final DataAccessProvider accessProvider;
205f9b59b400 Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
24
205f9b59b400 Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
25 public HgBundle(DataAccessProvider dap, File bundle) {
205f9b59b400 Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
26 accessProvider = dap;
205f9b59b400 Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
27 bundleFile = bundle;
205f9b59b400 Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
28 }
205f9b59b400 Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
29
37
e45e75e22523 Parse changesets from bundle's changelog group. Refactor Revlog to provide access to revision's raw content
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 36
diff changeset
30 public void changes(HgRepository hgRepo) throws IOException {
e45e75e22523 Parse changesets from bundle's changelog group. Refactor Revlog to provide access to revision's raw content
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 36
diff changeset
31 DataAccess da = accessProvider.create(bundleFile);
41
858d1b2458cb Check integrity for bundle changelog. Sort nodeids when calculating hash
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 39
diff changeset
32 DigestHelper dh = new DigestHelper();
37
e45e75e22523 Parse changesets from bundle's changelog group. Refactor Revlog to provide access to revision's raw content
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 36
diff changeset
33 try {
e45e75e22523 Parse changesets from bundle's changelog group. Refactor Revlog to provide access to revision's raw content
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 36
diff changeset
34 List<GroupElement> changelogGroup = readGroup(da);
39
4e9b66b07a28 Check changelog group starts with proper (known) base
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 37
diff changeset
35 if (changelogGroup.isEmpty()) {
4e9b66b07a28 Check changelog group starts with proper (known) base
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 37
diff changeset
36 throw new IllegalStateException("No changelog group in the bundle"); // XXX perhaps, just be silent and/or log?
4e9b66b07a28 Check changelog group starts with proper (known) base
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 37
diff changeset
37 }
4e9b66b07a28 Check changelog group starts with proper (known) base
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 37
diff changeset
38 // XXX in fact, bundle not necessarily starts with the first revision missing in hgRepo
4e9b66b07a28 Check changelog group starts with proper (known) base
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 37
diff changeset
39 // need to 'scroll' till the last one common.
4e9b66b07a28 Check changelog group starts with proper (known) base
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 37
diff changeset
40 final Nodeid base = changelogGroup.get(0).firstParent();
4e9b66b07a28 Check changelog group starts with proper (known) base
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 37
diff changeset
41 if (!hgRepo.getChangelog().isKnown(base)) {
4e9b66b07a28 Check changelog group starts with proper (known) base
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 37
diff changeset
42 throw new IllegalArgumentException("unknown parent");
4e9b66b07a28 Check changelog group starts with proper (known) base
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 37
diff changeset
43 }
4e9b66b07a28 Check changelog group starts with proper (known) base
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 37
diff changeset
44 // BundleFormat wiki says:
4e9b66b07a28 Check changelog group starts with proper (known) base
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 37
diff changeset
45 // Each Changelog entry patches the result of all previous patches
4e9b66b07a28 Check changelog group starts with proper (known) base
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 37
diff changeset
46 // (the previous, or parent patch of a given patch p is the patch that has a node equal to p's p1 field)
4e9b66b07a28 Check changelog group starts with proper (known) base
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 37
diff changeset
47 byte[] baseRevContent = hgRepo.getChangelog().content(base);
37
e45e75e22523 Parse changesets from bundle's changelog group. Refactor Revlog to provide access to revision's raw content
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 36
diff changeset
48 for (GroupElement ge : changelogGroup) {
51
9429c7bd1920 Try DataAccess to reach revision data instead of plain byte arrays
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 47
diff changeset
49 byte[] csetContent = RevlogStream.apply(new ByteArrayDataAccess(baseRevContent), -1, ge.patches);
42
92c3d0920d58 Real integrity check, with exception. DigestHelper refactored to accomodate new needs
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 41
diff changeset
50 dh = dh.sha1(ge.firstParent(), ge.secondParent(), csetContent); // XXX ge may give me access to byte[] content of nodeid directly, perhaps, I don't need DH to be friend of Nodeid?
92c3d0920d58 Real integrity check, with exception. DigestHelper refactored to accomodate new needs
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 41
diff changeset
51 if (!ge.node().equalsTo(dh.asBinary())) {
92c3d0920d58 Real integrity check, with exception. DigestHelper refactored to accomodate new needs
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 41
diff changeset
52 throw new IllegalStateException("Integrity check failed on " + bundleFile + ", node:" + ge.node());
92c3d0920d58 Real integrity check, with exception. DigestHelper refactored to accomodate new needs
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 41
diff changeset
53 }
37
e45e75e22523 Parse changesets from bundle's changelog group. Refactor Revlog to provide access to revision's raw content
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 36
diff changeset
54 Changeset cs = Changeset.parse(csetContent, 0, csetContent.length);
47
b01500fe2604 Log command output to match 'hg log'
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 45
diff changeset
55 System.out.println(cs.toString());
37
e45e75e22523 Parse changesets from bundle's changelog group. Refactor Revlog to provide access to revision's raw content
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 36
diff changeset
56 baseRevContent = csetContent;
e45e75e22523 Parse changesets from bundle's changelog group. Refactor Revlog to provide access to revision's raw content
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 36
diff changeset
57 }
e45e75e22523 Parse changesets from bundle's changelog group. Refactor Revlog to provide access to revision's raw content
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 36
diff changeset
58 } finally {
e45e75e22523 Parse changesets from bundle's changelog group. Refactor Revlog to provide access to revision's raw content
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 36
diff changeset
59 da.done();
e45e75e22523 Parse changesets from bundle's changelog group. Refactor Revlog to provide access to revision's raw content
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 36
diff changeset
60 }
e45e75e22523 Parse changesets from bundle's changelog group. Refactor Revlog to provide access to revision's raw content
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 36
diff changeset
61 }
e45e75e22523 Parse changesets from bundle's changelog group. Refactor Revlog to provide access to revision's raw content
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 36
diff changeset
62
e45e75e22523 Parse changesets from bundle's changelog group. Refactor Revlog to provide access to revision's raw content
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 36
diff changeset
63 public void dump() throws IOException {
36
205f9b59b400 Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
64 DataAccess da = accessProvider.create(bundleFile);
205f9b59b400 Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
65 try {
205f9b59b400 Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
66 LinkedList<String> names = new LinkedList<String>();
205f9b59b400 Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
67 if (!da.isEmpty()) {
205f9b59b400 Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
68 System.out.println("Changelog group");
205f9b59b400 Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
69 List<GroupElement> changelogGroup = readGroup(da);
205f9b59b400 Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
70 for (GroupElement ge : changelogGroup) {
37
e45e75e22523 Parse changesets from bundle's changelog group. Refactor Revlog to provide access to revision's raw content
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 36
diff changeset
71 System.out.printf(" %s %s %s %s; patches:%d\n", ge.node(), ge.firstParent(), ge.secondParent(), ge.cset(), ge.patches.size());
36
205f9b59b400 Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
72 }
205f9b59b400 Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
73 System.out.println("Manifest group");
205f9b59b400 Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
74 List<GroupElement> manifestGroup = readGroup(da);
205f9b59b400 Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
75 for (GroupElement ge : manifestGroup) {
37
e45e75e22523 Parse changesets from bundle's changelog group. Refactor Revlog to provide access to revision's raw content
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 36
diff changeset
76 System.out.printf(" %s %s %s %s; patches:%d\n", ge.node(), ge.firstParent(), ge.secondParent(), ge.cset(), ge.patches.size());
36
205f9b59b400 Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
77 }
205f9b59b400 Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
78 while (!da.isEmpty()) {
205f9b59b400 Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
79 int fnameLen = da.readInt();
205f9b59b400 Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
80 if (fnameLen <= 4) {
205f9b59b400 Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
81 break; // null chunk, the last one.
205f9b59b400 Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
82 }
205f9b59b400 Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
83 byte[] fname = new byte[fnameLen - 4];
205f9b59b400 Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
84 da.readBytes(fname, 0, fname.length);
205f9b59b400 Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
85 names.add(new String(fname));
205f9b59b400 Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
86 List<GroupElement> fileGroup = readGroup(da);
205f9b59b400 Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
87 System.out.println(names.getLast());
205f9b59b400 Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
88 for (GroupElement ge : fileGroup) {
37
e45e75e22523 Parse changesets from bundle's changelog group. Refactor Revlog to provide access to revision's raw content
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 36
diff changeset
89 System.out.printf(" %s %s %s %s; patches:%d\n", ge.node(), ge.firstParent(), ge.secondParent(), ge.cset(), ge.patches.size());
36
205f9b59b400 Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
90 }
205f9b59b400 Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
91 }
205f9b59b400 Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
92 }
205f9b59b400 Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
93 System.out.println(names.size());
205f9b59b400 Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
94 for (String s : names) {
205f9b59b400 Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
95 System.out.println(s);
205f9b59b400 Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
96 }
205f9b59b400 Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
97 } finally {
205f9b59b400 Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
98 da.done();
205f9b59b400 Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
99 }
205f9b59b400 Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
100 }
205f9b59b400 Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
101
205f9b59b400 Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
102 private static List<GroupElement> readGroup(DataAccess da) throws IOException {
205f9b59b400 Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
103 int len = da.readInt();
205f9b59b400 Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
104 LinkedList<GroupElement> rv = new LinkedList<HgBundle.GroupElement>();
205f9b59b400 Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
105 while (len > 4 && !da.isEmpty()) {
205f9b59b400 Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
106 byte[] nb = new byte[80];
205f9b59b400 Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
107 da.readBytes(nb, 0, 80);
205f9b59b400 Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
108 int dataLength = len-84;
205f9b59b400 Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
109 LinkedList<RevlogStream.PatchRecord> patches = new LinkedList<RevlogStream.PatchRecord>();
205f9b59b400 Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
110 while (dataLength > 0) {
205f9b59b400 Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
111 RevlogStream.PatchRecord pr = RevlogStream.PatchRecord.read(da);
205f9b59b400 Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
112 patches.add(pr);
205f9b59b400 Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
113 dataLength -= pr.len + 12;
205f9b59b400 Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
114 }
205f9b59b400 Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
115 rv.add(new GroupElement(nb, patches));
205f9b59b400 Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
116 len = da.isEmpty() ? 0 : da.readInt();
205f9b59b400 Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
117 }
205f9b59b400 Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
118 return rv;
205f9b59b400 Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
119 }
205f9b59b400 Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
120
205f9b59b400 Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
121 static class GroupElement {
205f9b59b400 Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
122 private byte[] header; // byte[80] takes 120 bytes, 4 Nodeids - 192
205f9b59b400 Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
123 private List<RevlogStream.PatchRecord> patches;
205f9b59b400 Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
124
205f9b59b400 Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
125 GroupElement(byte[] fourNodeids, List<RevlogStream.PatchRecord> patchList) {
205f9b59b400 Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
126 assert fourNodeids != null && fourNodeids.length == 80;
205f9b59b400 Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
127 // patchList.size() > 0
205f9b59b400 Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
128 header = fourNodeids;
205f9b59b400 Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
129 patches = patchList;
205f9b59b400 Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
130 }
205f9b59b400 Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
131 public Nodeid node() {
205f9b59b400 Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
132 return Nodeid.fromBinary(header, 0);
205f9b59b400 Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
133 }
205f9b59b400 Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
134 public Nodeid firstParent() {
205f9b59b400 Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
135 return Nodeid.fromBinary(header, 20);
205f9b59b400 Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
136 }
205f9b59b400 Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
137 public Nodeid secondParent() {
205f9b59b400 Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
138 return Nodeid.fromBinary(header, 40);
205f9b59b400 Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
139 }
37
e45e75e22523 Parse changesets from bundle's changelog group. Refactor Revlog to provide access to revision's raw content
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 36
diff changeset
140 public Nodeid cset() { // cs seems to be changeset
36
205f9b59b400 Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
141 return Nodeid.fromBinary(header, 60);
205f9b59b400 Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
142 }
205f9b59b400 Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
143 }
205f9b59b400 Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
144 }