annotate hg4j/src/main/java/org/tmatesoft/hg/repo/HgBundle.java @ 213:6ec4af642ba8 gradle

Project uses Gradle for build - actual changes
author Alexander Kitaev <kitaev@gmail.com>
date Tue, 10 May 2011 10:52:53 +0200
parents
children
rev   line source
213
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
1 /*
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
2 * Copyright (c) 2011 TMate Software Ltd
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
3 *
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
4 * This program is free software; you can redistribute it and/or modify
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
5 * it under the terms of the GNU General Public License as published by
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
6 * the Free Software Foundation; version 2 of the License.
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
7 *
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
8 * This program is distributed in the hope that it will be useful,
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
11 * GNU General Public License for more details.
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
12 *
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
13 * For information on how to redistribute this software under
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
14 * the terms of a license other than GNU General Public License
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
15 * contact TMate Software at support@hg4j.com
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
16 */
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
17 package org.tmatesoft.hg.repo;
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
18
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
19 import static org.tmatesoft.hg.core.Nodeid.NULL;
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
20
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
21 import java.io.File;
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
22 import java.io.IOException;
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
23 import java.util.LinkedList;
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
24 import java.util.List;
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
25
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
26 import org.tmatesoft.hg.core.HgBadStateException;
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
27 import org.tmatesoft.hg.core.HgException;
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
28 import org.tmatesoft.hg.core.Nodeid;
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
29 import org.tmatesoft.hg.internal.ByteArrayChannel;
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
30 import org.tmatesoft.hg.internal.ByteArrayDataAccess;
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
31 import org.tmatesoft.hg.internal.DataAccess;
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
32 import org.tmatesoft.hg.internal.DataAccessProvider;
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
33 import org.tmatesoft.hg.internal.DigestHelper;
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
34 import org.tmatesoft.hg.internal.InflaterDataAccess;
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
35 import org.tmatesoft.hg.internal.RevlogStream;
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
36 import org.tmatesoft.hg.repo.HgChangelog.RawChangeset;
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
37 import org.tmatesoft.hg.util.CancelledException;
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
38
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
39 /**
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
40 * @see http://mercurial.selenic.com/wiki/BundleFormat
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
41 *
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
42 * @author Artem Tikhomirov
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
43 * @author TMate Software Ltd.
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
44 */
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
45 public class HgBundle {
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
46
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
47 private final File bundleFile;
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
48 private final DataAccessProvider accessProvider;
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
49
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
50 HgBundle(DataAccessProvider dap, File bundle) {
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
51 accessProvider = dap;
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
52 bundleFile = bundle;
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
53 }
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
54
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
55 private DataAccess getDataStream() throws IOException {
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
56 DataAccess da = accessProvider.create(bundleFile);
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
57 byte[] signature = new byte[6];
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
58 if (da.length() > 6) {
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
59 da.readBytes(signature, 0, 6);
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
60 if (signature[0] == 'H' && signature[1] == 'G' && signature[2] == '1' && signature[3] == '0') {
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
61 if (signature[4] == 'G' && signature[5] == 'Z') {
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
62 return new InflaterDataAccess(da, 6, da.length() - 6);
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
63 }
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
64 if (signature[4] == 'B' && signature[5] == 'Z') {
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
65 throw HgRepository.notImplemented();
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
66 }
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
67 if (signature[4] != 'U' || signature[5] != 'N') {
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
68 throw new HgBadStateException("Bad bundle signature:" + new String(signature));
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
69 }
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
70 // "...UN", fall-through
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
71 } else {
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
72 da.reset();
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
73 }
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
74 }
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
75 return da;
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
76 }
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
77
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
78 private int uses = 0;
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
79 public HgBundle link() {
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
80 uses++;
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
81 return this;
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
82 }
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
83 public void unlink() {
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
84 uses--;
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
85 if (uses == 0 && bundleFile != null) {
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
86 bundleFile.deleteOnExit();
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
87 }
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
88 }
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
89 public boolean inUse() {
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
90 return uses > 0;
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
91 }
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
92
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
93 /**
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
94 * Get changes recorded in the bundle that are missing from the supplied repository.
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
95 * @param hgRepo repository that shall possess base revision for this bundle
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
96 * @param inspector callback to get each changeset found
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
97 */
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
98 public void changes(final HgRepository hgRepo, final HgChangelog.Inspector inspector) throws HgException, IOException {
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
99 Inspector bundleInsp = new Inspector() {
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
100 DigestHelper dh = new DigestHelper();
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
101 boolean emptyChangelog = true;
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
102 private DataAccess prevRevContent;
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
103 private int revisionIndex;
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
104
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
105 public void changelogStart() {
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
106 emptyChangelog = true;
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
107 revisionIndex = 0;
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
108 }
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
109
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
110 public void changelogEnd() {
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
111 if (emptyChangelog) {
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
112 throw new IllegalStateException("No changelog group in the bundle"); // XXX perhaps, just be silent and/or log?
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
113 }
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
114 }
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
115
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
116 /*
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
117 * Despite that BundleFormat wiki says: "Each Changelog entry patches the result of all previous patches
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
118 * (the previous, or parent patch of a given patch p is the patch that has a node equal to p's p1 field)",
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
119 * it seems not to hold true. Instead, each entry patches previous one, regardless of whether the one
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
120 * before is its parent (i.e. ge.firstParent()) or not.
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
121 *
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
122 Actual state in the changelog.i
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
123 Index Offset Flags Packed Actual Base Rev Link Rev Parent1 Parent2 nodeid
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
124 50: 9212 0 209 329 48 50 49 -1 f1db8610da62a3e0beb8d360556ee1fd6eb9885e
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
125 51: 9421 0 278 688 48 51 50 -1 9429c7bd1920fab164a9d2b621d38d57bcb49ae0
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
126 52: 9699 0 154 179 52 52 50 -1 30bd389788464287cee22ccff54c330a4b715de5
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
127 53: 9853 0 133 204 52 53 51 52 a6f39e595b2b54f56304470269a936ead77f5725
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
128 54: 9986 0 156 182 54 54 52 -1 fd4f2c98995beb051070630c272a9be87bef617d
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
129
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
130 Excerpt from bundle (nodeid, p1, p2, cs):
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
131 f1db8610da62a3e0beb8d360556ee1fd6eb9885e 26e3eeaa39623de552b45ee1f55c14f36460f220 0000000000000000000000000000000000000000 f1db8610da62a3e0beb8d360556ee1fd6eb9885e; patches:4
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
132 9429c7bd1920fab164a9d2b621d38d57bcb49ae0 f1db8610da62a3e0beb8d360556ee1fd6eb9885e 0000000000000000000000000000000000000000 9429c7bd1920fab164a9d2b621d38d57bcb49ae0; patches:3
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
133 > 30bd389788464287cee22ccff54c330a4b715de5 f1db8610da62a3e0beb8d360556ee1fd6eb9885e 0000000000000000000000000000000000000000 30bd389788464287cee22ccff54c330a4b715de5; patches:3
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
134 a6f39e595b2b54f56304470269a936ead77f5725 9429c7bd1920fab164a9d2b621d38d57bcb49ae0 30bd389788464287cee22ccff54c330a4b715de5 a6f39e595b2b54f56304470269a936ead77f5725; patches:3
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
135 fd4f2c98995beb051070630c272a9be87bef617d 30bd389788464287cee22ccff54c330a4b715de5 0000000000000000000000000000000000000000 fd4f2c98995beb051070630c272a9be87bef617d; patches:3
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
136
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
137 To recreate 30bd..e5, one have to take content of 9429..e0, not its p1 f1db..5e
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
138 */
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
139 public boolean element(GroupElement ge) {
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
140 emptyChangelog = false;
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
141 HgChangelog changelog = hgRepo.getChangelog();
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
142 try {
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
143 if (prevRevContent == null) {
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
144 if (NULL.equals(ge.firstParent()) && NULL.equals(ge.secondParent())) {
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
145 prevRevContent = new ByteArrayDataAccess(new byte[0]);
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
146 } else {
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
147 final Nodeid base = ge.firstParent();
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
148 if (!changelog.isKnown(base) /*only first parent, that's Bundle contract*/) {
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
149 throw new IllegalStateException(String.format("Revision %s needs a parent %s, which is missing in the supplied repo %s", ge.node().shortNotation(), base.shortNotation(), hgRepo.toString()));
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
150 }
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
151 ByteArrayChannel bac = new ByteArrayChannel();
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
152 changelog.rawContent(base, bac); // FIXME get DataAccess directly, to avoid
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
153 // extra byte[] (inside ByteArrayChannel) duplication just for the sake of subsequent ByteArrayDataChannel wrap.
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
154 prevRevContent = new ByteArrayDataAccess(bac.toArray());
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
155 }
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
156 }
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
157 //
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
158 byte[] csetContent = ge.apply(prevRevContent);
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
159 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?
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
160 if (!ge.node().equalsTo(dh.asBinary())) {
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
161 throw new IllegalStateException("Integrity check failed on " + bundleFile + ", node:" + ge.node());
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
162 }
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
163 ByteArrayDataAccess csetDataAccess = new ByteArrayDataAccess(csetContent);
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
164 RawChangeset cs = RawChangeset.parse(csetDataAccess);
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
165 inspector.next(revisionIndex++, ge.node(), cs);
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
166 prevRevContent.done();
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
167 prevRevContent = csetDataAccess.reset();
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
168 } catch (CancelledException ex) {
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
169 return false;
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
170 } catch (Exception ex) {
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
171 throw new HgBadStateException(ex); // FIXME
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
172 }
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
173 return true;
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
174 }
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
175
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
176 public void manifestStart() {}
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
177 public void manifestEnd() {}
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
178 public void fileStart(String name) {}
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
179 public void fileEnd(String name) {}
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
180
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
181 };
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
182 inspectChangelog(bundleInsp);
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
183 }
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
184
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
185 public void dump() throws IOException {
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
186 Dump dump = new Dump();
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
187 inspectAll(dump);
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
188 System.out.println("Total files:" + dump.names.size());
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
189 for (String s : dump.names) {
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
190 System.out.println(s);
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
191 }
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
192 }
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
193
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
194 // callback to minimize amount of Strings and Nodeids instantiated
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
195 public interface Inspector {
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
196 void changelogStart();
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
197
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
198 void changelogEnd();
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
199
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
200 void manifestStart();
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
201
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
202 void manifestEnd();
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
203
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
204 void fileStart(String name);
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
205
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
206 void fileEnd(String name);
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
207
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
208 /**
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
209 * XXX desperately need exceptions here
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
210 * @param element data element, instance might be reused, don't keep a reference to it or its raw data
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
211 * @return <code>true</code> to continue
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
212 */
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
213 boolean element(GroupElement element);
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
214 }
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
215
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
216 public static class Dump implements Inspector {
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
217 public final LinkedList<String> names = new LinkedList<String>();
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
218
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
219 public void changelogStart() {
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
220 System.out.println("Changelog group");
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
221 }
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
222
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
223 public void changelogEnd() {
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
224 }
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
225
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
226 public void manifestStart() {
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
227 System.out.println("Manifest group");
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
228 }
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
229
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
230 public void manifestEnd() {
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
231 }
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
232
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
233 public void fileStart(String name) {
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
234 names.add(name);
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
235 System.out.println(name);
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
236 }
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
237
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
238 public void fileEnd(String name) {
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
239 }
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
240
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
241 public boolean element(GroupElement ge) {
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
242 try {
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
243 System.out.printf(" %s %s %s %s; patches:%d\n", ge.node(), ge.firstParent(), ge.secondParent(), ge.cset(), ge.patches().size());
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
244 } catch (Exception ex) {
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
245 ex.printStackTrace(); // FIXME
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
246 }
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
247 return true;
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
248 }
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
249 }
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
250
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
251 public void inspectChangelog(Inspector inspector) throws IOException {
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
252 if (inspector == null) {
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
253 throw new IllegalArgumentException();
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
254 }
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
255 DataAccess da = getDataStream();
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
256 try {
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
257 internalInspectChangelog(da, inspector);
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
258 } finally {
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
259 da.done();
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
260 }
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
261 }
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
262
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
263 public void inspectManifest(Inspector inspector) throws IOException {
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
264 if (inspector == null) {
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
265 throw new IllegalArgumentException();
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
266 }
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
267 DataAccess da = getDataStream();
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
268 try {
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
269 if (da.isEmpty()) {
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
270 return;
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
271 }
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
272 skipGroup(da); // changelog
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
273 internalInspectManifest(da, inspector);
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
274 } finally {
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
275 da.done();
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
276 }
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
277 }
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
278
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
279 public void inspectFiles(Inspector inspector) throws IOException {
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
280 if (inspector == null) {
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
281 throw new IllegalArgumentException();
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
282 }
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
283 DataAccess da = getDataStream();
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
284 try {
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
285 if (da.isEmpty()) {
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
286 return;
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
287 }
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
288 skipGroup(da); // changelog
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
289 if (da.isEmpty()) {
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
290 return;
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
291 }
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
292 skipGroup(da); // manifest
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
293 internalInspectFiles(da, inspector);
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
294 } finally {
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
295 da.done();
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
296 }
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
297 }
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
298
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
299 public void inspectAll(Inspector inspector) throws IOException {
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
300 if (inspector == null) {
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
301 throw new IllegalArgumentException();
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
302 }
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
303 DataAccess da = getDataStream();
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
304 try {
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
305 internalInspectChangelog(da, inspector);
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
306 internalInspectManifest(da, inspector);
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
307 internalInspectFiles(da, inspector);
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
308 } finally {
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
309 da.done();
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
310 }
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
311 }
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
312
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
313 private void internalInspectChangelog(DataAccess da, Inspector inspector) throws IOException {
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
314 if (da.isEmpty()) {
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
315 return;
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
316 }
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
317 inspector.changelogStart();
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
318 readGroup(da, inspector);
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
319 inspector.changelogEnd();
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
320 }
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
321
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
322 private void internalInspectManifest(DataAccess da, Inspector inspector) throws IOException {
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
323 if (da.isEmpty()) {
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
324 return;
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
325 }
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
326 inspector.manifestStart();
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
327 readGroup(da, inspector);
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
328 inspector.manifestEnd();
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
329 }
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
330
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
331 private void internalInspectFiles(DataAccess da, Inspector inspector) throws IOException {
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
332 while (!da.isEmpty()) {
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
333 int fnameLen = da.readInt();
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
334 if (fnameLen <= 4) {
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
335 break; // null chunk, the last one.
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
336 }
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
337 byte[] fnameBuf = new byte[fnameLen - 4];
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
338 da.readBytes(fnameBuf, 0, fnameBuf.length);
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
339 String name = new String(fnameBuf);
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
340 inspector.fileStart(name);
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
341 readGroup(da, inspector);
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
342 inspector.fileEnd(name);
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
343 }
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
344 }
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
345
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
346 private static void readGroup(DataAccess da, Inspector inspector) throws IOException {
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
347 int len = da.readInt();
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
348 boolean good2go = true;
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
349 while (len > 4 && !da.isEmpty() && good2go) {
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
350 byte[] nb = new byte[80];
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
351 da.readBytes(nb, 0, 80);
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
352 int dataLength = len - 84 /* length field + 4 nodeids */;
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
353 byte[] data = new byte[dataLength];
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
354 da.readBytes(data, 0, dataLength);
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
355 DataAccess slice = new ByteArrayDataAccess(data); // XXX in fact, may pass a slicing DataAccess.
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
356 // Just need to make sure that we seek to proper location afterwards (where next GroupElement starts),
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
357 // regardless whether that slice has read it or not.
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
358 GroupElement ge = new GroupElement(nb, slice);
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
359 good2go = inspector.element(ge);
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
360 slice.done(); // BADA doesn't implement done(), but it could (e.g. free array)
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
361 /// and we'd better tell it we are not going to use it any more. However, it's important to ensure Inspector
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
362 // implementations out there do not retain GroupElement.rawData()
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
363 len = da.isEmpty() ? 0 : da.readInt();
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
364 }
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
365 // need to skip up to group end if inspector told he don't want to continue with the group,
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
366 // because outer code may try to read next group immediately as we return back.
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
367 while (len > 4 && !da.isEmpty()) {
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
368 da.skip(len - 4 /* length field */);
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
369 len = da.isEmpty() ? 0 : da.readInt();
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
370 }
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
371 }
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
372
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
373 private static void skipGroup(DataAccess da) throws IOException {
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
374 int len = da.readInt();
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
375 while (len > 4 && !da.isEmpty()) {
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
376 da.skip(len - 4); // sizeof(int)
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
377 len = da.isEmpty() ? 0 : da.readInt();
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
378 }
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
379 }
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
380
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
381 public static class GroupElement {
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
382 private final byte[] header; // byte[80] takes 120 bytes, 4 Nodeids - 192
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
383 private final DataAccess dataAccess;
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
384 private List<RevlogStream.PatchRecord> patches;
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
385
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
386 GroupElement(byte[] fourNodeids, DataAccess rawDataAccess) {
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
387 assert fourNodeids != null && fourNodeids.length == 80;
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
388 header = fourNodeids;
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
389 dataAccess = rawDataAccess;
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
390 }
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
391
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
392 public Nodeid node() {
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
393 return Nodeid.fromBinary(header, 0);
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
394 }
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
395
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
396 public Nodeid firstParent() {
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
397 return Nodeid.fromBinary(header, 20);
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
398 }
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
399
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
400 public Nodeid secondParent() {
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
401 return Nodeid.fromBinary(header, 40);
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
402 }
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
403
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
404 public Nodeid cset() { // cs seems to be changeset
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
405 return Nodeid.fromBinary(header, 60);
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
406 }
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
407
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
408 public DataAccess rawData() {
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
409 return dataAccess;
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
410 }
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
411
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
412 public List<RevlogStream.PatchRecord> patches() throws IOException {
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
413 if (patches == null) {
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
414 dataAccess.reset();
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
415 LinkedList<RevlogStream.PatchRecord> p = new LinkedList<RevlogStream.PatchRecord>();
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
416 while (!dataAccess.isEmpty()) {
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
417 RevlogStream.PatchRecord pr = RevlogStream.PatchRecord.read(dataAccess);
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
418 p.add(pr);
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
419 }
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
420 patches = p;
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
421 }
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
422 return patches;
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
423 }
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
424
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
425 public byte[] apply(DataAccess baseContent) throws IOException {
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
426 return RevlogStream.apply(baseContent, -1, patches());
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
427 }
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
428 }
6ec4af642ba8 Project uses Gradle for build - actual changes
Alexander Kitaev <kitaev@gmail.com>
parents:
diff changeset
429 }