Mercurial > jhg
annotate src/org/tmatesoft/hg/repo/HgBundle.java @ 465:2078692eeb58 smartgit3
MqManager: read status/series of the active queue
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Thu, 21 Jun 2012 21:36:06 +0200 |
parents | 994b5813a925 |
children | 528b6780a8bd |
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:
47
diff
changeset
|
2 * Copyright (c) 2011 TMate Software Ltd |
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
47
diff
changeset
|
3 * |
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
47
diff
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:
47
diff
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:
47
diff
changeset
|
6 * the Free Software Foundation; version 2 of the License. |
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
47
diff
changeset
|
7 * |
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
47
diff
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:
47
diff
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:
47
diff
changeset
|
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
47
diff
changeset
|
11 * GNU General Public License for more details. |
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
47
diff
changeset
|
12 * |
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
47
diff
changeset
|
13 * For information on how to redistribute this software under |
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
47
diff
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:
77
diff
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:
47
diff
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 |
205f9b59b400
Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
19 import java.io.File; |
205f9b59b400
Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
20 import java.io.IOException; |
205f9b59b400
Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
21 |
169
8c8e3f372fa1
Towards initial clone: refactor HgBundle to provide slightly higher-level structure of the bundle
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
157
diff
changeset
|
22 import org.tmatesoft.hg.core.HgBadStateException; |
354
5f9073eabf06
Propagate errors with exceptions up to a end client
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
329
diff
changeset
|
23 import org.tmatesoft.hg.core.HgCallbackTargetException; |
295
981f9f50bb6c
Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
274
diff
changeset
|
24 import org.tmatesoft.hg.core.HgInvalidFileException; |
74
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
47
diff
changeset
|
25 import org.tmatesoft.hg.core.Nodeid; |
357
dfb8405d996f
Clean debug stacktraces
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
354
diff
changeset
|
26 import org.tmatesoft.hg.core.SessionContext; |
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.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
|
28 import org.tmatesoft.hg.internal.ByteArrayDataAccess; |
74
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
47
diff
changeset
|
29 import org.tmatesoft.hg.internal.DataAccess; |
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
47
diff
changeset
|
30 import org.tmatesoft.hg.internal.DataAccessProvider; |
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
47
diff
changeset
|
31 import org.tmatesoft.hg.internal.DigestHelper; |
358
fc8bc2f1edbe
Clean internal classes from public API
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
357
diff
changeset
|
32 import org.tmatesoft.hg.internal.Experimental; |
169
8c8e3f372fa1
Towards initial clone: refactor HgBundle to provide slightly higher-level structure of the bundle
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
157
diff
changeset
|
33 import org.tmatesoft.hg.internal.InflaterDataAccess; |
329
694ebabb5cb3
Refactor revlog patch mechanism, towards patch merging
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
295
diff
changeset
|
34 import org.tmatesoft.hg.internal.Patch; |
154
ba2bf656f00f
Changeset => RawChangeset
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
129
diff
changeset
|
35 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
|
36 import org.tmatesoft.hg.util.CancelledException; |
74
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
47
diff
changeset
|
37 |
36
205f9b59b400
Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
38 /** |
205f9b59b400
Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
39 * @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:
157
diff
changeset
|
40 * |
74
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
47
diff
changeset
|
41 * @author Artem Tikhomirov |
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
47
diff
changeset
|
42 * @author TMate Software Ltd. |
36
205f9b59b400
Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
43 */ |
205f9b59b400
Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
44 public class HgBundle { |
205f9b59b400
Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
45 |
205f9b59b400
Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
46 private final File bundleFile; |
205f9b59b400
Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
47 private final DataAccessProvider accessProvider; |
357
dfb8405d996f
Clean debug stacktraces
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
354
diff
changeset
|
48 // private final SessionContext sessionContext; |
36
205f9b59b400
Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
49 |
357
dfb8405d996f
Clean debug stacktraces
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
354
diff
changeset
|
50 HgBundle(SessionContext ctx, DataAccessProvider dap, File bundle) { |
dfb8405d996f
Clean debug stacktraces
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
354
diff
changeset
|
51 // sessionContext = ctx; |
36
205f9b59b400
Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
52 accessProvider = dap; |
205f9b59b400
Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
53 bundleFile = bundle; |
205f9b59b400
Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
54 } |
205f9b59b400
Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
55 |
169
8c8e3f372fa1
Towards initial clone: refactor HgBundle to provide slightly higher-level structure of the bundle
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
157
diff
changeset
|
56 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:
36
diff
changeset
|
57 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:
157
diff
changeset
|
58 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:
157
diff
changeset
|
59 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:
157
diff
changeset
|
60 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:
157
diff
changeset
|
61 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:
157
diff
changeset
|
62 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:
157
diff
changeset
|
63 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:
157
diff
changeset
|
64 } |
8c8e3f372fa1
Towards initial clone: refactor HgBundle to provide slightly higher-level structure of the bundle
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
157
diff
changeset
|
65 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:
157
diff
changeset
|
66 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:
157
diff
changeset
|
67 } |
8c8e3f372fa1
Towards initial clone: refactor HgBundle to provide slightly higher-level structure of the bundle
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
157
diff
changeset
|
68 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:
157
diff
changeset
|
69 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:
157
diff
changeset
|
70 } |
8c8e3f372fa1
Towards initial clone: refactor HgBundle to provide slightly higher-level structure of the bundle
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
157
diff
changeset
|
71 // "...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:
157
diff
changeset
|
72 } else { |
8c8e3f372fa1
Towards initial clone: refactor HgBundle to provide slightly higher-level structure of the bundle
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
157
diff
changeset
|
73 da.reset(); |
39
4e9b66b07a28
Check changelog group starts with proper (known) base
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
37
diff
changeset
|
74 } |
169
8c8e3f372fa1
Towards initial clone: refactor HgBundle to provide slightly higher-level structure of the bundle
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
157
diff
changeset
|
75 } |
8c8e3f372fa1
Towards initial clone: refactor HgBundle to provide slightly higher-level structure of the bundle
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
157
diff
changeset
|
76 return da; |
8c8e3f372fa1
Towards initial clone: refactor HgBundle to provide slightly higher-level structure of the bundle
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
157
diff
changeset
|
77 } |
8c8e3f372fa1
Towards initial clone: refactor HgBundle to provide slightly higher-level structure of the bundle
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
157
diff
changeset
|
78 |
186
44a34baabea0
Clone refactored into a command. HgBundle needs means to control its lifecycle, to be deleted when no longer needed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
182
diff
changeset
|
79 private int uses = 0; |
44a34baabea0
Clone refactored into a command. HgBundle needs means to control its lifecycle, to be deleted when no longer needed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
182
diff
changeset
|
80 public HgBundle link() { |
44a34baabea0
Clone refactored into a command. HgBundle needs means to control its lifecycle, to be deleted when no longer needed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
182
diff
changeset
|
81 uses++; |
44a34baabea0
Clone refactored into a command. HgBundle needs means to control its lifecycle, to be deleted when no longer needed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
182
diff
changeset
|
82 return this; |
44a34baabea0
Clone refactored into a command. HgBundle needs means to control its lifecycle, to be deleted when no longer needed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
182
diff
changeset
|
83 } |
44a34baabea0
Clone refactored into a command. HgBundle needs means to control its lifecycle, to be deleted when no longer needed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
182
diff
changeset
|
84 public void unlink() { |
44a34baabea0
Clone refactored into a command. HgBundle needs means to control its lifecycle, to be deleted when no longer needed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
182
diff
changeset
|
85 uses--; |
44a34baabea0
Clone refactored into a command. HgBundle needs means to control its lifecycle, to be deleted when no longer needed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
182
diff
changeset
|
86 if (uses == 0 && bundleFile != null) { |
44a34baabea0
Clone refactored into a command. HgBundle needs means to control its lifecycle, to be deleted when no longer needed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
182
diff
changeset
|
87 bundleFile.deleteOnExit(); |
44a34baabea0
Clone refactored into a command. HgBundle needs means to control its lifecycle, to be deleted when no longer needed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
182
diff
changeset
|
88 } |
44a34baabea0
Clone refactored into a command. HgBundle needs means to control its lifecycle, to be deleted when no longer needed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
182
diff
changeset
|
89 } |
44a34baabea0
Clone refactored into a command. HgBundle needs means to control its lifecycle, to be deleted when no longer needed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
182
diff
changeset
|
90 public boolean inUse() { |
44a34baabea0
Clone refactored into a command. HgBundle needs means to control its lifecycle, to be deleted when no longer needed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
182
diff
changeset
|
91 return uses > 0; |
44a34baabea0
Clone refactored into a command. HgBundle needs means to control its lifecycle, to be deleted when no longer needed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
182
diff
changeset
|
92 } |
44a34baabea0
Clone refactored into a command. HgBundle needs means to control its lifecycle, to be deleted when no longer needed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
182
diff
changeset
|
93 |
182
f26ffe04ced0
Refactor HgBundle to dispatch changes found through callback
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
170
diff
changeset
|
94 /** |
f26ffe04ced0
Refactor HgBundle to dispatch changes found through callback
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
170
diff
changeset
|
95 * Get changes recorded in the bundle that are missing from the supplied repository. |
f26ffe04ced0
Refactor HgBundle to dispatch changes found through callback
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
170
diff
changeset
|
96 * @param hgRepo repository that shall possess base revision for this bundle |
f26ffe04ced0
Refactor HgBundle to dispatch changes found through callback
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
170
diff
changeset
|
97 * @param inspector callback to get each changeset found |
f26ffe04ced0
Refactor HgBundle to dispatch changes found through callback
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
170
diff
changeset
|
98 */ |
354
5f9073eabf06
Propagate errors with exceptions up to a end client
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
329
diff
changeset
|
99 public void changes(final HgRepository hgRepo, final HgChangelog.Inspector inspector) throws HgCallbackTargetException, HgInvalidFileException { |
182
f26ffe04ced0
Refactor HgBundle to dispatch changes found through callback
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
170
diff
changeset
|
100 Inspector bundleInsp = new Inspector() { |
169
8c8e3f372fa1
Towards initial clone: refactor HgBundle to provide slightly higher-level structure of the bundle
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
157
diff
changeset
|
101 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:
157
diff
changeset
|
102 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:
157
diff
changeset
|
103 private DataAccess prevRevContent; |
182
f26ffe04ced0
Refactor HgBundle to dispatch changes found through callback
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
170
diff
changeset
|
104 private int revisionIndex; |
169
8c8e3f372fa1
Towards initial clone: refactor HgBundle to provide slightly higher-level structure of the bundle
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
157
diff
changeset
|
105 |
8c8e3f372fa1
Towards initial clone: refactor HgBundle to provide slightly higher-level structure of the bundle
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
157
diff
changeset
|
106 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:
157
diff
changeset
|
107 emptyChangelog = true; |
182
f26ffe04ced0
Refactor HgBundle to dispatch changes found through callback
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
170
diff
changeset
|
108 revisionIndex = 0; |
169
8c8e3f372fa1
Towards initial clone: refactor HgBundle to provide slightly higher-level structure of the bundle
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
157
diff
changeset
|
109 } |
8c8e3f372fa1
Towards initial clone: refactor HgBundle to provide slightly higher-level structure of the bundle
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
157
diff
changeset
|
110 |
8c8e3f372fa1
Towards initial clone: refactor HgBundle to provide slightly higher-level structure of the bundle
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
157
diff
changeset
|
111 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:
157
diff
changeset
|
112 if (emptyChangelog) { |
8c8e3f372fa1
Towards initial clone: refactor HgBundle to provide slightly higher-level structure of the bundle
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
157
diff
changeset
|
113 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:
41
diff
changeset
|
114 } |
37
e45e75e22523
Parse changesets from bundle's changelog group. Refactor Revlog to provide access to revision's raw content
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
36
diff
changeset
|
115 } |
169
8c8e3f372fa1
Towards initial clone: refactor HgBundle to provide slightly higher-level structure of the bundle
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
157
diff
changeset
|
116 |
8c8e3f372fa1
Towards initial clone: refactor HgBundle to provide slightly higher-level structure of the bundle
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
157
diff
changeset
|
117 /* |
8c8e3f372fa1
Towards initial clone: refactor HgBundle to provide slightly higher-level structure of the bundle
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
157
diff
changeset
|
118 * 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:
157
diff
changeset
|
119 * (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:
157
diff
changeset
|
120 * 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:
157
diff
changeset
|
121 * 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:
157
diff
changeset
|
122 * |
8c8e3f372fa1
Towards initial clone: refactor HgBundle to provide slightly higher-level structure of the bundle
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
157
diff
changeset
|
123 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:
157
diff
changeset
|
124 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:
157
diff
changeset
|
125 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:
157
diff
changeset
|
126 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:
157
diff
changeset
|
127 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:
157
diff
changeset
|
128 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:
157
diff
changeset
|
129 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:
157
diff
changeset
|
130 |
8c8e3f372fa1
Towards initial clone: refactor HgBundle to provide slightly higher-level structure of the bundle
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
157
diff
changeset
|
131 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:
157
diff
changeset
|
132 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:
157
diff
changeset
|
133 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:
157
diff
changeset
|
134 > 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:
157
diff
changeset
|
135 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:
157
diff
changeset
|
136 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:
157
diff
changeset
|
137 |
8c8e3f372fa1
Towards initial clone: refactor HgBundle to provide slightly higher-level structure of the bundle
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
157
diff
changeset
|
138 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:
157
diff
changeset
|
139 */ |
8c8e3f372fa1
Towards initial clone: refactor HgBundle to provide slightly higher-level structure of the bundle
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
157
diff
changeset
|
140 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:
157
diff
changeset
|
141 emptyChangelog = false; |
8c8e3f372fa1
Towards initial clone: refactor HgBundle to provide slightly higher-level structure of the bundle
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
157
diff
changeset
|
142 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:
157
diff
changeset
|
143 try { |
8c8e3f372fa1
Towards initial clone: refactor HgBundle to provide slightly higher-level structure of the bundle
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
157
diff
changeset
|
144 if (prevRevContent == null) { |
274
9fb50c04f03c
Use Nodeid.isNull check instead of NULL.equals
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
186
diff
changeset
|
145 if (ge.firstParent().isNull() && ge.secondParent().isNull()) { |
169
8c8e3f372fa1
Towards initial clone: refactor HgBundle to provide slightly higher-level structure of the bundle
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
157
diff
changeset
|
146 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:
157
diff
changeset
|
147 } else { |
8c8e3f372fa1
Towards initial clone: refactor HgBundle to provide slightly higher-level structure of the bundle
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
157
diff
changeset
|
148 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:
157
diff
changeset
|
149 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:
157
diff
changeset
|
150 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:
157
diff
changeset
|
151 } |
8c8e3f372fa1
Towards initial clone: refactor HgBundle to provide slightly higher-level structure of the bundle
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
157
diff
changeset
|
152 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:
157
diff
changeset
|
153 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:
157
diff
changeset
|
154 // 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:
157
diff
changeset
|
155 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:
157
diff
changeset
|
156 } |
8c8e3f372fa1
Towards initial clone: refactor HgBundle to provide slightly higher-level structure of the bundle
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
157
diff
changeset
|
157 } |
8c8e3f372fa1
Towards initial clone: refactor HgBundle to provide slightly higher-level structure of the bundle
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
157
diff
changeset
|
158 // |
8c8e3f372fa1
Towards initial clone: refactor HgBundle to provide slightly higher-level structure of the bundle
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
157
diff
changeset
|
159 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:
157
diff
changeset
|
160 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:
157
diff
changeset
|
161 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:
157
diff
changeset
|
162 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:
157
diff
changeset
|
163 } |
8c8e3f372fa1
Towards initial clone: refactor HgBundle to provide slightly higher-level structure of the bundle
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
157
diff
changeset
|
164 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:
157
diff
changeset
|
165 RawChangeset cs = RawChangeset.parse(csetDataAccess); |
182
f26ffe04ced0
Refactor HgBundle to dispatch changes found through callback
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
170
diff
changeset
|
166 inspector.next(revisionIndex++, ge.node(), cs); |
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:
169
diff
changeset
|
167 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:
157
diff
changeset
|
168 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:
157
diff
changeset
|
169 } 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:
157
diff
changeset
|
170 return false; |
8c8e3f372fa1
Towards initial clone: refactor HgBundle to provide slightly higher-level structure of the bundle
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
157
diff
changeset
|
171 } catch (Exception ex) { |
383 | 172 throw new HgBadStateException(ex); // FIXME EXCEPTIONS |
169
8c8e3f372fa1
Towards initial clone: refactor HgBundle to provide slightly higher-level structure of the bundle
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
157
diff
changeset
|
173 } |
8c8e3f372fa1
Towards initial clone: refactor HgBundle to provide slightly higher-level structure of the bundle
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
157
diff
changeset
|
174 return true; |
8c8e3f372fa1
Towards initial clone: refactor HgBundle to provide slightly higher-level structure of the bundle
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
157
diff
changeset
|
175 } |
8c8e3f372fa1
Towards initial clone: refactor HgBundle to provide slightly higher-level structure of the bundle
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
157
diff
changeset
|
176 |
8c8e3f372fa1
Towards initial clone: refactor HgBundle to provide slightly higher-level structure of the bundle
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
157
diff
changeset
|
177 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:
157
diff
changeset
|
178 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:
157
diff
changeset
|
179 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:
157
diff
changeset
|
180 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:
157
diff
changeset
|
181 |
8c8e3f372fa1
Towards initial clone: refactor HgBundle to provide slightly higher-level structure of the bundle
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
157
diff
changeset
|
182 }; |
354
5f9073eabf06
Propagate errors with exceptions up to a end client
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
329
diff
changeset
|
183 try { |
5f9073eabf06
Propagate errors with exceptions up to a end client
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
329
diff
changeset
|
184 inspectChangelog(bundleInsp); |
5f9073eabf06
Propagate errors with exceptions up to a end client
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
329
diff
changeset
|
185 } catch (RuntimeException ex) { |
5f9073eabf06
Propagate errors with exceptions up to a end client
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
329
diff
changeset
|
186 throw new HgCallbackTargetException(ex); |
5f9073eabf06
Propagate errors with exceptions up to a end client
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
329
diff
changeset
|
187 } |
169
8c8e3f372fa1
Towards initial clone: refactor HgBundle to provide slightly higher-level structure of the bundle
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
157
diff
changeset
|
188 } |
8c8e3f372fa1
Towards initial clone: refactor HgBundle to provide slightly higher-level structure of the bundle
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
157
diff
changeset
|
189 |
8c8e3f372fa1
Towards initial clone: refactor HgBundle to provide slightly higher-level structure of the bundle
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
157
diff
changeset
|
190 // 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:
157
diff
changeset
|
191 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:
157
diff
changeset
|
192 void changelogStart(); |
8c8e3f372fa1
Towards initial clone: refactor HgBundle to provide slightly higher-level structure of the bundle
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
157
diff
changeset
|
193 |
8c8e3f372fa1
Towards initial clone: refactor HgBundle to provide slightly higher-level structure of the bundle
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
157
diff
changeset
|
194 void changelogEnd(); |
8c8e3f372fa1
Towards initial clone: refactor HgBundle to provide slightly higher-level structure of the bundle
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
157
diff
changeset
|
195 |
8c8e3f372fa1
Towards initial clone: refactor HgBundle to provide slightly higher-level structure of the bundle
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
157
diff
changeset
|
196 void manifestStart(); |
8c8e3f372fa1
Towards initial clone: refactor HgBundle to provide slightly higher-level structure of the bundle
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
157
diff
changeset
|
197 |
8c8e3f372fa1
Towards initial clone: refactor HgBundle to provide slightly higher-level structure of the bundle
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
157
diff
changeset
|
198 void manifestEnd(); |
8c8e3f372fa1
Towards initial clone: refactor HgBundle to provide slightly higher-level structure of the bundle
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
157
diff
changeset
|
199 |
8c8e3f372fa1
Towards initial clone: refactor HgBundle to provide slightly higher-level structure of the bundle
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
157
diff
changeset
|
200 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:
157
diff
changeset
|
201 |
8c8e3f372fa1
Towards initial clone: refactor HgBundle to provide slightly higher-level structure of the bundle
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
157
diff
changeset
|
202 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:
157
diff
changeset
|
203 |
8c8e3f372fa1
Towards initial clone: refactor HgBundle to provide slightly higher-level structure of the bundle
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
157
diff
changeset
|
204 /** |
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:
169
diff
changeset
|
205 * 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:
169
diff
changeset
|
206 * @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:
157
diff
changeset
|
207 * @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:
157
diff
changeset
|
208 */ |
8c8e3f372fa1
Towards initial clone: refactor HgBundle to provide slightly higher-level structure of the bundle
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
157
diff
changeset
|
209 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:
157
diff
changeset
|
210 } |
8c8e3f372fa1
Towards initial clone: refactor HgBundle to provide slightly higher-level structure of the bundle
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
157
diff
changeset
|
211 |
295
981f9f50bb6c
Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
274
diff
changeset
|
212 public void inspectChangelog(Inspector inspector) throws HgInvalidFileException { |
169
8c8e3f372fa1
Towards initial clone: refactor HgBundle to provide slightly higher-level structure of the bundle
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
157
diff
changeset
|
213 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:
157
diff
changeset
|
214 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:
157
diff
changeset
|
215 } |
295
981f9f50bb6c
Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
274
diff
changeset
|
216 DataAccess da = null; |
169
8c8e3f372fa1
Towards initial clone: refactor HgBundle to provide slightly higher-level structure of the bundle
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
157
diff
changeset
|
217 try { |
295
981f9f50bb6c
Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
274
diff
changeset
|
218 da = getDataStream(); |
182
f26ffe04ced0
Refactor HgBundle to dispatch changes found through callback
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
170
diff
changeset
|
219 internalInspectChangelog(da, inspector); |
295
981f9f50bb6c
Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
274
diff
changeset
|
220 } catch (IOException ex) { |
981f9f50bb6c
Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
274
diff
changeset
|
221 throw new HgInvalidFileException("Bundle.inspectChangelog failed", ex, bundleFile); |
37
e45e75e22523
Parse changesets from bundle's changelog group. Refactor Revlog to provide access to revision's raw content
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
36
diff
changeset
|
222 } finally { |
295
981f9f50bb6c
Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
274
diff
changeset
|
223 if (da != null) { |
981f9f50bb6c
Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
274
diff
changeset
|
224 da.done(); |
981f9f50bb6c
Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
274
diff
changeset
|
225 } |
37
e45e75e22523
Parse changesets from bundle's changelog group. Refactor Revlog to provide access to revision's raw content
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
36
diff
changeset
|
226 } |
e45e75e22523
Parse changesets from bundle's changelog group. Refactor Revlog to provide access to revision's raw content
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
36
diff
changeset
|
227 } |
e45e75e22523
Parse changesets from bundle's changelog group. Refactor Revlog to provide access to revision's raw content
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
36
diff
changeset
|
228 |
295
981f9f50bb6c
Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
274
diff
changeset
|
229 public void inspectManifest(Inspector inspector) throws HgInvalidFileException { |
169
8c8e3f372fa1
Towards initial clone: refactor HgBundle to provide slightly higher-level structure of the bundle
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
157
diff
changeset
|
230 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:
157
diff
changeset
|
231 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:
157
diff
changeset
|
232 } |
295
981f9f50bb6c
Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
274
diff
changeset
|
233 DataAccess da = null; |
36
205f9b59b400
Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
234 try { |
295
981f9f50bb6c
Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
274
diff
changeset
|
235 da = getDataStream(); |
169
8c8e3f372fa1
Towards initial clone: refactor HgBundle to provide slightly higher-level structure of the bundle
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
157
diff
changeset
|
236 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:
157
diff
changeset
|
237 return; |
8c8e3f372fa1
Towards initial clone: refactor HgBundle to provide slightly higher-level structure of the bundle
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
157
diff
changeset
|
238 } |
8c8e3f372fa1
Towards initial clone: refactor HgBundle to provide slightly higher-level structure of the bundle
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
157
diff
changeset
|
239 skipGroup(da); // changelog |
182
f26ffe04ced0
Refactor HgBundle to dispatch changes found through callback
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
170
diff
changeset
|
240 internalInspectManifest(da, inspector); |
295
981f9f50bb6c
Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
274
diff
changeset
|
241 } catch (IOException ex) { |
981f9f50bb6c
Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
274
diff
changeset
|
242 throw new HgInvalidFileException("Bundle.inspectManifest failed", ex, bundleFile); |
36
205f9b59b400
Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
243 } finally { |
295
981f9f50bb6c
Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
274
diff
changeset
|
244 if (da != null) { |
981f9f50bb6c
Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
274
diff
changeset
|
245 da.done(); |
981f9f50bb6c
Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
274
diff
changeset
|
246 } |
36
205f9b59b400
Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
247 } |
205f9b59b400
Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
248 } |
205f9b59b400
Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
249 |
295
981f9f50bb6c
Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
274
diff
changeset
|
250 public void inspectFiles(Inspector inspector) throws HgInvalidFileException { |
169
8c8e3f372fa1
Towards initial clone: refactor HgBundle to provide slightly higher-level structure of the bundle
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
157
diff
changeset
|
251 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:
157
diff
changeset
|
252 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:
157
diff
changeset
|
253 } |
295
981f9f50bb6c
Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
274
diff
changeset
|
254 DataAccess da = null; |
169
8c8e3f372fa1
Towards initial clone: refactor HgBundle to provide slightly higher-level structure of the bundle
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
157
diff
changeset
|
255 try { |
295
981f9f50bb6c
Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
274
diff
changeset
|
256 da = getDataStream(); |
182
f26ffe04ced0
Refactor HgBundle to dispatch changes found through callback
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
170
diff
changeset
|
257 if (da.isEmpty()) { |
f26ffe04ced0
Refactor HgBundle to dispatch changes found through callback
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
170
diff
changeset
|
258 return; |
169
8c8e3f372fa1
Towards initial clone: refactor HgBundle to provide slightly higher-level structure of the bundle
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
157
diff
changeset
|
259 } |
182
f26ffe04ced0
Refactor HgBundle to dispatch changes found through callback
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
170
diff
changeset
|
260 skipGroup(da); // changelog |
f26ffe04ced0
Refactor HgBundle to dispatch changes found through callback
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
170
diff
changeset
|
261 if (da.isEmpty()) { |
f26ffe04ced0
Refactor HgBundle to dispatch changes found through callback
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
170
diff
changeset
|
262 return; |
169
8c8e3f372fa1
Towards initial clone: refactor HgBundle to provide slightly higher-level structure of the bundle
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
157
diff
changeset
|
263 } |
182
f26ffe04ced0
Refactor HgBundle to dispatch changes found through callback
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
170
diff
changeset
|
264 skipGroup(da); // manifest |
f26ffe04ced0
Refactor HgBundle to dispatch changes found through callback
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
170
diff
changeset
|
265 internalInspectFiles(da, inspector); |
295
981f9f50bb6c
Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
274
diff
changeset
|
266 } catch (IOException ex) { |
981f9f50bb6c
Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
274
diff
changeset
|
267 throw new HgInvalidFileException("Bundle.inspectFiles failed", ex, bundleFile); |
169
8c8e3f372fa1
Towards initial clone: refactor HgBundle to provide slightly higher-level structure of the bundle
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
157
diff
changeset
|
268 } finally { |
295
981f9f50bb6c
Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
274
diff
changeset
|
269 if (da != null) { |
981f9f50bb6c
Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
274
diff
changeset
|
270 da.done(); |
981f9f50bb6c
Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
274
diff
changeset
|
271 } |
169
8c8e3f372fa1
Towards initial clone: refactor HgBundle to provide slightly higher-level structure of the bundle
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
157
diff
changeset
|
272 } |
8c8e3f372fa1
Towards initial clone: refactor HgBundle to provide slightly higher-level structure of the bundle
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
157
diff
changeset
|
273 } |
8c8e3f372fa1
Towards initial clone: refactor HgBundle to provide slightly higher-level structure of the bundle
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
157
diff
changeset
|
274 |
295
981f9f50bb6c
Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
274
diff
changeset
|
275 public void inspectAll(Inspector inspector) throws HgInvalidFileException { |
169
8c8e3f372fa1
Towards initial clone: refactor HgBundle to provide slightly higher-level structure of the bundle
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
157
diff
changeset
|
276 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:
157
diff
changeset
|
277 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:
157
diff
changeset
|
278 } |
295
981f9f50bb6c
Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
274
diff
changeset
|
279 DataAccess da = null; |
169
8c8e3f372fa1
Towards initial clone: refactor HgBundle to provide slightly higher-level structure of the bundle
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
157
diff
changeset
|
280 try { |
295
981f9f50bb6c
Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
274
diff
changeset
|
281 da = getDataStream(); |
182
f26ffe04ced0
Refactor HgBundle to dispatch changes found through callback
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
170
diff
changeset
|
282 internalInspectChangelog(da, inspector); |
f26ffe04ced0
Refactor HgBundle to dispatch changes found through callback
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
170
diff
changeset
|
283 internalInspectManifest(da, inspector); |
f26ffe04ced0
Refactor HgBundle to dispatch changes found through callback
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
170
diff
changeset
|
284 internalInspectFiles(da, inspector); |
295
981f9f50bb6c
Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
274
diff
changeset
|
285 } catch (IOException ex) { |
981f9f50bb6c
Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
274
diff
changeset
|
286 throw new HgInvalidFileException("Bundle.inspectAll failed", ex, bundleFile); |
169
8c8e3f372fa1
Towards initial clone: refactor HgBundle to provide slightly higher-level structure of the bundle
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
157
diff
changeset
|
287 } finally { |
295
981f9f50bb6c
Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
274
diff
changeset
|
288 if (da != null) { |
981f9f50bb6c
Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
274
diff
changeset
|
289 da.done(); |
981f9f50bb6c
Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
274
diff
changeset
|
290 } |
169
8c8e3f372fa1
Towards initial clone: refactor HgBundle to provide slightly higher-level structure of the bundle
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
157
diff
changeset
|
291 } |
8c8e3f372fa1
Towards initial clone: refactor HgBundle to provide slightly higher-level structure of the bundle
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
157
diff
changeset
|
292 } |
8c8e3f372fa1
Towards initial clone: refactor HgBundle to provide slightly higher-level structure of the bundle
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
157
diff
changeset
|
293 |
182
f26ffe04ced0
Refactor HgBundle to dispatch changes found through callback
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
170
diff
changeset
|
294 private void internalInspectChangelog(DataAccess da, Inspector inspector) throws IOException { |
f26ffe04ced0
Refactor HgBundle to dispatch changes found through callback
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
170
diff
changeset
|
295 if (da.isEmpty()) { |
f26ffe04ced0
Refactor HgBundle to dispatch changes found through callback
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
170
diff
changeset
|
296 return; |
f26ffe04ced0
Refactor HgBundle to dispatch changes found through callback
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
170
diff
changeset
|
297 } |
f26ffe04ced0
Refactor HgBundle to dispatch changes found through callback
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
170
diff
changeset
|
298 inspector.changelogStart(); |
f26ffe04ced0
Refactor HgBundle to dispatch changes found through callback
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
170
diff
changeset
|
299 readGroup(da, inspector); |
f26ffe04ced0
Refactor HgBundle to dispatch changes found through callback
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
170
diff
changeset
|
300 inspector.changelogEnd(); |
f26ffe04ced0
Refactor HgBundle to dispatch changes found through callback
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
170
diff
changeset
|
301 } |
f26ffe04ced0
Refactor HgBundle to dispatch changes found through callback
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
170
diff
changeset
|
302 |
f26ffe04ced0
Refactor HgBundle to dispatch changes found through callback
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
170
diff
changeset
|
303 private void internalInspectManifest(DataAccess da, Inspector inspector) throws IOException { |
f26ffe04ced0
Refactor HgBundle to dispatch changes found through callback
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
170
diff
changeset
|
304 if (da.isEmpty()) { |
f26ffe04ced0
Refactor HgBundle to dispatch changes found through callback
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
170
diff
changeset
|
305 return; |
f26ffe04ced0
Refactor HgBundle to dispatch changes found through callback
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
170
diff
changeset
|
306 } |
f26ffe04ced0
Refactor HgBundle to dispatch changes found through callback
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
170
diff
changeset
|
307 inspector.manifestStart(); |
f26ffe04ced0
Refactor HgBundle to dispatch changes found through callback
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
170
diff
changeset
|
308 readGroup(da, inspector); |
f26ffe04ced0
Refactor HgBundle to dispatch changes found through callback
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
170
diff
changeset
|
309 inspector.manifestEnd(); |
f26ffe04ced0
Refactor HgBundle to dispatch changes found through callback
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
170
diff
changeset
|
310 } |
f26ffe04ced0
Refactor HgBundle to dispatch changes found through callback
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
170
diff
changeset
|
311 |
f26ffe04ced0
Refactor HgBundle to dispatch changes found through callback
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
170
diff
changeset
|
312 private void internalInspectFiles(DataAccess da, Inspector inspector) throws IOException { |
f26ffe04ced0
Refactor HgBundle to dispatch changes found through callback
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
170
diff
changeset
|
313 while (!da.isEmpty()) { |
f26ffe04ced0
Refactor HgBundle to dispatch changes found through callback
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
170
diff
changeset
|
314 int fnameLen = da.readInt(); |
f26ffe04ced0
Refactor HgBundle to dispatch changes found through callback
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
170
diff
changeset
|
315 if (fnameLen <= 4) { |
f26ffe04ced0
Refactor HgBundle to dispatch changes found through callback
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
170
diff
changeset
|
316 break; // null chunk, the last one. |
f26ffe04ced0
Refactor HgBundle to dispatch changes found through callback
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
170
diff
changeset
|
317 } |
f26ffe04ced0
Refactor HgBundle to dispatch changes found through callback
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
170
diff
changeset
|
318 byte[] fnameBuf = new byte[fnameLen - 4]; |
f26ffe04ced0
Refactor HgBundle to dispatch changes found through callback
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
170
diff
changeset
|
319 da.readBytes(fnameBuf, 0, fnameBuf.length); |
f26ffe04ced0
Refactor HgBundle to dispatch changes found through callback
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
170
diff
changeset
|
320 String name = new String(fnameBuf); |
f26ffe04ced0
Refactor HgBundle to dispatch changes found through callback
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
170
diff
changeset
|
321 inspector.fileStart(name); |
f26ffe04ced0
Refactor HgBundle to dispatch changes found through callback
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
170
diff
changeset
|
322 readGroup(da, inspector); |
f26ffe04ced0
Refactor HgBundle to dispatch changes found through callback
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
170
diff
changeset
|
323 inspector.fileEnd(name); |
f26ffe04ced0
Refactor HgBundle to dispatch changes found through callback
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
170
diff
changeset
|
324 } |
f26ffe04ced0
Refactor HgBundle to dispatch changes found through callback
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
170
diff
changeset
|
325 } |
f26ffe04ced0
Refactor HgBundle to dispatch changes found through callback
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
170
diff
changeset
|
326 |
169
8c8e3f372fa1
Towards initial clone: refactor HgBundle to provide slightly higher-level structure of the bundle
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
157
diff
changeset
|
327 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
|
328 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:
157
diff
changeset
|
329 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:
157
diff
changeset
|
330 while (len > 4 && !da.isEmpty() && good2go) { |
36
205f9b59b400
Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
331 byte[] nb = new byte[80]; |
205f9b59b400
Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
332 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:
157
diff
changeset
|
333 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:
157
diff
changeset
|
334 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:
157
diff
changeset
|
335 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:
157
diff
changeset
|
336 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:
157
diff
changeset
|
337 // 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:
157
diff
changeset
|
338 // 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:
157
diff
changeset
|
339 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:
157
diff
changeset
|
340 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:
169
diff
changeset
|
341 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:
169
diff
changeset
|
342 /// 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:
169
diff
changeset
|
343 // 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
|
344 len = da.isEmpty() ? 0 : da.readInt(); |
205f9b59b400
Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
345 } |
169
8c8e3f372fa1
Towards initial clone: refactor HgBundle to provide slightly higher-level structure of the bundle
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
157
diff
changeset
|
346 // 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:
157
diff
changeset
|
347 // 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:
157
diff
changeset
|
348 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:
157
diff
changeset
|
349 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:
157
diff
changeset
|
350 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:
157
diff
changeset
|
351 } |
36
205f9b59b400
Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
352 } |
205f9b59b400
Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
353 |
169
8c8e3f372fa1
Towards initial clone: refactor HgBundle to provide slightly higher-level structure of the bundle
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
157
diff
changeset
|
354 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:
157
diff
changeset
|
355 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:
157
diff
changeset
|
356 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:
157
diff
changeset
|
357 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:
157
diff
changeset
|
358 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:
157
diff
changeset
|
359 } |
8c8e3f372fa1
Towards initial clone: refactor HgBundle to provide slightly higher-level structure of the bundle
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
157
diff
changeset
|
360 } |
8c8e3f372fa1
Towards initial clone: refactor HgBundle to provide slightly higher-level structure of the bundle
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
157
diff
changeset
|
361 |
358
fc8bc2f1edbe
Clean internal classes from public API
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
357
diff
changeset
|
362 @Experimental(reason="Cumbersome API, rawData and apply with byte[] perhaps need replacement with ByteChannel/ByteBuffer, and better Exceptions. Perhaps, shall split into interface and impl") |
169
8c8e3f372fa1
Towards initial clone: refactor HgBundle to provide slightly higher-level structure of the bundle
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
157
diff
changeset
|
363 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:
157
diff
changeset
|
364 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:
157
diff
changeset
|
365 private final DataAccess dataAccess; |
329
694ebabb5cb3
Refactor revlog patch mechanism, towards patch merging
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
295
diff
changeset
|
366 private Patch patches; |
169
8c8e3f372fa1
Towards initial clone: refactor HgBundle to provide slightly higher-level structure of the bundle
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
157
diff
changeset
|
367 |
8c8e3f372fa1
Towards initial clone: refactor HgBundle to provide slightly higher-level structure of the bundle
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
157
diff
changeset
|
368 GroupElement(byte[] fourNodeids, DataAccess rawDataAccess) { |
36
205f9b59b400
Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
369 assert fourNodeids != null && fourNodeids.length == 80; |
205f9b59b400
Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
370 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:
157
diff
changeset
|
371 dataAccess = rawDataAccess; |
36
205f9b59b400
Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
372 } |
169
8c8e3f372fa1
Towards initial clone: refactor HgBundle to provide slightly higher-level structure of the bundle
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
157
diff
changeset
|
373 |
358
fc8bc2f1edbe
Clean internal classes from public API
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
357
diff
changeset
|
374 /** |
fc8bc2f1edbe
Clean internal classes from public API
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
357
diff
changeset
|
375 * <b>node</b> field of the group element |
fc8bc2f1edbe
Clean internal classes from public API
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
357
diff
changeset
|
376 * @return node revision, never <code>null</code> |
fc8bc2f1edbe
Clean internal classes from public API
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
357
diff
changeset
|
377 */ |
36
205f9b59b400
Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
378 public Nodeid node() { |
205f9b59b400
Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
379 return Nodeid.fromBinary(header, 0); |
205f9b59b400
Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
380 } |
169
8c8e3f372fa1
Towards initial clone: refactor HgBundle to provide slightly higher-level structure of the bundle
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
157
diff
changeset
|
381 |
358
fc8bc2f1edbe
Clean internal classes from public API
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
357
diff
changeset
|
382 /** |
fc8bc2f1edbe
Clean internal classes from public API
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
357
diff
changeset
|
383 * <b>p1</b> <i>(parent 1)</i> field of the group element |
fc8bc2f1edbe
Clean internal classes from public API
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
357
diff
changeset
|
384 * @return revision of parent 1, never <code>null</code> |
fc8bc2f1edbe
Clean internal classes from public API
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
357
diff
changeset
|
385 */ |
36
205f9b59b400
Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
386 public Nodeid firstParent() { |
205f9b59b400
Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
387 return Nodeid.fromBinary(header, 20); |
205f9b59b400
Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
388 } |
169
8c8e3f372fa1
Towards initial clone: refactor HgBundle to provide slightly higher-level structure of the bundle
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
157
diff
changeset
|
389 |
358
fc8bc2f1edbe
Clean internal classes from public API
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
357
diff
changeset
|
390 /** |
fc8bc2f1edbe
Clean internal classes from public API
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
357
diff
changeset
|
391 * <b>p2</b> <i>(parent 2)</i> field of the group element |
fc8bc2f1edbe
Clean internal classes from public API
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
357
diff
changeset
|
392 * @return revision of parent 2, never <code>null</code> |
fc8bc2f1edbe
Clean internal classes from public API
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
357
diff
changeset
|
393 */ |
36
205f9b59b400
Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
394 public Nodeid secondParent() { |
205f9b59b400
Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
395 return Nodeid.fromBinary(header, 40); |
205f9b59b400
Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
396 } |
169
8c8e3f372fa1
Towards initial clone: refactor HgBundle to provide slightly higher-level structure of the bundle
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
157
diff
changeset
|
397 |
358
fc8bc2f1edbe
Clean internal classes from public API
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
357
diff
changeset
|
398 /** |
fc8bc2f1edbe
Clean internal classes from public API
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
357
diff
changeset
|
399 * <b>cs</b> <i>(changeset link)</i> field of the group element |
fc8bc2f1edbe
Clean internal classes from public API
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
357
diff
changeset
|
400 * @return changeset revision, never <code>null</code> |
fc8bc2f1edbe
Clean internal classes from public API
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
357
diff
changeset
|
401 */ |
fc8bc2f1edbe
Clean internal classes from public API
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
357
diff
changeset
|
402 public Nodeid cset() { |
36
205f9b59b400
Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
403 return Nodeid.fromBinary(header, 60); |
205f9b59b400
Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
404 } |
358
fc8bc2f1edbe
Clean internal classes from public API
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
357
diff
changeset
|
405 |
fc8bc2f1edbe
Clean internal classes from public API
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
357
diff
changeset
|
406 public byte[] rawDataByteArray() throws IOException { // XXX IOException or HgInvalidFileException? |
fc8bc2f1edbe
Clean internal classes from public API
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
357
diff
changeset
|
407 return rawData().byteArray(); |
fc8bc2f1edbe
Clean internal classes from public API
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
357
diff
changeset
|
408 } |
fc8bc2f1edbe
Clean internal classes from public API
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
357
diff
changeset
|
409 |
fc8bc2f1edbe
Clean internal classes from public API
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
357
diff
changeset
|
410 public byte[] apply(byte[] baseContent) throws IOException { |
fc8bc2f1edbe
Clean internal classes from public API
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
357
diff
changeset
|
411 return apply(new ByteArrayDataAccess(baseContent)); |
fc8bc2f1edbe
Clean internal classes from public API
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
357
diff
changeset
|
412 } |
169
8c8e3f372fa1
Towards initial clone: refactor HgBundle to provide slightly higher-level structure of the bundle
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
157
diff
changeset
|
413 |
358
fc8bc2f1edbe
Clean internal classes from public API
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
357
diff
changeset
|
414 /*package-local*/ DataAccess rawData() { |
169
8c8e3f372fa1
Towards initial clone: refactor HgBundle to provide slightly higher-level structure of the bundle
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
157
diff
changeset
|
415 return dataAccess; |
8c8e3f372fa1
Towards initial clone: refactor HgBundle to provide slightly higher-level structure of the bundle
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
157
diff
changeset
|
416 } |
8c8e3f372fa1
Towards initial clone: refactor HgBundle to provide slightly higher-level structure of the bundle
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
157
diff
changeset
|
417 |
329
694ebabb5cb3
Refactor revlog patch mechanism, towards patch merging
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
295
diff
changeset
|
418 /*package-local*/ Patch patch() throws IOException { |
169
8c8e3f372fa1
Towards initial clone: refactor HgBundle to provide slightly higher-level structure of the bundle
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
157
diff
changeset
|
419 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:
157
diff
changeset
|
420 dataAccess.reset(); |
329
694ebabb5cb3
Refactor revlog patch mechanism, towards patch merging
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
295
diff
changeset
|
421 patches = new Patch(); |
694ebabb5cb3
Refactor revlog patch mechanism, towards patch merging
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
295
diff
changeset
|
422 patches.read(dataAccess); |
169
8c8e3f372fa1
Towards initial clone: refactor HgBundle to provide slightly higher-level structure of the bundle
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
157
diff
changeset
|
423 } |
8c8e3f372fa1
Towards initial clone: refactor HgBundle to provide slightly higher-level structure of the bundle
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
157
diff
changeset
|
424 return patches; |
8c8e3f372fa1
Towards initial clone: refactor HgBundle to provide slightly higher-level structure of the bundle
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
157
diff
changeset
|
425 } |
8c8e3f372fa1
Towards initial clone: refactor HgBundle to provide slightly higher-level structure of the bundle
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
157
diff
changeset
|
426 |
358
fc8bc2f1edbe
Clean internal classes from public API
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
357
diff
changeset
|
427 /*package-local*/ byte[] apply(DataAccess baseContent) throws IOException { |
329
694ebabb5cb3
Refactor revlog patch mechanism, towards patch merging
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
295
diff
changeset
|
428 return patch().apply(baseContent, -1); |
169
8c8e3f372fa1
Towards initial clone: refactor HgBundle to provide slightly higher-level structure of the bundle
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
157
diff
changeset
|
429 } |
357
dfb8405d996f
Clean debug stacktraces
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
354
diff
changeset
|
430 |
dfb8405d996f
Clean debug stacktraces
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
354
diff
changeset
|
431 public String toString() { |
dfb8405d996f
Clean debug stacktraces
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
354
diff
changeset
|
432 int patchCount; |
dfb8405d996f
Clean debug stacktraces
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
354
diff
changeset
|
433 try { |
dfb8405d996f
Clean debug stacktraces
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
354
diff
changeset
|
434 patchCount = patch().count(); |
dfb8405d996f
Clean debug stacktraces
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
354
diff
changeset
|
435 } catch (IOException ex) { |
dfb8405d996f
Clean debug stacktraces
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
354
diff
changeset
|
436 ex.printStackTrace(); |
dfb8405d996f
Clean debug stacktraces
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
354
diff
changeset
|
437 patchCount = -1; |
dfb8405d996f
Clean debug stacktraces
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
354
diff
changeset
|
438 } |
dfb8405d996f
Clean debug stacktraces
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
354
diff
changeset
|
439 return String.format("%s %s %s %s; patches:%d\n", node().shortNotation(), firstParent().shortNotation(), secondParent().shortNotation(), cset().shortNotation(), patchCount); |
dfb8405d996f
Clean debug stacktraces
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
354
diff
changeset
|
440 } |
36
205f9b59b400
Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
441 } |
205f9b59b400
Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
442 } |