Mercurial > hg4j
annotate src/org/tmatesoft/hg/repo/HgManifest.java @ 463:a0507a9f3da0 smartgit3
Initial support for MqExtension
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Wed, 20 Jun 2012 21:16:21 +0200 |
parents | 63c5a9d7ca3f |
children | bb278ccf9866 |
rev | line source |
---|---|
13
df8c67f3006a
Basic manifest parsing to analyze what's in there
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
2
diff
changeset
|
1 /* |
390
6952d9ce97f1
Handle missing manifest revision case (brought up with Issue 23), do my best to report missing manifests when walking few manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
385
diff
changeset
|
2 * Copyright (c) 2010-2012 TMate Software Ltd |
74
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
28
diff
changeset
|
3 * |
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
28
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:
28
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:
28
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:
28
diff
changeset
|
7 * |
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
28
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:
28
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:
28
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:
28
diff
changeset
|
11 * GNU General Public License for more details. |
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
28
diff
changeset
|
12 * |
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
28
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:
28
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 |
2
08db726a0fb7
Shaping out low-level Hg structures
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
16 */ |
74
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
28
diff
changeset
|
17 package org.tmatesoft.hg.repo; |
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
28
diff
changeset
|
18 |
390
6952d9ce97f1
Handle missing manifest revision case (brought up with Issue 23), do my best to report missing manifests when walking few manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
385
diff
changeset
|
19 import static org.tmatesoft.hg.core.Nodeid.NULL; |
6952d9ce97f1
Handle missing manifest revision case (brought up with Issue 23), do my best to report missing manifests when walking few manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
385
diff
changeset
|
20 import static org.tmatesoft.hg.repo.HgRepository.BAD_REVISION; |
218
047b1dec7a04
Issue 7: Correctly handle manifest and changelog with different number of (or non-matching) revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
196
diff
changeset
|
21 import static org.tmatesoft.hg.repo.HgRepository.TIP; |
047b1dec7a04
Issue 7: Correctly handle manifest and changelog with different number of (or non-matching) revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
196
diff
changeset
|
22 |
232
b7347daa50e3
Allow to cat a file with changeset revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
222
diff
changeset
|
23 import java.io.ByteArrayOutputStream; |
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
|
24 import java.io.IOException; |
218
047b1dec7a04
Issue 7: Correctly handle manifest and changelog with different number of (or non-matching) revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
196
diff
changeset
|
25 import java.util.ArrayList; |
047b1dec7a04
Issue 7: Correctly handle manifest and changelog with different number of (or non-matching) revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
196
diff
changeset
|
26 import java.util.Arrays; |
326
d42a45a2c9d6
Alternative tag collection approach for a file history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
324
diff
changeset
|
27 import java.util.HashMap; |
d42a45a2c9d6
Alternative tag collection approach for a file history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
324
diff
changeset
|
28 import java.util.Map; |
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 |
390
6952d9ce97f1
Handle missing manifest revision case (brought up with Issue 23), do my best to report missing manifests when walking few manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
385
diff
changeset
|
30 import org.tmatesoft.hg.core.HgBadStateException; |
366
189dc6dc1c3e
Use exceptions to expose errors reading mercurial data
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
354
diff
changeset
|
31 import org.tmatesoft.hg.core.HgException; |
354
5f9073eabf06
Propagate errors with exceptions up to a end client
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
326
diff
changeset
|
32 import org.tmatesoft.hg.core.HgInvalidControlFileException; |
74
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
28
diff
changeset
|
33 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
|
34 import org.tmatesoft.hg.internal.DataAccess; |
266
0a2f445de774
Improve manifest parsing: reduce number of arrays instantiated for Nodeid
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
264
diff
changeset
|
35 import org.tmatesoft.hg.internal.DigestHelper; |
320
678e326fd27c
Issue 15: Exception accessing oddly named file from history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
313
diff
changeset
|
36 import org.tmatesoft.hg.internal.EncodingHelper; |
232
b7347daa50e3
Allow to cat a file with changeset revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
222
diff
changeset
|
37 import org.tmatesoft.hg.internal.Experimental; |
312
f9f3e9b67ccc
Facilitate cancellation and progress reporting in changelog and manifest iterations
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
304
diff
changeset
|
38 import org.tmatesoft.hg.internal.IterateControlMediator; |
218
047b1dec7a04
Issue 7: Correctly handle manifest and changelog with different number of (or non-matching) revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
196
diff
changeset
|
39 import org.tmatesoft.hg.internal.Lifecycle; |
304
85b8efde5586
Use memory-friendly set implementation to canonicalize filenames and nodeids
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
300
diff
changeset
|
40 import org.tmatesoft.hg.internal.Pool2; |
77
c677e1593919
Moved RevlogStream implementation into .internal
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
74
diff
changeset
|
41 import org.tmatesoft.hg.internal.RevlogStream; |
312
f9f3e9b67ccc
Facilitate cancellation and progress reporting in changelog and manifest iterations
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
304
diff
changeset
|
42 import org.tmatesoft.hg.util.CancelSupport; |
232
b7347daa50e3
Allow to cat a file with changeset revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
222
diff
changeset
|
43 import org.tmatesoft.hg.util.Path; |
312
f9f3e9b67ccc
Facilitate cancellation and progress reporting in changelog and manifest iterations
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
304
diff
changeset
|
44 import org.tmatesoft.hg.util.ProgressSupport; |
74
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
28
diff
changeset
|
45 |
2
08db726a0fb7
Shaping out low-level Hg structures
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
46 |
08db726a0fb7
Shaping out low-level Hg structures
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
47 /** |
08db726a0fb7
Shaping out low-level Hg structures
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
48 * |
74
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
28
diff
changeset
|
49 * @author Artem Tikhomirov |
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
28
diff
changeset
|
50 * @author TMate Software Ltd. |
2
08db726a0fb7
Shaping out low-level Hg structures
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
51 */ |
08db726a0fb7
Shaping out low-level Hg structures
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
52 public class HgManifest extends Revlog { |
218
047b1dec7a04
Issue 7: Correctly handle manifest and changelog with different number of (or non-matching) revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
196
diff
changeset
|
53 private RevisionMapper revisionMap; |
412
63c5a9d7ca3f
Follow-up for Issue 29: unify path translation for manifest and dirstate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
390
diff
changeset
|
54 private EncodingHelper encodingHelper; |
285
6dbbc53fc46d
Use Path instead of plain String for manifest file names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
268
diff
changeset
|
55 |
6dbbc53fc46d
Use Path instead of plain String for manifest file names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
268
diff
changeset
|
56 public enum Flags { |
6dbbc53fc46d
Use Path instead of plain String for manifest file names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
268
diff
changeset
|
57 Exec, Link; |
6dbbc53fc46d
Use Path instead of plain String for manifest file names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
268
diff
changeset
|
58 |
6dbbc53fc46d
Use Path instead of plain String for manifest file names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
268
diff
changeset
|
59 static Flags parse(String flags) { |
6dbbc53fc46d
Use Path instead of plain String for manifest file names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
268
diff
changeset
|
60 if ("x".equalsIgnoreCase(flags)) { |
6dbbc53fc46d
Use Path instead of plain String for manifest file names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
268
diff
changeset
|
61 return Exec; |
6dbbc53fc46d
Use Path instead of plain String for manifest file names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
268
diff
changeset
|
62 } |
6dbbc53fc46d
Use Path instead of plain String for manifest file names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
268
diff
changeset
|
63 if ("l".equalsIgnoreCase(flags)) { |
6dbbc53fc46d
Use Path instead of plain String for manifest file names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
268
diff
changeset
|
64 return Link; |
6dbbc53fc46d
Use Path instead of plain String for manifest file names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
268
diff
changeset
|
65 } |
6dbbc53fc46d
Use Path instead of plain String for manifest file names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
268
diff
changeset
|
66 if (flags == null) { |
6dbbc53fc46d
Use Path instead of plain String for manifest file names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
268
diff
changeset
|
67 return null; |
6dbbc53fc46d
Use Path instead of plain String for manifest file names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
268
diff
changeset
|
68 } |
6dbbc53fc46d
Use Path instead of plain String for manifest file names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
268
diff
changeset
|
69 throw new IllegalStateException(flags); |
6dbbc53fc46d
Use Path instead of plain String for manifest file names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
268
diff
changeset
|
70 } |
6dbbc53fc46d
Use Path instead of plain String for manifest file names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
268
diff
changeset
|
71 |
6dbbc53fc46d
Use Path instead of plain String for manifest file names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
268
diff
changeset
|
72 static Flags parse(byte[] data, int start, int length) { |
6dbbc53fc46d
Use Path instead of plain String for manifest file names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
268
diff
changeset
|
73 if (length == 0) { |
6dbbc53fc46d
Use Path instead of plain String for manifest file names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
268
diff
changeset
|
74 return null; |
6dbbc53fc46d
Use Path instead of plain String for manifest file names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
268
diff
changeset
|
75 } |
6dbbc53fc46d
Use Path instead of plain String for manifest file names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
268
diff
changeset
|
76 if (length == 1) { |
6dbbc53fc46d
Use Path instead of plain String for manifest file names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
268
diff
changeset
|
77 if (data[start] == 'x') { |
6dbbc53fc46d
Use Path instead of plain String for manifest file names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
268
diff
changeset
|
78 return Exec; |
6dbbc53fc46d
Use Path instead of plain String for manifest file names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
268
diff
changeset
|
79 } |
6dbbc53fc46d
Use Path instead of plain String for manifest file names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
268
diff
changeset
|
80 if (data[start] == 'l') { |
6dbbc53fc46d
Use Path instead of plain String for manifest file names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
268
diff
changeset
|
81 return Link; |
6dbbc53fc46d
Use Path instead of plain String for manifest file names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
268
diff
changeset
|
82 } |
6dbbc53fc46d
Use Path instead of plain String for manifest file names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
268
diff
changeset
|
83 // FALL THROUGH |
6dbbc53fc46d
Use Path instead of plain String for manifest file names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
268
diff
changeset
|
84 } |
6dbbc53fc46d
Use Path instead of plain String for manifest file names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
268
diff
changeset
|
85 throw new IllegalStateException(new String(data, start, length)); |
6dbbc53fc46d
Use Path instead of plain String for manifest file names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
268
diff
changeset
|
86 } |
6dbbc53fc46d
Use Path instead of plain String for manifest file names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
268
diff
changeset
|
87 |
6dbbc53fc46d
Use Path instead of plain String for manifest file names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
268
diff
changeset
|
88 String nativeString() { |
6dbbc53fc46d
Use Path instead of plain String for manifest file names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
268
diff
changeset
|
89 if (this == Exec) { |
6dbbc53fc46d
Use Path instead of plain String for manifest file names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
268
diff
changeset
|
90 return "x"; |
6dbbc53fc46d
Use Path instead of plain String for manifest file names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
268
diff
changeset
|
91 } |
6dbbc53fc46d
Use Path instead of plain String for manifest file names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
268
diff
changeset
|
92 if (this == Link) { |
6dbbc53fc46d
Use Path instead of plain String for manifest file names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
268
diff
changeset
|
93 return "l"; |
6dbbc53fc46d
Use Path instead of plain String for manifest file names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
268
diff
changeset
|
94 } |
6dbbc53fc46d
Use Path instead of plain String for manifest file names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
268
diff
changeset
|
95 throw new IllegalStateException(toString()); |
6dbbc53fc46d
Use Path instead of plain String for manifest file names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
268
diff
changeset
|
96 } |
6dbbc53fc46d
Use Path instead of plain String for manifest file names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
268
diff
changeset
|
97 } |
2
08db726a0fb7
Shaping out low-level Hg structures
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
98 |
412
63c5a9d7ca3f
Follow-up for Issue 29: unify path translation for manifest and dirstate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
390
diff
changeset
|
99 /*package-local*/ HgManifest(HgRepository hgRepo, RevlogStream content, EncodingHelper eh) { |
21
e929cecae4e1
Refactor to move revlog content to base class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
20
diff
changeset
|
100 super(hgRepo, content); |
412
63c5a9d7ca3f
Follow-up for Issue 29: unify path translation for manifest and dirstate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
390
diff
changeset
|
101 encodingHelper = eh; |
13
df8c67f3006a
Basic manifest parsing to analyze what's in there
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
2
diff
changeset
|
102 } |
df8c67f3006a
Basic manifest parsing to analyze what's in there
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
2
diff
changeset
|
103 |
218
047b1dec7a04
Issue 7: Correctly handle manifest and changelog with different number of (or non-matching) revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
196
diff
changeset
|
104 /** |
390
6952d9ce97f1
Handle missing manifest revision case (brought up with Issue 23), do my best to report missing manifests when walking few manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
385
diff
changeset
|
105 * Walks manifest revisions that correspond to specified range of changesets. The order in which manifest versions get reported |
6952d9ce97f1
Handle missing manifest revision case (brought up with Issue 23), do my best to report missing manifests when walking few manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
385
diff
changeset
|
106 * to the inspector corresponds to physical order of manifest revisions, not that of changesets (with few exceptions as noted below). |
6952d9ce97f1
Handle missing manifest revision case (brought up with Issue 23), do my best to report missing manifests when walking few manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
385
diff
changeset
|
107 * That is, for cset-manifest revision pairs: |
6952d9ce97f1
Handle missing manifest revision case (brought up with Issue 23), do my best to report missing manifests when walking few manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
385
diff
changeset
|
108 * <pre> |
6952d9ce97f1
Handle missing manifest revision case (brought up with Issue 23), do my best to report missing manifests when walking few manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
385
diff
changeset
|
109 * 3 8 |
6952d9ce97f1
Handle missing manifest revision case (brought up with Issue 23), do my best to report missing manifests when walking few manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
385
diff
changeset
|
110 * 4 7 |
6952d9ce97f1
Handle missing manifest revision case (brought up with Issue 23), do my best to report missing manifests when walking few manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
385
diff
changeset
|
111 * 5 9 |
6952d9ce97f1
Handle missing manifest revision case (brought up with Issue 23), do my best to report missing manifests when walking few manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
385
diff
changeset
|
112 * </pre> |
6952d9ce97f1
Handle missing manifest revision case (brought up with Issue 23), do my best to report missing manifests when walking few manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
385
diff
changeset
|
113 * call <code>walk(3,5, insp)</code> would yield (4,7), (3,8) and (5,9) to the inspector; |
6952d9ce97f1
Handle missing manifest revision case (brought up with Issue 23), do my best to report missing manifests when walking few manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
385
diff
changeset
|
114 * different order of arguments, <code>walk(5, 3, insp)</code>, makes no difference. |
6952d9ce97f1
Handle missing manifest revision case (brought up with Issue 23), do my best to report missing manifests when walking few manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
385
diff
changeset
|
115 * |
6952d9ce97f1
Handle missing manifest revision case (brought up with Issue 23), do my best to report missing manifests when walking few manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
385
diff
changeset
|
116 * <p>Physical layout of mercurial files (revlog) doesn't impose any restriction on whether manifest and changeset revisions shall go |
6952d9ce97f1
Handle missing manifest revision case (brought up with Issue 23), do my best to report missing manifests when walking few manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
385
diff
changeset
|
117 * incrementally, nor it mandates presence of manifest version for a changeset. Thus, there might be changesets that record {@link Nodeid#NULL} |
6952d9ce97f1
Handle missing manifest revision case (brought up with Issue 23), do my best to report missing manifests when walking few manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
385
diff
changeset
|
118 * as corresponding manifest revision. This situation is deemed exceptional now and what would <code>inspector</code> get depends on whether |
6952d9ce97f1
Handle missing manifest revision case (brought up with Issue 23), do my best to report missing manifests when walking few manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
385
diff
changeset
|
119 * <code>start</code> or <code>end</code> arguments point to such changeset, or such changeset happen to be somewhere inside the range |
6952d9ce97f1
Handle missing manifest revision case (brought up with Issue 23), do my best to report missing manifests when walking few manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
385
diff
changeset
|
120 * <code>[start..end]</code>. Implementation does it best to report empty manifests (<code>Inspector.begin(BAD_REVISION, NULL, csetRevIndex);</code> |
6952d9ce97f1
Handle missing manifest revision case (brought up with Issue 23), do my best to report missing manifests when walking few manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
385
diff
changeset
|
121 * followed immediately by <code>Inspector.end(BAD_REVISION)</code> when <code>start</code> and/or <code>end</code> point to changeset with no associated |
6952d9ce97f1
Handle missing manifest revision case (brought up with Issue 23), do my best to report missing manifests when walking few manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
385
diff
changeset
|
122 * manifest revision. However, if changeset-manifest revision pairs look like: |
6952d9ce97f1
Handle missing manifest revision case (brought up with Issue 23), do my best to report missing manifests when walking few manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
385
diff
changeset
|
123 * <pre> |
6952d9ce97f1
Handle missing manifest revision case (brought up with Issue 23), do my best to report missing manifests when walking few manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
385
diff
changeset
|
124 * 3 8 |
6952d9ce97f1
Handle missing manifest revision case (brought up with Issue 23), do my best to report missing manifests when walking few manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
385
diff
changeset
|
125 * 4 -1 (cset records null revision for manifest) |
6952d9ce97f1
Handle missing manifest revision case (brought up with Issue 23), do my best to report missing manifests when walking few manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
385
diff
changeset
|
126 * 5 9 |
6952d9ce97f1
Handle missing manifest revision case (brought up with Issue 23), do my best to report missing manifests when walking few manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
385
diff
changeset
|
127 * </pre> |
6952d9ce97f1
Handle missing manifest revision case (brought up with Issue 23), do my best to report missing manifests when walking few manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
385
diff
changeset
|
128 * call <code>walk(3,5, insp)</code> would yield only (3,8) and (5,9) to the inspector, without additional empty |
6952d9ce97f1
Handle missing manifest revision case (brought up with Issue 23), do my best to report missing manifests when walking few manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
385
diff
changeset
|
129 * <code>Inspector.begin(); Inspector.end()</code> call pair. |
218
047b1dec7a04
Issue 7: Correctly handle manifest and changelog with different number of (or non-matching) revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
196
diff
changeset
|
130 * |
047b1dec7a04
Issue 7: Correctly handle manifest and changelog with different number of (or non-matching) revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
196
diff
changeset
|
131 * @param start changelog (not manifest!) revision to begin with |
047b1dec7a04
Issue 7: Correctly handle manifest and changelog with different number of (or non-matching) revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
196
diff
changeset
|
132 * @param end changelog (not manifest!) revision to stop, inclusive. |
390
6952d9ce97f1
Handle missing manifest revision case (brought up with Issue 23), do my best to report missing manifests when walking few manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
385
diff
changeset
|
133 * @param inspector manifest revision visitor, can't be <code>null</code> |
6952d9ce97f1
Handle missing manifest revision case (brought up with Issue 23), do my best to report missing manifests when walking few manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
385
diff
changeset
|
134 * @throws HgInvalidControlFileException if access to revlog index/data entry failed |
218
047b1dec7a04
Issue 7: Correctly handle manifest and changelog with different number of (or non-matching) revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
196
diff
changeset
|
135 */ |
366
189dc6dc1c3e
Use exceptions to expose errors reading mercurial data
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
354
diff
changeset
|
136 public void walk(int start, int end, final Inspector inspector) throws /*FIXME HgInvalidRevisionException,*/ HgInvalidControlFileException { |
196
e2115da4cf6a
Pool objects to avoid memory polution with duplicates
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
157
diff
changeset
|
137 if (inspector == null) { |
e2115da4cf6a
Pool objects to avoid memory polution with duplicates
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
157
diff
changeset
|
138 throw new IllegalArgumentException(); |
e2115da4cf6a
Pool objects to avoid memory polution with duplicates
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
157
diff
changeset
|
139 } |
390
6952d9ce97f1
Handle missing manifest revision case (brought up with Issue 23), do my best to report missing manifests when walking few manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
385
diff
changeset
|
140 final int csetFirst = start <= end ? start : end, csetLast = start > end ? start : end; |
6952d9ce97f1
Handle missing manifest revision case (brought up with Issue 23), do my best to report missing manifests when walking few manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
385
diff
changeset
|
141 int manifestFirst, manifestLast, i = 0; |
6952d9ce97f1
Handle missing manifest revision case (brought up with Issue 23), do my best to report missing manifests when walking few manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
385
diff
changeset
|
142 do { |
6952d9ce97f1
Handle missing manifest revision case (brought up with Issue 23), do my best to report missing manifests when walking few manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
385
diff
changeset
|
143 manifestFirst = fromChangelog(csetFirst+i); |
6952d9ce97f1
Handle missing manifest revision case (brought up with Issue 23), do my best to report missing manifests when walking few manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
385
diff
changeset
|
144 if (manifestFirst == -1) { |
6952d9ce97f1
Handle missing manifest revision case (brought up with Issue 23), do my best to report missing manifests when walking few manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
385
diff
changeset
|
145 inspector.begin(BAD_REVISION, NULL, csetFirst+i); |
6952d9ce97f1
Handle missing manifest revision case (brought up with Issue 23), do my best to report missing manifests when walking few manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
385
diff
changeset
|
146 inspector.end(BAD_REVISION); |
6952d9ce97f1
Handle missing manifest revision case (brought up with Issue 23), do my best to report missing manifests when walking few manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
385
diff
changeset
|
147 } |
6952d9ce97f1
Handle missing manifest revision case (brought up with Issue 23), do my best to report missing manifests when walking few manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
385
diff
changeset
|
148 i++; |
6952d9ce97f1
Handle missing manifest revision case (brought up with Issue 23), do my best to report missing manifests when walking few manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
385
diff
changeset
|
149 } while (manifestFirst == -1 && csetFirst+i <= csetLast); |
6952d9ce97f1
Handle missing manifest revision case (brought up with Issue 23), do my best to report missing manifests when walking few manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
385
diff
changeset
|
150 if (manifestFirst == -1) { |
6952d9ce97f1
Handle missing manifest revision case (brought up with Issue 23), do my best to report missing manifests when walking few manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
385
diff
changeset
|
151 getRepo().getContext().getLog().info(getClass(), "None of changesets [%d..%d] have associated manifest revision", csetFirst, csetLast); |
6952d9ce97f1
Handle missing manifest revision case (brought up with Issue 23), do my best to report missing manifests when walking few manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
385
diff
changeset
|
152 // we ran through all revisions in [start..end] and none of them had manifest. |
6952d9ce97f1
Handle missing manifest revision case (brought up with Issue 23), do my best to report missing manifests when walking few manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
385
diff
changeset
|
153 // we reported that to inspector and proceeding is done now. |
6952d9ce97f1
Handle missing manifest revision case (brought up with Issue 23), do my best to report missing manifests when walking few manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
385
diff
changeset
|
154 return; |
6952d9ce97f1
Handle missing manifest revision case (brought up with Issue 23), do my best to report missing manifests when walking few manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
385
diff
changeset
|
155 } |
6952d9ce97f1
Handle missing manifest revision case (brought up with Issue 23), do my best to report missing manifests when walking few manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
385
diff
changeset
|
156 i = 0; |
6952d9ce97f1
Handle missing manifest revision case (brought up with Issue 23), do my best to report missing manifests when walking few manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
385
diff
changeset
|
157 do { |
6952d9ce97f1
Handle missing manifest revision case (brought up with Issue 23), do my best to report missing manifests when walking few manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
385
diff
changeset
|
158 manifestLast = fromChangelog(csetLast-i); |
6952d9ce97f1
Handle missing manifest revision case (brought up with Issue 23), do my best to report missing manifests when walking few manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
385
diff
changeset
|
159 if (manifestLast == -1) { |
6952d9ce97f1
Handle missing manifest revision case (brought up with Issue 23), do my best to report missing manifests when walking few manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
385
diff
changeset
|
160 inspector.begin(BAD_REVISION, NULL, csetLast-i); |
6952d9ce97f1
Handle missing manifest revision case (brought up with Issue 23), do my best to report missing manifests when walking few manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
385
diff
changeset
|
161 inspector.end(BAD_REVISION); |
6952d9ce97f1
Handle missing manifest revision case (brought up with Issue 23), do my best to report missing manifests when walking few manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
385
diff
changeset
|
162 } |
6952d9ce97f1
Handle missing manifest revision case (brought up with Issue 23), do my best to report missing manifests when walking few manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
385
diff
changeset
|
163 i++; |
6952d9ce97f1
Handle missing manifest revision case (brought up with Issue 23), do my best to report missing manifests when walking few manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
385
diff
changeset
|
164 } while (manifestLast == -1 && csetLast-i >= csetFirst); |
6952d9ce97f1
Handle missing manifest revision case (brought up with Issue 23), do my best to report missing manifests when walking few manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
385
diff
changeset
|
165 if (manifestLast == -1) { |
6952d9ce97f1
Handle missing manifest revision case (brought up with Issue 23), do my best to report missing manifests when walking few manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
385
diff
changeset
|
166 // hmm, manifestFirst != -1 here, hence there's i from [csetFirst..csetLast] for which manifest entry exists, |
6952d9ce97f1
Handle missing manifest revision case (brought up with Issue 23), do my best to report missing manifests when walking few manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
385
diff
changeset
|
167 // and thus it's impossible to run into manifestLast == -1. Nevertheless, never hurts to check. |
6952d9ce97f1
Handle missing manifest revision case (brought up with Issue 23), do my best to report missing manifests when walking few manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
385
diff
changeset
|
168 throw new HgBadStateException(String.format("Manifest %d-%d(!) for cset range [%d..%d] ", manifestFirst, manifestLast, csetFirst, csetLast)); |
6952d9ce97f1
Handle missing manifest revision case (brought up with Issue 23), do my best to report missing manifests when walking few manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
385
diff
changeset
|
169 } |
6952d9ce97f1
Handle missing manifest revision case (brought up with Issue 23), do my best to report missing manifests when walking few manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
385
diff
changeset
|
170 if (manifestLast < manifestFirst) { |
300
650b45d290b1
Share range check code
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
285
diff
changeset
|
171 // there are tool-constructed repositories that got order of changeset revisions completely different from that of manifest |
390
6952d9ce97f1
Handle missing manifest revision case (brought up with Issue 23), do my best to report missing manifests when walking few manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
385
diff
changeset
|
172 int x = manifestLast; |
6952d9ce97f1
Handle missing manifest revision case (brought up with Issue 23), do my best to report missing manifests when walking few manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
385
diff
changeset
|
173 manifestLast = manifestFirst; |
6952d9ce97f1
Handle missing manifest revision case (brought up with Issue 23), do my best to report missing manifests when walking few manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
385
diff
changeset
|
174 manifestFirst = x; |
300
650b45d290b1
Share range check code
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
285
diff
changeset
|
175 } |
412
63c5a9d7ca3f
Follow-up for Issue 29: unify path translation for manifest and dirstate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
390
diff
changeset
|
176 content.iterate(manifestFirst, manifestLast, true, new ManifestParser(inspector, encodingHelper)); |
19
40532cdc92fc
Inspector (visitor) for manifest
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
16
diff
changeset
|
177 } |
218
047b1dec7a04
Issue 7: Correctly handle manifest and changelog with different number of (or non-matching) revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
196
diff
changeset
|
178 |
254
a620f0663a37
Collect tags for a file - improve performance of 'sparse' manifest reads
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
232
diff
changeset
|
179 /** |
390
6952d9ce97f1
Handle missing manifest revision case (brought up with Issue 23), do my best to report missing manifests when walking few manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
385
diff
changeset
|
180 * "Sparse" iteration of the manifest, more effective than accessing revisions one by one. |
6952d9ce97f1
Handle missing manifest revision case (brought up with Issue 23), do my best to report missing manifests when walking few manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
385
diff
changeset
|
181 * <p> Inspector is invoked for each changeset revision supplied, even when there's no manifest |
6952d9ce97f1
Handle missing manifest revision case (brought up with Issue 23), do my best to report missing manifests when walking few manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
385
diff
changeset
|
182 * revision associated with a changeset (@see {@link #walk(int, int, Inspector)} for more details when it happens). Order inspector |
6952d9ce97f1
Handle missing manifest revision case (brought up with Issue 23), do my best to report missing manifests when walking few manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
385
diff
changeset
|
183 * gets invoked doesn't resemble order of changeset revisions supplied, manifest revisions are reported in the order they appear |
6952d9ce97f1
Handle missing manifest revision case (brought up with Issue 23), do my best to report missing manifests when walking few manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
385
diff
changeset
|
184 * in manifest revlog (with exception of changesets with missing manifest that may be reported in any order). |
254
a620f0663a37
Collect tags for a file - improve performance of 'sparse' manifest reads
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
232
diff
changeset
|
185 * |
390
6952d9ce97f1
Handle missing manifest revision case (brought up with Issue 23), do my best to report missing manifests when walking few manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
385
diff
changeset
|
186 * @param inspector manifest revision visitor, can't be <code>null</code> |
6952d9ce97f1
Handle missing manifest revision case (brought up with Issue 23), do my best to report missing manifests when walking few manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
385
diff
changeset
|
187 * @param revisionIndexes local indexes of changesets to visit, non-<code>null</code> |
254
a620f0663a37
Collect tags for a file - improve performance of 'sparse' manifest reads
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
232
diff
changeset
|
188 */ |
367
2fadf8695f8a
Use 'revision index' instead of the vague 'local revision number' concept in the API
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
366
diff
changeset
|
189 public void walk(final Inspector inspector, int... revisionIndexes) throws HgInvalidControlFileException{ |
2fadf8695f8a
Use 'revision index' instead of the vague 'local revision number' concept in the API
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
366
diff
changeset
|
190 if (inspector == null || revisionIndexes == null) { |
254
a620f0663a37
Collect tags for a file - improve performance of 'sparse' manifest reads
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
232
diff
changeset
|
191 throw new IllegalArgumentException(); |
a620f0663a37
Collect tags for a file - improve performance of 'sparse' manifest reads
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
232
diff
changeset
|
192 } |
390
6952d9ce97f1
Handle missing manifest revision case (brought up with Issue 23), do my best to report missing manifests when walking few manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
385
diff
changeset
|
193 int[] manifestRevs = toManifestRevisionIndexes(revisionIndexes, inspector); |
412
63c5a9d7ca3f
Follow-up for Issue 29: unify path translation for manifest and dirstate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
390
diff
changeset
|
194 content.iterate(manifestRevs, true, new ManifestParser(inspector, encodingHelper)); |
254
a620f0663a37
Collect tags for a file - improve performance of 'sparse' manifest reads
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
232
diff
changeset
|
195 } |
a620f0663a37
Collect tags for a file - improve performance of 'sparse' manifest reads
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
232
diff
changeset
|
196 |
390
6952d9ce97f1
Handle missing manifest revision case (brought up with Issue 23), do my best to report missing manifests when walking few manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
385
diff
changeset
|
197 // |
6952d9ce97f1
Handle missing manifest revision case (brought up with Issue 23), do my best to report missing manifests when walking few manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
385
diff
changeset
|
198 /** |
6952d9ce97f1
Handle missing manifest revision case (brought up with Issue 23), do my best to report missing manifests when walking few manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
385
diff
changeset
|
199 * Tells manifest revision number that corresponds to the given changeset. |
6952d9ce97f1
Handle missing manifest revision case (brought up with Issue 23), do my best to report missing manifests when walking few manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
385
diff
changeset
|
200 * @return manifest revision index, or -1 if changeset has no associated manifest (cset records NULL nodeid for manifest) |
6952d9ce97f1
Handle missing manifest revision case (brought up with Issue 23), do my best to report missing manifests when walking few manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
385
diff
changeset
|
201 */ |
368
8107b95f4280
Update Javadoc with 'revision index'
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
367
diff
changeset
|
202 /*package-local*/ int fromChangelog(int changesetRevisionIndex) throws HgInvalidControlFileException { |
8107b95f4280
Update Javadoc with 'revision index'
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
367
diff
changeset
|
203 if (HgInternals.wrongRevisionIndex(changesetRevisionIndex)) { |
8107b95f4280
Update Javadoc with 'revision index'
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
367
diff
changeset
|
204 throw new IllegalArgumentException(String.valueOf(changesetRevisionIndex)); |
218
047b1dec7a04
Issue 7: Correctly handle manifest and changelog with different number of (or non-matching) revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
196
diff
changeset
|
205 } |
368
8107b95f4280
Update Javadoc with 'revision index'
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
367
diff
changeset
|
206 if (changesetRevisionIndex == HgRepository.WORKING_COPY || changesetRevisionIndex == HgRepository.BAD_REVISION) { |
257
f39fb6b3cc76
Handle revision constants correctly
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
254
diff
changeset
|
207 throw new IllegalArgumentException("Can't use constants like WORKING_COPY or BAD_REVISION"); |
f39fb6b3cc76
Handle revision constants correctly
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
254
diff
changeset
|
208 } |
f39fb6b3cc76
Handle revision constants correctly
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
254
diff
changeset
|
209 // revisionNumber == TIP is processed by RevisionMapper |
218
047b1dec7a04
Issue 7: Correctly handle manifest and changelog with different number of (or non-matching) revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
196
diff
changeset
|
210 if (revisionMap == null) { |
047b1dec7a04
Issue 7: Correctly handle manifest and changelog with different number of (or non-matching) revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
196
diff
changeset
|
211 revisionMap = new RevisionMapper(getRepo()); |
047b1dec7a04
Issue 7: Correctly handle manifest and changelog with different number of (or non-matching) revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
196
diff
changeset
|
212 content.iterate(0, TIP, false, revisionMap); |
047b1dec7a04
Issue 7: Correctly handle manifest and changelog with different number of (or non-matching) revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
196
diff
changeset
|
213 } |
368
8107b95f4280
Update Javadoc with 'revision index'
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
367
diff
changeset
|
214 return revisionMap.at(changesetRevisionIndex); |
218
047b1dec7a04
Issue 7: Correctly handle manifest and changelog with different number of (or non-matching) revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
196
diff
changeset
|
215 } |
047b1dec7a04
Issue 7: Correctly handle manifest and changelog with different number of (or non-matching) revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
196
diff
changeset
|
216 |
232
b7347daa50e3
Allow to cat a file with changeset revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
222
diff
changeset
|
217 /** |
b7347daa50e3
Allow to cat a file with changeset revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
222
diff
changeset
|
218 * Extracts file revision as it was known at the time of given changeset. |
b7347daa50e3
Allow to cat a file with changeset revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
222
diff
changeset
|
219 * |
367
2fadf8695f8a
Use 'revision index' instead of the vague 'local revision number' concept in the API
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
366
diff
changeset
|
220 * @param changelogRevisionIndex local changeset index |
232
b7347daa50e3
Allow to cat a file with changeset revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
222
diff
changeset
|
221 * @param file path to file in question |
b7347daa50e3
Allow to cat a file with changeset revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
222
diff
changeset
|
222 * @return file revision or <code>null</code> if manifest at specified revision doesn't list such file |
b7347daa50e3
Allow to cat a file with changeset revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
222
diff
changeset
|
223 */ |
326
d42a45a2c9d6
Alternative tag collection approach for a file history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
324
diff
changeset
|
224 @Experimental(reason="Perhaps, HgDataFile shall own this method, or get a delegate?") |
367
2fadf8695f8a
Use 'revision index' instead of the vague 'local revision number' concept in the API
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
366
diff
changeset
|
225 public Nodeid getFileRevision(int changelogRevisionIndex, final Path file) throws HgInvalidControlFileException{ |
2fadf8695f8a
Use 'revision index' instead of the vague 'local revision number' concept in the API
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
366
diff
changeset
|
226 return getFileRevisions(file, changelogRevisionIndex).get(changelogRevisionIndex); |
326
d42a45a2c9d6
Alternative tag collection approach for a file history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
324
diff
changeset
|
227 } |
d42a45a2c9d6
Alternative tag collection approach for a file history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
324
diff
changeset
|
228 |
d42a45a2c9d6
Alternative tag collection approach for a file history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
324
diff
changeset
|
229 // XXX package-local, IntMap, and HgDataFile getFileRevisionAt(int... localChangelogRevisions) |
d42a45a2c9d6
Alternative tag collection approach for a file history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
324
diff
changeset
|
230 @Experimental(reason="@see #getFileRevision") |
367
2fadf8695f8a
Use 'revision index' instead of the vague 'local revision number' concept in the API
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
366
diff
changeset
|
231 public Map<Integer, Nodeid> getFileRevisions(final Path file, int... changelogRevisionIndexes) throws HgInvalidControlFileException{ |
326
d42a45a2c9d6
Alternative tag collection approach for a file history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
324
diff
changeset
|
232 // FIXME need tests |
390
6952d9ce97f1
Handle missing manifest revision case (brought up with Issue 23), do my best to report missing manifests when walking few manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
385
diff
changeset
|
233 int[] manifestRevisionIndexes = toManifestRevisionIndexes(changelogRevisionIndexes, null); |
367
2fadf8695f8a
Use 'revision index' instead of the vague 'local revision number' concept in the API
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
366
diff
changeset
|
234 final HashMap<Integer,Nodeid> rv = new HashMap<Integer, Nodeid>(changelogRevisionIndexes.length); |
2fadf8695f8a
Use 'revision index' instead of the vague 'local revision number' concept in the API
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
366
diff
changeset
|
235 content.iterate(manifestRevisionIndexes, true, new RevlogStream.Inspector() { |
232
b7347daa50e3
Allow to cat a file with changeset revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
222
diff
changeset
|
236 |
366
189dc6dc1c3e
Use exceptions to expose errors reading mercurial data
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
354
diff
changeset
|
237 public void next(int revisionNumber, int actualLen, int baseRevision, int linkRevision, int parent1Revision, int parent2Revision, byte[] nodeid, DataAccess data) throws HgException { |
232
b7347daa50e3
Allow to cat a file with changeset revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
222
diff
changeset
|
238 ByteArrayOutputStream bos = new ByteArrayOutputStream(); |
b7347daa50e3
Allow to cat a file with changeset revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
222
diff
changeset
|
239 try { |
b7347daa50e3
Allow to cat a file with changeset revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
222
diff
changeset
|
240 byte b; |
b7347daa50e3
Allow to cat a file with changeset revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
222
diff
changeset
|
241 while (!data.isEmpty() && (b = data.readByte()) != '\n') { |
b7347daa50e3
Allow to cat a file with changeset revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
222
diff
changeset
|
242 if (b != 0) { |
b7347daa50e3
Allow to cat a file with changeset revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
222
diff
changeset
|
243 bos.write(b); |
b7347daa50e3
Allow to cat a file with changeset revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
222
diff
changeset
|
244 } else { |
b7347daa50e3
Allow to cat a file with changeset revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
222
diff
changeset
|
245 String fname = new String(bos.toByteArray()); |
b7347daa50e3
Allow to cat a file with changeset revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
222
diff
changeset
|
246 bos.reset(); |
b7347daa50e3
Allow to cat a file with changeset revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
222
diff
changeset
|
247 if (file.toString().equals(fname)) { |
b7347daa50e3
Allow to cat a file with changeset revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
222
diff
changeset
|
248 byte[] nid = new byte[40]; |
b7347daa50e3
Allow to cat a file with changeset revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
222
diff
changeset
|
249 data.readBytes(nid, 0, 40); |
326
d42a45a2c9d6
Alternative tag collection approach for a file history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
324
diff
changeset
|
250 rv.put(linkRevision, Nodeid.fromAscii(nid, 0, 40)); |
232
b7347daa50e3
Allow to cat a file with changeset revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
222
diff
changeset
|
251 break; |
326
d42a45a2c9d6
Alternative tag collection approach for a file history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
324
diff
changeset
|
252 } else { |
d42a45a2c9d6
Alternative tag collection approach for a file history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
324
diff
changeset
|
253 data.skip(40); |
232
b7347daa50e3
Allow to cat a file with changeset revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
222
diff
changeset
|
254 } |
b7347daa50e3
Allow to cat a file with changeset revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
222
diff
changeset
|
255 // else skip to the end of line |
b7347daa50e3
Allow to cat a file with changeset revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
222
diff
changeset
|
256 while (!data.isEmpty() && (b = data.readByte()) != '\n') |
b7347daa50e3
Allow to cat a file with changeset revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
222
diff
changeset
|
257 ; |
b7347daa50e3
Allow to cat a file with changeset revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
222
diff
changeset
|
258 } |
b7347daa50e3
Allow to cat a file with changeset revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
222
diff
changeset
|
259 } |
b7347daa50e3
Allow to cat a file with changeset revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
222
diff
changeset
|
260 } catch (IOException ex) { |
366
189dc6dc1c3e
Use exceptions to expose errors reading mercurial data
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
354
diff
changeset
|
261 throw new HgException(ex); |
232
b7347daa50e3
Allow to cat a file with changeset revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
222
diff
changeset
|
262 } |
b7347daa50e3
Allow to cat a file with changeset revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
222
diff
changeset
|
263 } |
b7347daa50e3
Allow to cat a file with changeset revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
222
diff
changeset
|
264 }); |
326
d42a45a2c9d6
Alternative tag collection approach for a file history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
324
diff
changeset
|
265 return rv; |
232
b7347daa50e3
Allow to cat a file with changeset revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
222
diff
changeset
|
266 } |
326
d42a45a2c9d6
Alternative tag collection approach for a file history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
324
diff
changeset
|
267 |
d42a45a2c9d6
Alternative tag collection approach for a file history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
324
diff
changeset
|
268 |
390
6952d9ce97f1
Handle missing manifest revision case (brought up with Issue 23), do my best to report missing manifests when walking few manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
385
diff
changeset
|
269 /** |
6952d9ce97f1
Handle missing manifest revision case (brought up with Issue 23), do my best to report missing manifests when walking few manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
385
diff
changeset
|
270 * @param changelogRevisionIndexes non-null |
6952d9ce97f1
Handle missing manifest revision case (brought up with Issue 23), do my best to report missing manifests when walking few manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
385
diff
changeset
|
271 * @param inspector may be null if reporting of missing manifests is not needed |
6952d9ce97f1
Handle missing manifest revision case (brought up with Issue 23), do my best to report missing manifests when walking few manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
385
diff
changeset
|
272 */ |
6952d9ce97f1
Handle missing manifest revision case (brought up with Issue 23), do my best to report missing manifests when walking few manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
385
diff
changeset
|
273 private int[] toManifestRevisionIndexes(int[] changelogRevisionIndexes, Inspector inspector) throws HgInvalidControlFileException { |
368
8107b95f4280
Update Javadoc with 'revision index'
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
367
diff
changeset
|
274 int[] manifestRevs = new int[changelogRevisionIndexes.length]; |
326
d42a45a2c9d6
Alternative tag collection approach for a file history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
324
diff
changeset
|
275 boolean needsSort = false; |
390
6952d9ce97f1
Handle missing manifest revision case (brought up with Issue 23), do my best to report missing manifests when walking few manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
385
diff
changeset
|
276 int j = 0; |
367
2fadf8695f8a
Use 'revision index' instead of the vague 'local revision number' concept in the API
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
366
diff
changeset
|
277 for (int i = 0; i < changelogRevisionIndexes.length; i++) { |
2fadf8695f8a
Use 'revision index' instead of the vague 'local revision number' concept in the API
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
366
diff
changeset
|
278 final int manifestRevisionIndex = fromChangelog(changelogRevisionIndexes[i]); |
390
6952d9ce97f1
Handle missing manifest revision case (brought up with Issue 23), do my best to report missing manifests when walking few manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
385
diff
changeset
|
279 if (manifestRevisionIndex == -1) { |
6952d9ce97f1
Handle missing manifest revision case (brought up with Issue 23), do my best to report missing manifests when walking few manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
385
diff
changeset
|
280 if (inspector != null) { |
6952d9ce97f1
Handle missing manifest revision case (brought up with Issue 23), do my best to report missing manifests when walking few manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
385
diff
changeset
|
281 inspector.begin(BAD_REVISION, NULL, changelogRevisionIndexes[i]); |
6952d9ce97f1
Handle missing manifest revision case (brought up with Issue 23), do my best to report missing manifests when walking few manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
385
diff
changeset
|
282 inspector.end(BAD_REVISION); |
6952d9ce97f1
Handle missing manifest revision case (brought up with Issue 23), do my best to report missing manifests when walking few manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
385
diff
changeset
|
283 } |
6952d9ce97f1
Handle missing manifest revision case (brought up with Issue 23), do my best to report missing manifests when walking few manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
385
diff
changeset
|
284 // othrwise, ignore changeset without manifest |
6952d9ce97f1
Handle missing manifest revision case (brought up with Issue 23), do my best to report missing manifests when walking few manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
385
diff
changeset
|
285 } else { |
6952d9ce97f1
Handle missing manifest revision case (brought up with Issue 23), do my best to report missing manifests when walking few manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
385
diff
changeset
|
286 manifestRevs[j] = manifestRevisionIndex; |
6952d9ce97f1
Handle missing manifest revision case (brought up with Issue 23), do my best to report missing manifests when walking few manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
385
diff
changeset
|
287 if (j > 0 && manifestRevs[j-1] > manifestRevisionIndex) { |
6952d9ce97f1
Handle missing manifest revision case (brought up with Issue 23), do my best to report missing manifests when walking few manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
385
diff
changeset
|
288 needsSort = true; |
6952d9ce97f1
Handle missing manifest revision case (brought up with Issue 23), do my best to report missing manifests when walking few manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
385
diff
changeset
|
289 } |
6952d9ce97f1
Handle missing manifest revision case (brought up with Issue 23), do my best to report missing manifests when walking few manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
385
diff
changeset
|
290 j++; |
326
d42a45a2c9d6
Alternative tag collection approach for a file history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
324
diff
changeset
|
291 } |
d42a45a2c9d6
Alternative tag collection approach for a file history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
324
diff
changeset
|
292 } |
d42a45a2c9d6
Alternative tag collection approach for a file history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
324
diff
changeset
|
293 if (needsSort) { |
390
6952d9ce97f1
Handle missing manifest revision case (brought up with Issue 23), do my best to report missing manifests when walking few manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
385
diff
changeset
|
294 Arrays.sort(manifestRevs, 0, j); |
326
d42a45a2c9d6
Alternative tag collection approach for a file history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
324
diff
changeset
|
295 } |
390
6952d9ce97f1
Handle missing manifest revision case (brought up with Issue 23), do my best to report missing manifests when walking few manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
385
diff
changeset
|
296 if (j == manifestRevs.length) { |
6952d9ce97f1
Handle missing manifest revision case (brought up with Issue 23), do my best to report missing manifests when walking few manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
385
diff
changeset
|
297 return manifestRevs; |
6952d9ce97f1
Handle missing manifest revision case (brought up with Issue 23), do my best to report missing manifests when walking few manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
385
diff
changeset
|
298 } else { |
6952d9ce97f1
Handle missing manifest revision case (brought up with Issue 23), do my best to report missing manifests when walking few manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
385
diff
changeset
|
299 int[] rv = new int[j]; |
6952d9ce97f1
Handle missing manifest revision case (brought up with Issue 23), do my best to report missing manifests when walking few manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
385
diff
changeset
|
300 //Arrays.copyOfRange |
6952d9ce97f1
Handle missing manifest revision case (brought up with Issue 23), do my best to report missing manifests when walking few manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
385
diff
changeset
|
301 System.arraycopy(manifestRevs, 0, rv, 0, j); |
6952d9ce97f1
Handle missing manifest revision case (brought up with Issue 23), do my best to report missing manifests when walking few manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
385
diff
changeset
|
302 return rv; |
6952d9ce97f1
Handle missing manifest revision case (brought up with Issue 23), do my best to report missing manifests when walking few manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
385
diff
changeset
|
303 } |
326
d42a45a2c9d6
Alternative tag collection approach for a file history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
324
diff
changeset
|
304 } |
d42a45a2c9d6
Alternative tag collection approach for a file history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
324
diff
changeset
|
305 |
19
40532cdc92fc
Inspector (visitor) for manifest
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
16
diff
changeset
|
306 public interface Inspector { |
222
373e07cd3991
Due to discrepancy in manifest and changelor indexes, wrong manifest revisions got cached and compared
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
220
diff
changeset
|
307 boolean begin(int mainfestRevision, Nodeid nid, int changelogRevision); |
285
6dbbc53fc46d
Use Path instead of plain String for manifest file names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
268
diff
changeset
|
308 /** |
6dbbc53fc46d
Use Path instead of plain String for manifest file names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
268
diff
changeset
|
309 * @deprecated switch to {@link Inspector2#next(Nodeid, Path, Flags)} |
6dbbc53fc46d
Use Path instead of plain String for manifest file names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
268
diff
changeset
|
310 */ |
6dbbc53fc46d
Use Path instead of plain String for manifest file names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
268
diff
changeset
|
311 @Deprecated |
19
40532cdc92fc
Inspector (visitor) for manifest
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
16
diff
changeset
|
312 boolean next(Nodeid nid, String fname, String flags); |
222
373e07cd3991
Due to discrepancy in manifest and changelor indexes, wrong manifest revisions got cached and compared
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
220
diff
changeset
|
313 boolean end(int manifestRevision); |
2
08db726a0fb7
Shaping out low-level Hg structures
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
314 } |
267
ec921ef0628e
Revert manifest parser changes - no single string and back to HashMap Pool
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
266
diff
changeset
|
315 |
285
6dbbc53fc46d
Use Path instead of plain String for manifest file names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
268
diff
changeset
|
316 @Experimental(reason="Explore Path alternative for filenames and enum for flags") |
6dbbc53fc46d
Use Path instead of plain String for manifest file names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
268
diff
changeset
|
317 public interface Inspector2 extends Inspector { |
6dbbc53fc46d
Use Path instead of plain String for manifest file names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
268
diff
changeset
|
318 boolean next(Nodeid nid, Path fname, Flags flags); |
267
ec921ef0628e
Revert manifest parser changes - no single string and back to HashMap Pool
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
266
diff
changeset
|
319 } |
326
d42a45a2c9d6
Alternative tag collection approach for a file history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
324
diff
changeset
|
320 |
268
c5980f287cc4
Use StringProxy when parsing manifest to minimize number of useless conversions and array instances
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
267
diff
changeset
|
321 /** |
c5980f287cc4
Use StringProxy when parsing manifest to minimize number of useless conversions and array instances
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
267
diff
changeset
|
322 * When Pool uses Strings directly, |
c5980f287cc4
Use StringProxy when parsing manifest to minimize number of useless conversions and array instances
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
267
diff
changeset
|
323 * ManifestParser creates new String instance with new char[] value, and does byte->char conversion. |
c5980f287cc4
Use StringProxy when parsing manifest to minimize number of useless conversions and array instances
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
267
diff
changeset
|
324 * For cpython repo, walk(0..10k), there are over 16 million filenames, of them only 3020 unique. |
c5980f287cc4
Use StringProxy when parsing manifest to minimize number of useless conversions and array instances
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
267
diff
changeset
|
325 * This means there are 15.9 million useless char[] instances and byte->char conversions |
c5980f287cc4
Use StringProxy when parsing manifest to minimize number of useless conversions and array instances
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
267
diff
changeset
|
326 * |
285
6dbbc53fc46d
Use Path instead of plain String for manifest file names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
268
diff
changeset
|
327 * When String (Path) is wrapped into {@link PathProxy}, there's extra overhead of byte[] representation |
6dbbc53fc46d
Use Path instead of plain String for manifest file names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
268
diff
changeset
|
328 * of the String, but these are only for unique Strings (Paths) (3020 in the example above). Besides, I save |
268
c5980f287cc4
Use StringProxy when parsing manifest to minimize number of useless conversions and array instances
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
267
diff
changeset
|
329 * useless char[] and byte->char conversions. |
c5980f287cc4
Use StringProxy when parsing manifest to minimize number of useless conversions and array instances
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
267
diff
changeset
|
330 */ |
285
6dbbc53fc46d
Use Path instead of plain String for manifest file names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
268
diff
changeset
|
331 private static class PathProxy { |
267
ec921ef0628e
Revert manifest parser changes - no single string and back to HashMap Pool
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
266
diff
changeset
|
332 private byte[] data; |
268
c5980f287cc4
Use StringProxy when parsing manifest to minimize number of useless conversions and array instances
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
267
diff
changeset
|
333 private int start; |
c5980f287cc4
Use StringProxy when parsing manifest to minimize number of useless conversions and array instances
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
267
diff
changeset
|
334 private final int hash, length; |
285
6dbbc53fc46d
Use Path instead of plain String for manifest file names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
268
diff
changeset
|
335 private Path result; |
412
63c5a9d7ca3f
Follow-up for Issue 29: unify path translation for manifest and dirstate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
390
diff
changeset
|
336 private final EncodingHelper encHelper; |
267
ec921ef0628e
Revert manifest parser changes - no single string and back to HashMap Pool
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
266
diff
changeset
|
337 |
412
63c5a9d7ca3f
Follow-up for Issue 29: unify path translation for manifest and dirstate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
390
diff
changeset
|
338 public PathProxy(byte[] data, int start, int length, EncodingHelper eh) { |
267
ec921ef0628e
Revert manifest parser changes - no single string and back to HashMap Pool
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
266
diff
changeset
|
339 this.data = data; |
ec921ef0628e
Revert manifest parser changes - no single string and back to HashMap Pool
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
266
diff
changeset
|
340 this.start = start; |
ec921ef0628e
Revert manifest parser changes - no single string and back to HashMap Pool
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
266
diff
changeset
|
341 this.length = length; |
412
63c5a9d7ca3f
Follow-up for Issue 29: unify path translation for manifest and dirstate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
390
diff
changeset
|
342 this.encHelper = eh; |
267
ec921ef0628e
Revert manifest parser changes - no single string and back to HashMap Pool
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
266
diff
changeset
|
343 |
268
c5980f287cc4
Use StringProxy when parsing manifest to minimize number of useless conversions and array instances
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
267
diff
changeset
|
344 // copy from String.hashCode(). In fact, not necessarily match result of String(data).hashCode |
c5980f287cc4
Use StringProxy when parsing manifest to minimize number of useless conversions and array instances
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
267
diff
changeset
|
345 // just need some nice algorithm here |
267
ec921ef0628e
Revert manifest parser changes - no single string and back to HashMap Pool
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
266
diff
changeset
|
346 int h = 0; |
ec921ef0628e
Revert manifest parser changes - no single string and back to HashMap Pool
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
266
diff
changeset
|
347 byte[] d = data; |
ec921ef0628e
Revert manifest parser changes - no single string and back to HashMap Pool
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
266
diff
changeset
|
348 for (int i = 0, off = start, len = length; i < len; i++) { |
ec921ef0628e
Revert manifest parser changes - no single string and back to HashMap Pool
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
266
diff
changeset
|
349 h = 31 * h + d[off++]; |
ec921ef0628e
Revert manifest parser changes - no single string and back to HashMap Pool
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
266
diff
changeset
|
350 } |
ec921ef0628e
Revert manifest parser changes - no single string and back to HashMap Pool
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
266
diff
changeset
|
351 hash = h; |
ec921ef0628e
Revert manifest parser changes - no single string and back to HashMap Pool
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
266
diff
changeset
|
352 } |
ec921ef0628e
Revert manifest parser changes - no single string and back to HashMap Pool
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
266
diff
changeset
|
353 |
ec921ef0628e
Revert manifest parser changes - no single string and back to HashMap Pool
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
266
diff
changeset
|
354 @Override |
ec921ef0628e
Revert manifest parser changes - no single string and back to HashMap Pool
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
266
diff
changeset
|
355 public boolean equals(Object obj) { |
285
6dbbc53fc46d
Use Path instead of plain String for manifest file names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
268
diff
changeset
|
356 if (false == obj instanceof PathProxy) { |
267
ec921ef0628e
Revert manifest parser changes - no single string and back to HashMap Pool
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
266
diff
changeset
|
357 return false; |
ec921ef0628e
Revert manifest parser changes - no single string and back to HashMap Pool
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
266
diff
changeset
|
358 } |
285
6dbbc53fc46d
Use Path instead of plain String for manifest file names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
268
diff
changeset
|
359 PathProxy o = (PathProxy) obj; |
267
ec921ef0628e
Revert manifest parser changes - no single string and back to HashMap Pool
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
266
diff
changeset
|
360 if (o.result != null && result != null) { |
ec921ef0628e
Revert manifest parser changes - no single string and back to HashMap Pool
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
266
diff
changeset
|
361 return result.equals(o.result); |
ec921ef0628e
Revert manifest parser changes - no single string and back to HashMap Pool
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
266
diff
changeset
|
362 } |
268
c5980f287cc4
Use StringProxy when parsing manifest to minimize number of useless conversions and array instances
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
267
diff
changeset
|
363 if (o.length != length || o.hash != hash) { |
267
ec921ef0628e
Revert manifest parser changes - no single string and back to HashMap Pool
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
266
diff
changeset
|
364 return false; |
ec921ef0628e
Revert manifest parser changes - no single string and back to HashMap Pool
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
266
diff
changeset
|
365 } |
ec921ef0628e
Revert manifest parser changes - no single string and back to HashMap Pool
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
266
diff
changeset
|
366 for (int i = 0, x = o.start, y = start; i < length; i++) { |
ec921ef0628e
Revert manifest parser changes - no single string and back to HashMap Pool
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
266
diff
changeset
|
367 if (o.data[x++] != data[y++]) { |
ec921ef0628e
Revert manifest parser changes - no single string and back to HashMap Pool
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
266
diff
changeset
|
368 return false; |
ec921ef0628e
Revert manifest parser changes - no single string and back to HashMap Pool
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
266
diff
changeset
|
369 } |
ec921ef0628e
Revert manifest parser changes - no single string and back to HashMap Pool
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
266
diff
changeset
|
370 } |
ec921ef0628e
Revert manifest parser changes - no single string and back to HashMap Pool
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
266
diff
changeset
|
371 return true; |
ec921ef0628e
Revert manifest parser changes - no single string and back to HashMap Pool
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
266
diff
changeset
|
372 } |
ec921ef0628e
Revert manifest parser changes - no single string and back to HashMap Pool
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
266
diff
changeset
|
373 @Override |
ec921ef0628e
Revert manifest parser changes - no single string and back to HashMap Pool
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
266
diff
changeset
|
374 public int hashCode() { |
ec921ef0628e
Revert manifest parser changes - no single string and back to HashMap Pool
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
266
diff
changeset
|
375 return hash; |
ec921ef0628e
Revert manifest parser changes - no single string and back to HashMap Pool
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
266
diff
changeset
|
376 } |
ec921ef0628e
Revert manifest parser changes - no single string and back to HashMap Pool
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
266
diff
changeset
|
377 |
285
6dbbc53fc46d
Use Path instead of plain String for manifest file names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
268
diff
changeset
|
378 public Path freeze() { |
267
ec921ef0628e
Revert manifest parser changes - no single string and back to HashMap Pool
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
266
diff
changeset
|
379 if (result == null) { |
412
63c5a9d7ca3f
Follow-up for Issue 29: unify path translation for manifest and dirstate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
390
diff
changeset
|
380 result = Path.create(encHelper.fromManifest(data, start, length)); |
268
c5980f287cc4
Use StringProxy when parsing manifest to minimize number of useless conversions and array instances
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
267
diff
changeset
|
381 // release reference to bigger data array, make a copy of relevant part only |
285
6dbbc53fc46d
Use Path instead of plain String for manifest file names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
268
diff
changeset
|
382 // use original bytes, not those from String above to avoid cache misses due to different encodings |
268
c5980f287cc4
Use StringProxy when parsing manifest to minimize number of useless conversions and array instances
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
267
diff
changeset
|
383 byte[] d = new byte[length]; |
c5980f287cc4
Use StringProxy when parsing manifest to minimize number of useless conversions and array instances
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
267
diff
changeset
|
384 System.arraycopy(data, start, d, 0, length); |
c5980f287cc4
Use StringProxy when parsing manifest to minimize number of useless conversions and array instances
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
267
diff
changeset
|
385 data = d; |
c5980f287cc4
Use StringProxy when parsing manifest to minimize number of useless conversions and array instances
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
267
diff
changeset
|
386 start = 0; |
267
ec921ef0628e
Revert manifest parser changes - no single string and back to HashMap Pool
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
266
diff
changeset
|
387 } |
ec921ef0628e
Revert manifest parser changes - no single string and back to HashMap Pool
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
266
diff
changeset
|
388 return result; |
ec921ef0628e
Revert manifest parser changes - no single string and back to HashMap Pool
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
266
diff
changeset
|
389 } |
ec921ef0628e
Revert manifest parser changes - no single string and back to HashMap Pool
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
266
diff
changeset
|
390 } |
196
e2115da4cf6a
Pool objects to avoid memory polution with duplicates
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
157
diff
changeset
|
391 |
312
f9f3e9b67ccc
Facilitate cancellation and progress reporting in changelog and manifest iterations
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
304
diff
changeset
|
392 private static class ManifestParser implements RevlogStream.Inspector, Lifecycle { |
196
e2115da4cf6a
Pool objects to avoid memory polution with duplicates
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
157
diff
changeset
|
393 private final Inspector inspector; |
285
6dbbc53fc46d
Use Path instead of plain String for manifest file names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
268
diff
changeset
|
394 private final Inspector2 inspector2; |
304
85b8efde5586
Use memory-friendly set implementation to canonicalize filenames and nodeids
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
300
diff
changeset
|
395 private Pool2<Nodeid> nodeidPool, thisRevPool; |
85b8efde5586
Use memory-friendly set implementation to canonicalize filenames and nodeids
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
300
diff
changeset
|
396 private final Pool2<PathProxy> fnamePool; |
266
0a2f445de774
Improve manifest parsing: reduce number of arrays instantiated for Nodeid
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
264
diff
changeset
|
397 private byte[] nodeidLookupBuffer = new byte[20]; // get reassigned each time new Nodeid is added to pool |
312
f9f3e9b67ccc
Facilitate cancellation and progress reporting in changelog and manifest iterations
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
304
diff
changeset
|
398 private final ProgressSupport progressHelper; |
f9f3e9b67ccc
Facilitate cancellation and progress reporting in changelog and manifest iterations
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
304
diff
changeset
|
399 private IterateControlMediator iterateControl; |
412
63c5a9d7ca3f
Follow-up for Issue 29: unify path translation for manifest and dirstate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
390
diff
changeset
|
400 private final EncodingHelper encHelper; |
262
3dcd3dd90c77
Improve manifest parsing: decode bytes to chars once, minimize arraycopy on String instantiation, keep set of file revisions from previous manifest only
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
257
diff
changeset
|
401 |
412
63c5a9d7ca3f
Follow-up for Issue 29: unify path translation for manifest and dirstate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
390
diff
changeset
|
402 public ManifestParser(Inspector delegate, EncodingHelper eh) { |
196
e2115da4cf6a
Pool objects to avoid memory polution with duplicates
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
157
diff
changeset
|
403 assert delegate != null; |
e2115da4cf6a
Pool objects to avoid memory polution with duplicates
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
157
diff
changeset
|
404 inspector = delegate; |
285
6dbbc53fc46d
Use Path instead of plain String for manifest file names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
268
diff
changeset
|
405 inspector2 = delegate instanceof Inspector2 ? (Inspector2) delegate : null; |
412
63c5a9d7ca3f
Follow-up for Issue 29: unify path translation for manifest and dirstate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
390
diff
changeset
|
406 encHelper = eh; |
304
85b8efde5586
Use memory-friendly set implementation to canonicalize filenames and nodeids
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
300
diff
changeset
|
407 nodeidPool = new Pool2<Nodeid>(); |
85b8efde5586
Use memory-friendly set implementation to canonicalize filenames and nodeids
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
300
diff
changeset
|
408 fnamePool = new Pool2<PathProxy>(); |
85b8efde5586
Use memory-friendly set implementation to canonicalize filenames and nodeids
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
300
diff
changeset
|
409 thisRevPool = new Pool2<Nodeid>(); |
312
f9f3e9b67ccc
Facilitate cancellation and progress reporting in changelog and manifest iterations
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
304
diff
changeset
|
410 progressHelper = ProgressSupport.Factory.get(delegate); |
196
e2115da4cf6a
Pool objects to avoid memory polution with duplicates
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
157
diff
changeset
|
411 } |
268
c5980f287cc4
Use StringProxy when parsing manifest to minimize number of useless conversions and array instances
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
267
diff
changeset
|
412 |
366
189dc6dc1c3e
Use exceptions to expose errors reading mercurial data
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
354
diff
changeset
|
413 public void next(int revisionNumber, int actualLen, int baseRevision, int linkRevision, int parent1Revision, int parent2Revision, byte[] nodeid, DataAccess da) throws HgException { |
196
e2115da4cf6a
Pool objects to avoid memory polution with duplicates
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
157
diff
changeset
|
414 try { |
312
f9f3e9b67ccc
Facilitate cancellation and progress reporting in changelog and manifest iterations
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
304
diff
changeset
|
415 if (!inspector.begin(revisionNumber, new Nodeid(nodeid, true), linkRevision)) { |
f9f3e9b67ccc
Facilitate cancellation and progress reporting in changelog and manifest iterations
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
304
diff
changeset
|
416 iterateControl.stop(); |
f9f3e9b67ccc
Facilitate cancellation and progress reporting in changelog and manifest iterations
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
304
diff
changeset
|
417 return; |
f9f3e9b67ccc
Facilitate cancellation and progress reporting in changelog and manifest iterations
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
304
diff
changeset
|
418 } |
372
155c1893bda4
Issue 22: UnsupportedOperationException on empty manifest entry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
368
diff
changeset
|
419 if (!da.isEmpty()) { |
155c1893bda4
Issue 22: UnsupportedOperationException on empty manifest entry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
368
diff
changeset
|
420 // although unlikely, manifest entry may be empty, when all files have been deleted from the repository |
155c1893bda4
Issue 22: UnsupportedOperationException on empty manifest entry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
368
diff
changeset
|
421 Path fname = null; |
155c1893bda4
Issue 22: UnsupportedOperationException on empty manifest entry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
368
diff
changeset
|
422 Flags flags = null; |
155c1893bda4
Issue 22: UnsupportedOperationException on empty manifest entry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
368
diff
changeset
|
423 Nodeid nid = null; |
155c1893bda4
Issue 22: UnsupportedOperationException on empty manifest entry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
368
diff
changeset
|
424 int i; |
155c1893bda4
Issue 22: UnsupportedOperationException on empty manifest entry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
368
diff
changeset
|
425 byte[] data = da.byteArray(); |
155c1893bda4
Issue 22: UnsupportedOperationException on empty manifest entry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
368
diff
changeset
|
426 for (i = 0; i < actualLen; i++) { |
155c1893bda4
Issue 22: UnsupportedOperationException on empty manifest entry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
368
diff
changeset
|
427 int x = i; |
155c1893bda4
Issue 22: UnsupportedOperationException on empty manifest entry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
368
diff
changeset
|
428 for( ; data[i] != '\n' && i < actualLen; i++) { |
155c1893bda4
Issue 22: UnsupportedOperationException on empty manifest entry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
368
diff
changeset
|
429 if (fname == null && data[i] == 0) { |
412
63c5a9d7ca3f
Follow-up for Issue 29: unify path translation for manifest and dirstate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
390
diff
changeset
|
430 PathProxy px = fnamePool.unify(new PathProxy(data, x, i - x, encHelper)); |
372
155c1893bda4
Issue 22: UnsupportedOperationException on empty manifest entry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
368
diff
changeset
|
431 // if (cached = fnamePool.unify(px))== px then cacheMiss, else cacheHit |
155c1893bda4
Issue 22: UnsupportedOperationException on empty manifest entry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
368
diff
changeset
|
432 // cpython 0..10k: hits: 15 989 152, misses: 3020 |
155c1893bda4
Issue 22: UnsupportedOperationException on empty manifest entry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
368
diff
changeset
|
433 fname = px.freeze(); |
155c1893bda4
Issue 22: UnsupportedOperationException on empty manifest entry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
368
diff
changeset
|
434 x = i+1; |
155c1893bda4
Issue 22: UnsupportedOperationException on empty manifest entry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
368
diff
changeset
|
435 } |
196
e2115da4cf6a
Pool objects to avoid memory polution with duplicates
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
157
diff
changeset
|
436 } |
372
155c1893bda4
Issue 22: UnsupportedOperationException on empty manifest entry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
368
diff
changeset
|
437 if (i < actualLen) { |
155c1893bda4
Issue 22: UnsupportedOperationException on empty manifest entry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
368
diff
changeset
|
438 assert data[i] == '\n'; |
155c1893bda4
Issue 22: UnsupportedOperationException on empty manifest entry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
368
diff
changeset
|
439 int nodeidLen = i - x < 40 ? i-x : 40; // if > 40, there are flags |
155c1893bda4
Issue 22: UnsupportedOperationException on empty manifest entry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
368
diff
changeset
|
440 DigestHelper.ascii2bin(data, x, nodeidLen, nodeidLookupBuffer); // ignore return value as it's unlikely to have NULL in manifest |
155c1893bda4
Issue 22: UnsupportedOperationException on empty manifest entry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
368
diff
changeset
|
441 nid = new Nodeid(nodeidLookupBuffer, false); // this Nodeid is for pool lookup only, mock object |
155c1893bda4
Issue 22: UnsupportedOperationException on empty manifest entry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
368
diff
changeset
|
442 Nodeid cached = nodeidPool.unify(nid); |
155c1893bda4
Issue 22: UnsupportedOperationException on empty manifest entry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
368
diff
changeset
|
443 if (cached == nid) { |
155c1893bda4
Issue 22: UnsupportedOperationException on empty manifest entry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
368
diff
changeset
|
444 // buffer now belongs to the cached nodeid |
155c1893bda4
Issue 22: UnsupportedOperationException on empty manifest entry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
368
diff
changeset
|
445 nodeidLookupBuffer = new byte[20]; |
155c1893bda4
Issue 22: UnsupportedOperationException on empty manifest entry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
368
diff
changeset
|
446 } else { |
155c1893bda4
Issue 22: UnsupportedOperationException on empty manifest entry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
368
diff
changeset
|
447 nid = cached; // use existing version, discard the lookup object |
155c1893bda4
Issue 22: UnsupportedOperationException on empty manifest entry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
368
diff
changeset
|
448 } // for cpython 0..10k, cache hits are 15 973 301, vs 18871 misses. |
155c1893bda4
Issue 22: UnsupportedOperationException on empty manifest entry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
368
diff
changeset
|
449 thisRevPool.record(nid); // memorize revision for the next iteration. |
155c1893bda4
Issue 22: UnsupportedOperationException on empty manifest entry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
368
diff
changeset
|
450 if (nodeidLen + x < i) { |
155c1893bda4
Issue 22: UnsupportedOperationException on empty manifest entry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
368
diff
changeset
|
451 // 'x' and 'l' for executable bits and symlinks? |
155c1893bda4
Issue 22: UnsupportedOperationException on empty manifest entry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
368
diff
changeset
|
452 // hg --debug manifest shows 644 for each regular file in my repo |
155c1893bda4
Issue 22: UnsupportedOperationException on empty manifest entry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
368
diff
changeset
|
453 // for cpython 0..10k, there are 4361062 flag checks, and there's only 1 unique flag |
155c1893bda4
Issue 22: UnsupportedOperationException on empty manifest entry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
368
diff
changeset
|
454 flags = Flags.parse(data, x + nodeidLen, i-x-nodeidLen); |
155c1893bda4
Issue 22: UnsupportedOperationException on empty manifest entry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
368
diff
changeset
|
455 } else { |
155c1893bda4
Issue 22: UnsupportedOperationException on empty manifest entry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
368
diff
changeset
|
456 flags = null; |
155c1893bda4
Issue 22: UnsupportedOperationException on empty manifest entry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
368
diff
changeset
|
457 } |
155c1893bda4
Issue 22: UnsupportedOperationException on empty manifest entry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
368
diff
changeset
|
458 boolean good2go; |
155c1893bda4
Issue 22: UnsupportedOperationException on empty manifest entry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
368
diff
changeset
|
459 if (inspector2 == null) { |
155c1893bda4
Issue 22: UnsupportedOperationException on empty manifest entry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
368
diff
changeset
|
460 String flagString = flags == null ? null : flags.nativeString(); |
155c1893bda4
Issue 22: UnsupportedOperationException on empty manifest entry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
368
diff
changeset
|
461 good2go = inspector.next(nid, fname.toString(), flagString); |
155c1893bda4
Issue 22: UnsupportedOperationException on empty manifest entry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
368
diff
changeset
|
462 } else { |
155c1893bda4
Issue 22: UnsupportedOperationException on empty manifest entry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
368
diff
changeset
|
463 good2go = inspector2.next(nid, fname, flags); |
155c1893bda4
Issue 22: UnsupportedOperationException on empty manifest entry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
368
diff
changeset
|
464 } |
155c1893bda4
Issue 22: UnsupportedOperationException on empty manifest entry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
368
diff
changeset
|
465 if (!good2go) { |
155c1893bda4
Issue 22: UnsupportedOperationException on empty manifest entry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
368
diff
changeset
|
466 iterateControl.stop(); |
155c1893bda4
Issue 22: UnsupportedOperationException on empty manifest entry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
368
diff
changeset
|
467 return; |
155c1893bda4
Issue 22: UnsupportedOperationException on empty manifest entry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
368
diff
changeset
|
468 } |
155c1893bda4
Issue 22: UnsupportedOperationException on empty manifest entry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
368
diff
changeset
|
469 } |
155c1893bda4
Issue 22: UnsupportedOperationException on empty manifest entry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
368
diff
changeset
|
470 nid = null; |
155c1893bda4
Issue 22: UnsupportedOperationException on empty manifest entry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
368
diff
changeset
|
471 fname = null; |
155c1893bda4
Issue 22: UnsupportedOperationException on empty manifest entry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
368
diff
changeset
|
472 flags = null; |
196
e2115da4cf6a
Pool objects to avoid memory polution with duplicates
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
157
diff
changeset
|
473 } |
e2115da4cf6a
Pool objects to avoid memory polution with duplicates
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
157
diff
changeset
|
474 } |
312
f9f3e9b67ccc
Facilitate cancellation and progress reporting in changelog and manifest iterations
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
304
diff
changeset
|
475 if (!inspector.end(revisionNumber)) { |
f9f3e9b67ccc
Facilitate cancellation and progress reporting in changelog and manifest iterations
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
304
diff
changeset
|
476 iterateControl.stop(); |
f9f3e9b67ccc
Facilitate cancellation and progress reporting in changelog and manifest iterations
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
304
diff
changeset
|
477 return; |
f9f3e9b67ccc
Facilitate cancellation and progress reporting in changelog and manifest iterations
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
304
diff
changeset
|
478 } |
262
3dcd3dd90c77
Improve manifest parsing: decode bytes to chars once, minimize arraycopy on String instantiation, keep set of file revisions from previous manifest only
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
257
diff
changeset
|
479 // |
3dcd3dd90c77
Improve manifest parsing: decode bytes to chars once, minimize arraycopy on String instantiation, keep set of file revisions from previous manifest only
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
257
diff
changeset
|
480 // keep only actual file revisions, found at this version |
3dcd3dd90c77
Improve manifest parsing: decode bytes to chars once, minimize arraycopy on String instantiation, keep set of file revisions from previous manifest only
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
257
diff
changeset
|
481 // (next manifest is likely to refer to most of them, although in specific cases |
3dcd3dd90c77
Improve manifest parsing: decode bytes to chars once, minimize arraycopy on String instantiation, keep set of file revisions from previous manifest only
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
257
diff
changeset
|
482 // like commit in another branch a lot may be useless) |
3dcd3dd90c77
Improve manifest parsing: decode bytes to chars once, minimize arraycopy on String instantiation, keep set of file revisions from previous manifest only
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
257
diff
changeset
|
483 nodeidPool.clear(); |
304
85b8efde5586
Use memory-friendly set implementation to canonicalize filenames and nodeids
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
300
diff
changeset
|
484 Pool2<Nodeid> t = nodeidPool; |
262
3dcd3dd90c77
Improve manifest parsing: decode bytes to chars once, minimize arraycopy on String instantiation, keep set of file revisions from previous manifest only
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
257
diff
changeset
|
485 nodeidPool = thisRevPool; |
264
6bb5e7ed051a
Optimize memory usage (reduce number of objects instantiated) when pooling file names and nodeids during manifest parsing
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
262
diff
changeset
|
486 thisRevPool = t; |
313
c1e3c18fd2f2
Test manifest cancellation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
312
diff
changeset
|
487 iterateControl.checkCancelled(); |
312
f9f3e9b67ccc
Facilitate cancellation and progress reporting in changelog and manifest iterations
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
304
diff
changeset
|
488 progressHelper.worked(1); |
196
e2115da4cf6a
Pool objects to avoid memory polution with duplicates
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
157
diff
changeset
|
489 } catch (IOException ex) { |
366
189dc6dc1c3e
Use exceptions to expose errors reading mercurial data
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
354
diff
changeset
|
490 throw new HgException(ex); |
196
e2115da4cf6a
Pool objects to avoid memory polution with duplicates
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
157
diff
changeset
|
491 } |
e2115da4cf6a
Pool objects to avoid memory polution with duplicates
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
157
diff
changeset
|
492 } |
312
f9f3e9b67ccc
Facilitate cancellation and progress reporting in changelog and manifest iterations
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
304
diff
changeset
|
493 |
f9f3e9b67ccc
Facilitate cancellation and progress reporting in changelog and manifest iterations
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
304
diff
changeset
|
494 public void start(int count, Callback callback, Object token) { |
f9f3e9b67ccc
Facilitate cancellation and progress reporting in changelog and manifest iterations
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
304
diff
changeset
|
495 CancelSupport cs = CancelSupport.Factory.get(inspector, null); |
f9f3e9b67ccc
Facilitate cancellation and progress reporting in changelog and manifest iterations
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
304
diff
changeset
|
496 iterateControl = new IterateControlMediator(cs, callback); |
f9f3e9b67ccc
Facilitate cancellation and progress reporting in changelog and manifest iterations
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
304
diff
changeset
|
497 progressHelper.start(count); |
f9f3e9b67ccc
Facilitate cancellation and progress reporting in changelog and manifest iterations
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
304
diff
changeset
|
498 } |
f9f3e9b67ccc
Facilitate cancellation and progress reporting in changelog and manifest iterations
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
304
diff
changeset
|
499 |
f9f3e9b67ccc
Facilitate cancellation and progress reporting in changelog and manifest iterations
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
304
diff
changeset
|
500 public void finish(Object token) { |
f9f3e9b67ccc
Facilitate cancellation and progress reporting in changelog and manifest iterations
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
304
diff
changeset
|
501 progressHelper.done(); |
f9f3e9b67ccc
Facilitate cancellation and progress reporting in changelog and manifest iterations
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
304
diff
changeset
|
502 } |
196
e2115da4cf6a
Pool objects to avoid memory polution with duplicates
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
157
diff
changeset
|
503 } |
218
047b1dec7a04
Issue 7: Correctly handle manifest and changelog with different number of (or non-matching) revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
196
diff
changeset
|
504 |
047b1dec7a04
Issue 7: Correctly handle manifest and changelog with different number of (or non-matching) revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
196
diff
changeset
|
505 private static class RevisionMapper implements RevlogStream.Inspector, Lifecycle { |
047b1dec7a04
Issue 7: Correctly handle manifest and changelog with different number of (or non-matching) revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
196
diff
changeset
|
506 |
047b1dec7a04
Issue 7: Correctly handle manifest and changelog with different number of (or non-matching) revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
196
diff
changeset
|
507 private final int changelogRevisions; |
047b1dec7a04
Issue 7: Correctly handle manifest and changelog with different number of (or non-matching) revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
196
diff
changeset
|
508 private int[] changelog2manifest; |
047b1dec7a04
Issue 7: Correctly handle manifest and changelog with different number of (or non-matching) revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
196
diff
changeset
|
509 private final HgRepository repo; |
047b1dec7a04
Issue 7: Correctly handle manifest and changelog with different number of (or non-matching) revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
196
diff
changeset
|
510 |
047b1dec7a04
Issue 7: Correctly handle manifest and changelog with different number of (or non-matching) revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
196
diff
changeset
|
511 public RevisionMapper(HgRepository hgRepo) { |
047b1dec7a04
Issue 7: Correctly handle manifest and changelog with different number of (or non-matching) revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
196
diff
changeset
|
512 repo = hgRepo; |
047b1dec7a04
Issue 7: Correctly handle manifest and changelog with different number of (or non-matching) revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
196
diff
changeset
|
513 changelogRevisions = repo.getChangelog().getRevisionCount(); |
047b1dec7a04
Issue 7: Correctly handle manifest and changelog with different number of (or non-matching) revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
196
diff
changeset
|
514 } |
047b1dec7a04
Issue 7: Correctly handle manifest and changelog with different number of (or non-matching) revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
196
diff
changeset
|
515 |
257
f39fb6b3cc76
Handle revision constants correctly
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
254
diff
changeset
|
516 // respects TIP |
218
047b1dec7a04
Issue 7: Correctly handle manifest and changelog with different number of (or non-matching) revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
196
diff
changeset
|
517 public int at(int revisionNumber) { |
257
f39fb6b3cc76
Handle revision constants correctly
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
254
diff
changeset
|
518 if (revisionNumber == TIP) { |
f39fb6b3cc76
Handle revision constants correctly
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
254
diff
changeset
|
519 revisionNumber = changelogRevisions - 1; |
f39fb6b3cc76
Handle revision constants correctly
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
254
diff
changeset
|
520 } |
218
047b1dec7a04
Issue 7: Correctly handle manifest and changelog with different number of (or non-matching) revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
196
diff
changeset
|
521 if (changelog2manifest != null) { |
047b1dec7a04
Issue 7: Correctly handle manifest and changelog with different number of (or non-matching) revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
196
diff
changeset
|
522 return changelog2manifest[revisionNumber]; |
047b1dec7a04
Issue 7: Correctly handle manifest and changelog with different number of (or non-matching) revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
196
diff
changeset
|
523 } |
047b1dec7a04
Issue 7: Correctly handle manifest and changelog with different number of (or non-matching) revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
196
diff
changeset
|
524 return revisionNumber; |
047b1dec7a04
Issue 7: Correctly handle manifest and changelog with different number of (or non-matching) revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
196
diff
changeset
|
525 } |
047b1dec7a04
Issue 7: Correctly handle manifest and changelog with different number of (or non-matching) revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
196
diff
changeset
|
526 |
324
283b294d1079
Explore alternatives to access file-changelog combined history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
321
diff
changeset
|
527 // XXX likely can be replaced with Revlog.RevisionInspector |
218
047b1dec7a04
Issue 7: Correctly handle manifest and changelog with different number of (or non-matching) revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
196
diff
changeset
|
528 public void next(int revisionNumber, int actualLen, int baseRevision, int linkRevision, int parent1Revision, int parent2Revision, byte[] nodeid, DataAccess data) { |
047b1dec7a04
Issue 7: Correctly handle manifest and changelog with different number of (or non-matching) revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
196
diff
changeset
|
529 if (changelog2manifest != null) { |
220
8de327242aa0
Basic information about branches
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
218
diff
changeset
|
530 // next assertion is not an error, rather assumption check, which is too development-related to be explicit exception - |
8de327242aa0
Basic information about branches
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
218
diff
changeset
|
531 // I just wonder if there are manifests that have two entries pointing to single changeset. It seems unrealistic, though - |
8de327242aa0
Basic information about branches
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
218
diff
changeset
|
532 // changeset records one and only one manifest nodeid |
8de327242aa0
Basic information about branches
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
218
diff
changeset
|
533 assert changelog2manifest[linkRevision] == -1 : String.format("revision:%d, link:%d, already linked to revision:%d", revisionNumber, linkRevision, changelog2manifest[linkRevision]); |
218
047b1dec7a04
Issue 7: Correctly handle manifest and changelog with different number of (or non-matching) revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
196
diff
changeset
|
534 changelog2manifest[linkRevision] = revisionNumber; |
047b1dec7a04
Issue 7: Correctly handle manifest and changelog with different number of (or non-matching) revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
196
diff
changeset
|
535 } else { |
047b1dec7a04
Issue 7: Correctly handle manifest and changelog with different number of (or non-matching) revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
196
diff
changeset
|
536 if (revisionNumber != linkRevision) { |
047b1dec7a04
Issue 7: Correctly handle manifest and changelog with different number of (or non-matching) revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
196
diff
changeset
|
537 changelog2manifest = new int[changelogRevisions]; |
047b1dec7a04
Issue 7: Correctly handle manifest and changelog with different number of (or non-matching) revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
196
diff
changeset
|
538 Arrays.fill(changelog2manifest, -1); |
047b1dec7a04
Issue 7: Correctly handle manifest and changelog with different number of (or non-matching) revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
196
diff
changeset
|
539 for (int i = 0; i < revisionNumber; changelog2manifest[i] = i, i++) |
047b1dec7a04
Issue 7: Correctly handle manifest and changelog with different number of (or non-matching) revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
196
diff
changeset
|
540 ; |
047b1dec7a04
Issue 7: Correctly handle manifest and changelog with different number of (or non-matching) revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
196
diff
changeset
|
541 changelog2manifest[linkRevision] = revisionNumber; |
047b1dec7a04
Issue 7: Correctly handle manifest and changelog with different number of (or non-matching) revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
196
diff
changeset
|
542 } |
047b1dec7a04
Issue 7: Correctly handle manifest and changelog with different number of (or non-matching) revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
196
diff
changeset
|
543 } |
047b1dec7a04
Issue 7: Correctly handle manifest and changelog with different number of (or non-matching) revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
196
diff
changeset
|
544 } |
047b1dec7a04
Issue 7: Correctly handle manifest and changelog with different number of (or non-matching) revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
196
diff
changeset
|
545 |
047b1dec7a04
Issue 7: Correctly handle manifest and changelog with different number of (or non-matching) revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
196
diff
changeset
|
546 public void start(int count, Callback callback, Object token) { |
047b1dec7a04
Issue 7: Correctly handle manifest and changelog with different number of (or non-matching) revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
196
diff
changeset
|
547 if (count != changelogRevisions) { |
047b1dec7a04
Issue 7: Correctly handle manifest and changelog with different number of (or non-matching) revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
196
diff
changeset
|
548 assert count < changelogRevisions; // no idea what to do if manifest has more revisions than changelog |
047b1dec7a04
Issue 7: Correctly handle manifest and changelog with different number of (or non-matching) revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
196
diff
changeset
|
549 // the way how manifest may contain more revisions than changelog, as I can imagine, is a result of |
047b1dec7a04
Issue 7: Correctly handle manifest and changelog with different number of (or non-matching) revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
196
diff
changeset
|
550 // some kind of an import tool (e.g. from SVN or CVS), that creates manifest and changelog independently. |
047b1dec7a04
Issue 7: Correctly handle manifest and changelog with different number of (or non-matching) revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
196
diff
changeset
|
551 // Note, it's pure guess, I didn't see such repository yet (although the way manifest revisions |
047b1dec7a04
Issue 7: Correctly handle manifest and changelog with different number of (or non-matching) revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
196
diff
changeset
|
552 // in cpython repo are numbered makes me think aforementioned way) |
047b1dec7a04
Issue 7: Correctly handle manifest and changelog with different number of (or non-matching) revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
196
diff
changeset
|
553 changelog2manifest = new int[changelogRevisions]; |
047b1dec7a04
Issue 7: Correctly handle manifest and changelog with different number of (or non-matching) revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
196
diff
changeset
|
554 Arrays.fill(changelog2manifest, -1); |
047b1dec7a04
Issue 7: Correctly handle manifest and changelog with different number of (or non-matching) revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
196
diff
changeset
|
555 } |
047b1dec7a04
Issue 7: Correctly handle manifest and changelog with different number of (or non-matching) revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
196
diff
changeset
|
556 } |
047b1dec7a04
Issue 7: Correctly handle manifest and changelog with different number of (or non-matching) revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
196
diff
changeset
|
557 |
047b1dec7a04
Issue 7: Correctly handle manifest and changelog with different number of (or non-matching) revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
196
diff
changeset
|
558 public void finish(Object token) { |
047b1dec7a04
Issue 7: Correctly handle manifest and changelog with different number of (or non-matching) revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
196
diff
changeset
|
559 if (changelog2manifest == null) { |
047b1dec7a04
Issue 7: Correctly handle manifest and changelog with different number of (or non-matching) revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
196
diff
changeset
|
560 return; |
047b1dec7a04
Issue 7: Correctly handle manifest and changelog with different number of (or non-matching) revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
196
diff
changeset
|
561 } |
047b1dec7a04
Issue 7: Correctly handle manifest and changelog with different number of (or non-matching) revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
196
diff
changeset
|
562 // I assume there'd be not too many revisions we don't know manifest of |
047b1dec7a04
Issue 7: Correctly handle manifest and changelog with different number of (or non-matching) revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
196
diff
changeset
|
563 ArrayList<Integer> undefinedChangelogRevision = new ArrayList<Integer>(); |
047b1dec7a04
Issue 7: Correctly handle manifest and changelog with different number of (or non-matching) revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
196
diff
changeset
|
564 for (int i = 0; i < changelog2manifest.length; i++) { |
047b1dec7a04
Issue 7: Correctly handle manifest and changelog with different number of (or non-matching) revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
196
diff
changeset
|
565 if (changelog2manifest[i] == -1) { |
047b1dec7a04
Issue 7: Correctly handle manifest and changelog with different number of (or non-matching) revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
196
diff
changeset
|
566 undefinedChangelogRevision.add(i); |
047b1dec7a04
Issue 7: Correctly handle manifest and changelog with different number of (or non-matching) revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
196
diff
changeset
|
567 } |
047b1dec7a04
Issue 7: Correctly handle manifest and changelog with different number of (or non-matching) revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
196
diff
changeset
|
568 } |
047b1dec7a04
Issue 7: Correctly handle manifest and changelog with different number of (or non-matching) revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
196
diff
changeset
|
569 for (int u : undefinedChangelogRevision) { |
354
5f9073eabf06
Propagate errors with exceptions up to a end client
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
326
diff
changeset
|
570 try { |
366
189dc6dc1c3e
Use exceptions to expose errors reading mercurial data
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
354
diff
changeset
|
571 Nodeid manifest = repo.getChangelog().range(u, u).get(0).manifest(); |
390
6952d9ce97f1
Handle missing manifest revision case (brought up with Issue 23), do my best to report missing manifests when walking few manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
385
diff
changeset
|
572 // TODO calculate those missing effectively (e.g. cache and sort nodeids to speed lookup |
366
189dc6dc1c3e
Use exceptions to expose errors reading mercurial data
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
354
diff
changeset
|
573 // right away in the #next (may refactor ParentWalker's sequential and sorted into dedicated helper and reuse here) |
385
6150555eb41d
HgInvalidRevisionException for svn imported repositories (changeset 0 references nullid manifest)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
372
diff
changeset
|
574 if (manifest.isNull()) { |
6150555eb41d
HgInvalidRevisionException for svn imported repositories (changeset 0 references nullid manifest)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
372
diff
changeset
|
575 repo.getContext().getLog().warn(getClass(), "Changeset %d has no associated manifest entry", u); |
390
6952d9ce97f1
Handle missing manifest revision case (brought up with Issue 23), do my best to report missing manifests when walking few manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
385
diff
changeset
|
576 // keep -1 in the changelog2manifest map. |
385
6150555eb41d
HgInvalidRevisionException for svn imported repositories (changeset 0 references nullid manifest)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
372
diff
changeset
|
577 } else { |
6150555eb41d
HgInvalidRevisionException for svn imported repositories (changeset 0 references nullid manifest)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
372
diff
changeset
|
578 changelog2manifest[u] = repo.getManifest().getRevisionIndex(manifest); |
6150555eb41d
HgInvalidRevisionException for svn imported repositories (changeset 0 references nullid manifest)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
372
diff
changeset
|
579 } |
354
5f9073eabf06
Propagate errors with exceptions up to a end client
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
326
diff
changeset
|
580 } catch (HgInvalidControlFileException ex) { |
5f9073eabf06
Propagate errors with exceptions up to a end client
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
326
diff
changeset
|
581 // FIXME need to propagate the error up to client |
5f9073eabf06
Propagate errors with exceptions up to a end client
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
326
diff
changeset
|
582 repo.getContext().getLog().error(getClass(), ex, null); |
5f9073eabf06
Propagate errors with exceptions up to a end client
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
326
diff
changeset
|
583 } |
218
047b1dec7a04
Issue 7: Correctly handle manifest and changelog with different number of (or non-matching) revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
196
diff
changeset
|
584 } |
047b1dec7a04
Issue 7: Correctly handle manifest and changelog with different number of (or non-matching) revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
196
diff
changeset
|
585 } |
047b1dec7a04
Issue 7: Correctly handle manifest and changelog with different number of (or non-matching) revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
196
diff
changeset
|
586 } |
2
08db726a0fb7
Shaping out low-level Hg structures
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
587 } |