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