Mercurial > jhg
annotate src/org/tmatesoft/hg/repo/HgManifest.java @ 713:661e77dc88ba tip
Mac support: respect Mac alternatives of command-line arguments for common unix tools
| author | Artem Tikhomirov <tikhomirov.artem@gmail.com> | 
|---|---|
| date | Sun, 03 Aug 2014 18:09:00 +0200 | 
| parents | 42b88709e41d | 
| children | 
| 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 /* | 
| 
537
 
5a455624be4f
Update javadoc for HgManifest.Inspector and fix erroneous internal API
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
490 
diff
changeset
 | 
2 * Copyright (c) 2010-2013 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; | 
| 
423
 
9c9c442b5f2e
Major refactoring of exception handling. Low-level API uses RuntimeExceptions, while checked are left for higher level
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
421 
diff
changeset
 | 
20 import static org.tmatesoft.hg.repo.HgRepository.*; | 
| 
456
 
909306e412e2
Refactor LogFacility and SessionContext, better API for both
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
431 
diff
changeset
 | 
21 import static org.tmatesoft.hg.util.LogFacility.Severity.Info; | 
| 
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
 | 
22 | 
| 
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
 | 
23 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
 | 
24 import java.util.Arrays; | 
| 
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
 | 
25 | 
| 
417
 
ccd7d25e5aea
New and better name for HgFileInformer - HgChangesetFileSneaker. Explain (comments) ties between HgManifest, HgDataFile, HgChangesetFileSneaker and reasons for method placement
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
415 
diff
changeset
 | 
26 import org.tmatesoft.hg.core.HgChangesetFileSneaker; | 
| 
74
 
6f1b88693d48
Complete refactoring to org.tmatesoft
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
28 
diff
changeset
 | 
27 import org.tmatesoft.hg.core.Nodeid; | 
| 
574
 
88afffd39899
Improve memory consumption of HgManifest#getFileRevision(): avoid extra byte[] instances
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
571 
diff
changeset
 | 
28 import org.tmatesoft.hg.internal.ByteVector; | 
| 
423
 
9c9c442b5f2e
Major refactoring of exception handling. Low-level API uses RuntimeExceptions, while checked are left for higher level
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
421 
diff
changeset
 | 
29 import org.tmatesoft.hg.internal.Callback; | 
| 
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
 | 
30 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
 | 
31 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
 | 
32 import org.tmatesoft.hg.internal.EncodingHelper; | 
| 
574
 
88afffd39899
Improve memory consumption of HgManifest#getFileRevision(): avoid extra byte[] instances
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
571 
diff
changeset
 | 
33 import org.tmatesoft.hg.internal.IdentityPool; | 
| 
415
 
ee8264d80747
Explicit constant for regular file flags, access to flags for a given file revision
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
414 
diff
changeset
 | 
34 import org.tmatesoft.hg.internal.IntMap; | 
| 
597
 
c895b5556937
Wrap manifest revision map completion into single file access
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
583 
diff
changeset
 | 
35 import org.tmatesoft.hg.internal.IntVector; | 
| 
312
 
f9f3e9b67ccc
Facilitate cancellation and progress reporting in changelog and manifest iterations
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
304 
diff
changeset
 | 
36 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
 | 
37 import org.tmatesoft.hg.internal.Lifecycle; | 
| 
600
 
46f29b73e51e
Utilize RevisionLookup to speed-up getRevisionIndex of both manifest and changelog
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
598 
diff
changeset
 | 
38 import org.tmatesoft.hg.internal.RevisionLookup; | 
| 
77
 
c677e1593919
Moved RevlogStream implementation into .internal
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
74 
diff
changeset
 | 
39 import org.tmatesoft.hg.internal.RevlogStream; | 
| 
597
 
c895b5556937
Wrap manifest revision map completion into single file access
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
583 
diff
changeset
 | 
40 import org.tmatesoft.hg.repo.HgChangelog.RawChangeset; | 
| 
312
 
f9f3e9b67ccc
Facilitate cancellation and progress reporting in changelog and manifest iterations
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
304 
diff
changeset
 | 
41 import org.tmatesoft.hg.util.CancelSupport; | 
| 
574
 
88afffd39899
Improve memory consumption of HgManifest#getFileRevision(): avoid extra byte[] instances
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
571 
diff
changeset
 | 
42 import org.tmatesoft.hg.util.LogFacility.Severity; | 
| 
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 /** | 
| 
425
 
48f993aa2f41
FIXMEs: exceptions, javadoc
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
424 
diff
changeset
 | 
48 * Representation of Mercurial manifest file (list of file names and their revisions in a particular changeset) | 
| 
 
48f993aa2f41
FIXMEs: exceptions, javadoc
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
424 
diff
changeset
 | 
49 * | 
| 
 
48f993aa2f41
FIXMEs: exceptions, javadoc
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
424 
diff
changeset
 | 
50 * @see http://mercurial.selenic.com/wiki/Manifest | 
| 
74
 
6f1b88693d48
Complete refactoring to org.tmatesoft
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
28 
diff
changeset
 | 
51 * @author Artem Tikhomirov | 
| 
 
6f1b88693d48
Complete refactoring to org.tmatesoft
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
28 
diff
changeset
 | 
52 * @author TMate Software Ltd. | 
| 
2
 
08db726a0fb7
Shaping out low-level Hg structures
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
53 */ | 
| 
426
 
063b0663495a
HgManifest#getFileRevisions refactored into #walkFileRevisions to match pattern throught rest of the library
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
425 
diff
changeset
 | 
54 public final 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
 | 
55 private RevisionMapper revisionMap; | 
| 
574
 
88afffd39899
Improve memory consumption of HgManifest#getFileRevision(): avoid extra byte[] instances
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
571 
diff
changeset
 | 
56 private final EncodingHelper encodingHelper; | 
| 
 
88afffd39899
Improve memory consumption of HgManifest#getFileRevision(): avoid extra byte[] instances
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
571 
diff
changeset
 | 
57 private final Path.Source pathFactory; | 
| 
607
 
66f1cc23b906
Refresh revlogs if a change to a file has been detected; do not force reload of the whole repository
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
601 
diff
changeset
 | 
58 private final RevlogStream.Observer revisionMapCleaner = new RevlogStream.Observer() { | 
| 
 
66f1cc23b906
Refresh revlogs if a change to a file has been detected; do not force reload of the whole repository
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
601 
diff
changeset
 | 
59 public void reloaded(RevlogStream src) { | 
| 
 
66f1cc23b906
Refresh revlogs if a change to a file has been detected; do not force reload of the whole repository
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
601 
diff
changeset
 | 
60 revisionMap = null; | 
| 
 
66f1cc23b906
Refresh revlogs if a change to a file has been detected; do not force reload of the whole repository
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
601 
diff
changeset
 | 
61 // TODO RevlogDerivedCache<T> class, to wrap revisionMap and super.revisionLookup | 
| 
 
66f1cc23b906
Refresh revlogs if a change to a file has been detected; do not force reload of the whole repository
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
601 
diff
changeset
 | 
62 // and their respective cleanup observers, or any other all-in-one alternative | 
| 
 
66f1cc23b906
Refresh revlogs if a change to a file has been detected; do not force reload of the whole repository
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
601 
diff
changeset
 | 
63 // not to keep both field and it's cleaner | 
| 
 
66f1cc23b906
Refresh revlogs if a change to a file has been detected; do not force reload of the whole repository
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
601 
diff
changeset
 | 
64 } | 
| 
 
66f1cc23b906
Refresh revlogs if a change to a file has been detected; do not force reload of the whole repository
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
601 
diff
changeset
 | 
65 }; | 
| 
285
 
6dbbc53fc46d
Use Path instead of plain String for manifest file names
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
268 
diff
changeset
 | 
66 | 
| 
415
 
ee8264d80747
Explicit constant for regular file flags, access to flags for a given file revision
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
414 
diff
changeset
 | 
67 /** | 
| 
 
ee8264d80747
Explicit constant for regular file flags, access to flags for a given file revision
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
414 
diff
changeset
 | 
68 * File flags recorded in manifest | 
| 
 
ee8264d80747
Explicit constant for regular file flags, access to flags for a given file revision
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
414 
diff
changeset
 | 
69 */ | 
| 
285
 
6dbbc53fc46d
Use Path instead of plain String for manifest file names
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
268 
diff
changeset
 | 
70 public enum Flags { | 
| 
415
 
ee8264d80747
Explicit constant for regular file flags, access to flags for a given file revision
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
414 
diff
changeset
 | 
71 /** | 
| 
 
ee8264d80747
Explicit constant for regular file flags, access to flags for a given file revision
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
414 
diff
changeset
 | 
72 * Executable bit set | 
| 
 
ee8264d80747
Explicit constant for regular file flags, access to flags for a given file revision
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
414 
diff
changeset
 | 
73 */ | 
| 
 
ee8264d80747
Explicit constant for regular file flags, access to flags for a given file revision
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
414 
diff
changeset
 | 
74 Exec, | 
| 
 
ee8264d80747
Explicit constant for regular file flags, access to flags for a given file revision
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
414 
diff
changeset
 | 
75 /** | 
| 
 
ee8264d80747
Explicit constant for regular file flags, access to flags for a given file revision
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
414 
diff
changeset
 | 
76 * Symbolic link | 
| 
 
ee8264d80747
Explicit constant for regular file flags, access to flags for a given file revision
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
414 
diff
changeset
 | 
77 */ | 
| 
 
ee8264d80747
Explicit constant for regular file flags, access to flags for a given file revision
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
414 
diff
changeset
 | 
78 Link, | 
| 
 
ee8264d80747
Explicit constant for regular file flags, access to flags for a given file revision
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
414 
diff
changeset
 | 
79 /** | 
| 
 
ee8264d80747
Explicit constant for regular file flags, access to flags for a given file revision
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
414 
diff
changeset
 | 
80 * Regular file | 
| 
 
ee8264d80747
Explicit constant for regular file flags, access to flags for a given file revision
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
414 
diff
changeset
 | 
81 */ | 
| 
 
ee8264d80747
Explicit constant for regular file flags, access to flags for a given file revision
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
414 
diff
changeset
 | 
82 RegularFile; | 
| 
285
 
6dbbc53fc46d
Use Path instead of plain String for manifest file names
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
268 
diff
changeset
 | 
83 | 
| 
 
6dbbc53fc46d
Use Path instead of plain String for manifest file names
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
268 
diff
changeset
 | 
84 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
 | 
85 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
 | 
86 return Exec; | 
| 
 
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 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
 | 
89 return Link; | 
| 
 
6dbbc53fc46d
Use Path instead of plain String for manifest file names
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
268 
diff
changeset
 | 
90 } | 
| 
 
6dbbc53fc46d
Use Path instead of plain String for manifest file names
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
268 
diff
changeset
 | 
91 if (flags == null) { | 
| 
415
 
ee8264d80747
Explicit constant for regular file flags, access to flags for a given file revision
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
414 
diff
changeset
 | 
92 return RegularFile; | 
| 
285
 
6dbbc53fc46d
Use Path instead of plain String for manifest file names
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
268 
diff
changeset
 | 
93 } | 
| 
 
6dbbc53fc46d
Use Path instead of plain String for manifest file names
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
268 
diff
changeset
 | 
94 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
 | 
95 } | 
| 
 
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 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
 | 
98 if (length == 0) { | 
| 
415
 
ee8264d80747
Explicit constant for regular file flags, access to flags for a given file revision
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
414 
diff
changeset
 | 
99 return RegularFile; | 
| 
285
 
6dbbc53fc46d
Use Path instead of plain String for manifest file names
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
268 
diff
changeset
 | 
100 } | 
| 
 
6dbbc53fc46d
Use Path instead of plain String for manifest file names
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
268 
diff
changeset
 | 
101 if (length == 1) { | 
| 
 
6dbbc53fc46d
Use Path instead of plain String for manifest file names
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
268 
diff
changeset
 | 
102 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
 | 
103 return Exec; | 
| 
 
6dbbc53fc46d
Use Path instead of plain String for manifest file names
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
268 
diff
changeset
 | 
104 } | 
| 
 
6dbbc53fc46d
Use Path instead of plain String for manifest file names
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
268 
diff
changeset
 | 
105 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
 | 
106 return Link; | 
| 
 
6dbbc53fc46d
Use Path instead of plain String for manifest file names
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
268 
diff
changeset
 | 
107 } | 
| 
 
6dbbc53fc46d
Use Path instead of plain String for manifest file names
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
268 
diff
changeset
 | 
108 // FALL THROUGH | 
| 
 
6dbbc53fc46d
Use Path instead of plain String for manifest file names
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
268 
diff
changeset
 | 
109 } | 
| 
 
6dbbc53fc46d
Use Path instead of plain String for manifest file names
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
268 
diff
changeset
 | 
110 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
 | 
111 } | 
| 
608
 
e1b29756f901
Clean, organize and resolve some TODOs and FIXMEs: minor refactorings and comments
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
607 
diff
changeset
 | 
112 | 
| 
 
e1b29756f901
Clean, organize and resolve some TODOs and FIXMEs: minor refactorings and comments
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
607 
diff
changeset
 | 
113 static Flags parse(int dirstateFileMode) { | 
| 
 
e1b29756f901
Clean, organize and resolve some TODOs and FIXMEs: minor refactorings and comments
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
607 
diff
changeset
 | 
114 // source/include/linux/stat.h | 
| 
 
e1b29756f901
Clean, organize and resolve some TODOs and FIXMEs: minor refactorings and comments
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
607 
diff
changeset
 | 
115 final int S_IFLNK = 0120000, S_IXUSR = 00100; | 
| 
 
e1b29756f901
Clean, organize and resolve some TODOs and FIXMEs: minor refactorings and comments
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
607 
diff
changeset
 | 
116 if ((dirstateFileMode & S_IFLNK) == S_IFLNK) { | 
| 
 
e1b29756f901
Clean, organize and resolve some TODOs and FIXMEs: minor refactorings and comments
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
607 
diff
changeset
 | 
117 return Link; | 
| 
 
e1b29756f901
Clean, organize and resolve some TODOs and FIXMEs: minor refactorings and comments
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
607 
diff
changeset
 | 
118 } | 
| 
 
e1b29756f901
Clean, organize and resolve some TODOs and FIXMEs: minor refactorings and comments
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
607 
diff
changeset
 | 
119 if ((dirstateFileMode & S_IXUSR) == S_IXUSR) { | 
| 
 
e1b29756f901
Clean, organize and resolve some TODOs and FIXMEs: minor refactorings and comments
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
607 
diff
changeset
 | 
120 return Exec; | 
| 
 
e1b29756f901
Clean, organize and resolve some TODOs and FIXMEs: minor refactorings and comments
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
607 
diff
changeset
 | 
121 } | 
| 
 
e1b29756f901
Clean, organize and resolve some TODOs and FIXMEs: minor refactorings and comments
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
607 
diff
changeset
 | 
122 return RegularFile; | 
| 
 
e1b29756f901
Clean, organize and resolve some TODOs and FIXMEs: minor refactorings and comments
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
607 
diff
changeset
 | 
123 } | 
| 
 
e1b29756f901
Clean, organize and resolve some TODOs and FIXMEs: minor refactorings and comments
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
607 
diff
changeset
 | 
124 | 
| 
707
 
42b88709e41d
Merge: support 'unresolved' resolution with MergeStateBuilder
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
661 
diff
changeset
 | 
125 /** | 
| 
 
42b88709e41d
Merge: support 'unresolved' resolution with MergeStateBuilder
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
661 
diff
changeset
 | 
126 * String representation of the flag as of native Mercurial client. | 
| 
 
42b88709e41d
Merge: support 'unresolved' resolution with MergeStateBuilder
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
661 
diff
changeset
 | 
127 */ | 
| 
 
42b88709e41d
Merge: support 'unresolved' resolution with MergeStateBuilder
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
661 
diff
changeset
 | 
128 public String mercurialString() { | 
| 
285
 
6dbbc53fc46d
Use Path instead of plain String for manifest file names
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
268 
diff
changeset
 | 
129 if (this == Exec) { | 
| 
 
6dbbc53fc46d
Use Path instead of plain String for manifest file names
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
268 
diff
changeset
 | 
130 return "x"; | 
| 
 
6dbbc53fc46d
Use Path instead of plain String for manifest file names
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
268 
diff
changeset
 | 
131 } | 
| 
 
6dbbc53fc46d
Use Path instead of plain String for manifest file names
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
268 
diff
changeset
 | 
132 if (this == Link) { | 
| 
 
6dbbc53fc46d
Use Path instead of plain String for manifest file names
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
268 
diff
changeset
 | 
133 return "l"; | 
| 
 
6dbbc53fc46d
Use Path instead of plain String for manifest file names
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
268 
diff
changeset
 | 
134 } | 
| 
415
 
ee8264d80747
Explicit constant for regular file flags, access to flags for a given file revision
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
414 
diff
changeset
 | 
135 if (this == RegularFile) { | 
| 
 
ee8264d80747
Explicit constant for regular file flags, access to flags for a given file revision
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
414 
diff
changeset
 | 
136 return ""; | 
| 
 
ee8264d80747
Explicit constant for regular file flags, access to flags for a given file revision
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
414 
diff
changeset
 | 
137 } | 
| 
285
 
6dbbc53fc46d
Use Path instead of plain String for manifest file names
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
268 
diff
changeset
 | 
138 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
 | 
139 } | 
| 
574
 
88afffd39899
Improve memory consumption of HgManifest#getFileRevision(): avoid extra byte[] instances
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
571 
diff
changeset
 | 
140 | 
| 
 
88afffd39899
Improve memory consumption of HgManifest#getFileRevision(): avoid extra byte[] instances
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
571 
diff
changeset
 | 
141 public int fsMode() { | 
| 
 
88afffd39899
Improve memory consumption of HgManifest#getFileRevision(): avoid extra byte[] instances
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
571 
diff
changeset
 | 
142 if (this == Exec) { | 
| 
 
88afffd39899
Improve memory consumption of HgManifest#getFileRevision(): avoid extra byte[] instances
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
571 
diff
changeset
 | 
143 return 0755; | 
| 
 
88afffd39899
Improve memory consumption of HgManifest#getFileRevision(): avoid extra byte[] instances
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
571 
diff
changeset
 | 
144 } | 
| 
 
88afffd39899
Improve memory consumption of HgManifest#getFileRevision(): avoid extra byte[] instances
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
571 
diff
changeset
 | 
145 return 0644; | 
| 
 
88afffd39899
Improve memory consumption of HgManifest#getFileRevision(): avoid extra byte[] instances
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
571 
diff
changeset
 | 
146 } | 
| 
285
 
6dbbc53fc46d
Use Path instead of plain String for manifest file names
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
268 
diff
changeset
 | 
147 } | 
| 
2
 
08db726a0fb7
Shaping out low-level Hg structures
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
148 | 
| 
412
 
63c5a9d7ca3f
Follow-up for Issue 29: unify path translation for manifest and dirstate
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
390 
diff
changeset
 | 
149 /*package-local*/ HgManifest(HgRepository hgRepo, RevlogStream content, EncodingHelper eh) { | 
| 
600
 
46f29b73e51e
Utilize RevisionLookup to speed-up getRevisionIndex of both manifest and changelog
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
598 
diff
changeset
 | 
150 super(hgRepo, content, true); | 
| 
412
 
63c5a9d7ca3f
Follow-up for Issue 29: unify path translation for manifest and dirstate
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
390 
diff
changeset
 | 
151 encodingHelper = eh; | 
| 
574
 
88afffd39899
Improve memory consumption of HgManifest#getFileRevision(): avoid extra byte[] instances
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
571 
diff
changeset
 | 
152 pathFactory = hgRepo.getSessionContext().getPathFactory(); | 
| 
13
 
df8c67f3006a
Basic manifest parsing to analyze what's in there
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
2 
diff
changeset
 | 
153 } | 
| 
 
df8c67f3006a
Basic manifest parsing to analyze what's in there
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
2 
diff
changeset
 | 
154 | 
| 
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
 | 
155 /** | 
| 
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
 | 
156 * 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
 | 
157 * 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
 | 
158 * 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
 | 
159 * <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
 | 
160 * 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
 | 
161 * 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
 | 
162 * 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
 | 
163 * </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
 | 
164 * 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
 | 
165 * 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
 | 
166 * | 
| 
 
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 * <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
 | 
168 * 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
 | 
169 * 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
 | 
170 * <code>start</code> or <code>end</code> arguments point to such changeset, or such changeset happen to be somewhere inside the range | 
| 
423
 
9c9c442b5f2e
Major refactoring of exception handling. Low-level API uses RuntimeExceptions, while checked are left for higher level
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
421 
diff
changeset
 | 
171 * <code>[start..end]</code>. Implementation does it best to report empty manifests | 
| 
 
9c9c442b5f2e
Major refactoring of exception handling. Low-level API uses RuntimeExceptions, while checked are left for higher level
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
421 
diff
changeset
 | 
172 * (<code>Inspector.begin(HgRepository.NO_REVISION, NULL, csetRevIndex);</code> | 
| 
 
9c9c442b5f2e
Major refactoring of exception handling. Low-level API uses RuntimeExceptions, while checked are left for higher level
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
421 
diff
changeset
 | 
173 * followed immediately by <code>Inspector.end(HgRepository.NO_REVISION)</code> | 
| 
 
9c9c442b5f2e
Major refactoring of exception handling. Low-level API uses RuntimeExceptions, while checked are left for higher level
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
421 
diff
changeset
 | 
174 * when <code>start</code> and/or <code>end</code> point to changeset with no associated | 
| 
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
 | 
175 * 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
 | 
176 * <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
 | 
177 * 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
 | 
178 * 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
 | 
179 * 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
 | 
180 * </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
 | 
181 * 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
 | 
182 * <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
 | 
183 * | 
| 
423
 
9c9c442b5f2e
Major refactoring of exception handling. Low-level API uses RuntimeExceptions, while checked are left for higher level
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
421 
diff
changeset
 | 
184 * @see HgRepository#NO_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
 | 
185 * @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
 | 
186 * @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
 | 
187 * @param inspector manifest revision visitor, can't be <code>null</code> | 
| 
423
 
9c9c442b5f2e
Major refactoring of exception handling. Low-level API uses RuntimeExceptions, while checked are left for higher level
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
421 
diff
changeset
 | 
188 * @throws HgRuntimeException subclass thereof to indicate issues with the library. <em>Runtime exception</em> | 
| 
 
9c9c442b5f2e
Major refactoring of exception handling. Low-level API uses RuntimeExceptions, while checked are left for higher level
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
421 
diff
changeset
 | 
189 * @throws IllegalArgumentException if inspector callback is <code>null</code> | 
| 
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
 | 
190 */ | 
| 
423
 
9c9c442b5f2e
Major refactoring of exception handling. Low-level API uses RuntimeExceptions, while checked are left for higher level
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
421 
diff
changeset
 | 
191 public void walk(int start, int end, final Inspector inspector) throws HgRuntimeException, IllegalArgumentException { | 
| 
196
 
e2115da4cf6a
Pool objects to avoid memory polution with duplicates
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
157 
diff
changeset
 | 
192 if (inspector == null) { | 
| 
 
e2115da4cf6a
Pool objects to avoid memory polution with duplicates
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
157 
diff
changeset
 | 
193 throw new IllegalArgumentException(); | 
| 
 
e2115da4cf6a
Pool objects to avoid memory polution with duplicates
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
157 
diff
changeset
 | 
194 } | 
| 
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
 | 
195 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
 | 
196 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
 | 
197 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
 | 
198 manifestFirst = fromChangelog(csetFirst+i); | 
| 
403
 
2747b0723867
FIXMEs: work on exceptions and javadoc
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
390 
diff
changeset
 | 
199 if (manifestFirst == BAD_REVISION) { | 
| 
423
 
9c9c442b5f2e
Major refactoring of exception handling. Low-level API uses RuntimeExceptions, while checked are left for higher level
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
421 
diff
changeset
 | 
200 inspector.begin(NO_REVISION, NULL, csetFirst+i); | 
| 
 
9c9c442b5f2e
Major refactoring of exception handling. Low-level API uses RuntimeExceptions, while checked are left for higher level
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
421 
diff
changeset
 | 
201 inspector.end(NO_REVISION); | 
| 
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
 | 
202 } | 
| 
 
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
 | 
203 i++; | 
| 
403
 
2747b0723867
FIXMEs: work on exceptions and javadoc
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
390 
diff
changeset
 | 
204 } while (manifestFirst == BAD_REVISION && csetFirst+i <= csetLast); | 
| 
 
2747b0723867
FIXMEs: work on exceptions and javadoc
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
390 
diff
changeset
 | 
205 if (manifestFirst == BAD_REVISION) { | 
| 
490
 
b3c16d1aede0
Refactoring: move HgRepository's implementation aspects to Internals (which is now its imlementation counterpart and primary repository class to be used by other parts of the library)
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
456 
diff
changeset
 | 
206 getRepo().getSessionContext().getLog().dump(getClass(), Info, "None of changesets [%d..%d] have associated manifest revision", csetFirst, csetLast); | 
| 
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
 | 
207 // 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
 | 
208 // 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
 | 
209 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
 | 
210 } | 
| 
 
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
 | 
211 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
 | 
212 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
 | 
213 manifestLast = fromChangelog(csetLast-i); | 
| 
403
 
2747b0723867
FIXMEs: work on exceptions and javadoc
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
390 
diff
changeset
 | 
214 if (manifestLast == BAD_REVISION) { | 
| 
423
 
9c9c442b5f2e
Major refactoring of exception handling. Low-level API uses RuntimeExceptions, while checked are left for higher level
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
421 
diff
changeset
 | 
215 inspector.begin(NO_REVISION, NULL, csetLast-i); | 
| 
 
9c9c442b5f2e
Major refactoring of exception handling. Low-level API uses RuntimeExceptions, while checked are left for higher level
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
421 
diff
changeset
 | 
216 inspector.end(NO_REVISION); | 
| 
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
 | 
217 } | 
| 
 
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
 | 
218 i++; | 
| 
403
 
2747b0723867
FIXMEs: work on exceptions and javadoc
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
390 
diff
changeset
 | 
219 } while (manifestLast == BAD_REVISION && csetLast-i >= csetFirst); | 
| 
 
2747b0723867
FIXMEs: work on exceptions and javadoc
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
390 
diff
changeset
 | 
220 if (manifestLast == BAD_REVISION) { | 
| 
423
 
9c9c442b5f2e
Major refactoring of exception handling. Low-level API uses RuntimeExceptions, while checked are left for higher level
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
421 
diff
changeset
 | 
221 // hmm, manifestFirst != BAD_REVISION here, hence there's i from [csetFirst..csetLast] for which manifest entry exists, | 
| 
 
9c9c442b5f2e
Major refactoring of exception handling. Low-level API uses RuntimeExceptions, while checked are left for higher level
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
421 
diff
changeset
 | 
222 // and thus it's impossible to run into manifestLast == BAD_REVISION. Nevertheless, never hurts to check. | 
| 
 
9c9c442b5f2e
Major refactoring of exception handling. Low-level API uses RuntimeExceptions, while checked are left for higher level
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
421 
diff
changeset
 | 
223 throw new HgInvalidStateException(String.format("Manifest %d-%d(!) for cset range [%d..%d] ", manifestFirst, manifestLast, csetFirst, csetLast)); | 
| 
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
 | 
224 } | 
| 
 
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
 | 
225 if (manifestLast < manifestFirst) { | 
| 
300
 
650b45d290b1
Share range check code
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
285 
diff
changeset
 | 
226 // 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
 | 
227 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
 | 
228 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
 | 
229 manifestFirst = x; | 
| 
300
 
650b45d290b1
Share range check code
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
285 
diff
changeset
 | 
230 } | 
| 
571
 
e4ee4bf4c7d0
Let session context control creation of Path instances
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
550 
diff
changeset
 | 
231 content.iterate(manifestFirst, manifestLast, true, new ManifestParser(inspector)); | 
| 
19
 
40532cdc92fc
Inspector (visitor) for manifest
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
16 
diff
changeset
 | 
232 } | 
| 
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
 | 
233 | 
| 
254
 
a620f0663a37
Collect tags for a file - improve performance of 'sparse' manifest reads
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
232 
diff
changeset
 | 
234 /** | 
| 
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
 | 
235 * "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
 | 
236 * <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
 | 
237 * 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
 | 
238 * 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
 | 
239 * 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
 | 
240 * | 
| 
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
 | 
241 * @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
 | 
242 * @param revisionIndexes local indexes of changesets to visit, non-<code>null</code> | 
| 
628
 
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
608 
diff
changeset
 | 
243 * @throws HgInvalidRevisionException if method argument specifies non-existent revision index. <em>Runtime exception</em> | 
| 
 
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
608 
diff
changeset
 | 
244 * @throws HgInvalidControlFileException if failed to access revlog index/data entry. <em>Runtime exception</em> | 
| 
 
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
608 
diff
changeset
 | 
245 * @throws HgRuntimeException subclass thereof to indicate other issues with the library. <em>Runtime exception</em> | 
| 
423
 
9c9c442b5f2e
Major refactoring of exception handling. Low-level API uses RuntimeExceptions, while checked are left for higher level
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
421 
diff
changeset
 | 
246 * @throws InvalidArgumentException if supplied arguments are <code>null</code>s | 
| 
254
 
a620f0663a37
Collect tags for a file - improve performance of 'sparse' manifest reads
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
232 
diff
changeset
 | 
247 */ | 
| 
423
 
9c9c442b5f2e
Major refactoring of exception handling. Low-level API uses RuntimeExceptions, while checked are left for higher level
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
421 
diff
changeset
 | 
248 public void walk(final Inspector inspector, int... revisionIndexes) throws HgRuntimeException, IllegalArgumentException { | 
| 
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
 | 
249 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
 | 
250 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
 | 
251 } | 
| 
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
 | 
252 int[] manifestRevs = toManifestRevisionIndexes(revisionIndexes, inspector); | 
| 
571
 
e4ee4bf4c7d0
Let session context control creation of Path instances
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
550 
diff
changeset
 | 
253 content.iterate(manifestRevs, true, new ManifestParser(inspector)); | 
| 
254
 
a620f0663a37
Collect tags for a file - improve performance of 'sparse' manifest reads
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
232 
diff
changeset
 | 
254 } | 
| 
 
a620f0663a37
Collect tags for a file - improve performance of 'sparse' manifest reads
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
232 
diff
changeset
 | 
255 | 
| 
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
 | 
256 // | 
| 
 
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
 | 
257 /** | 
| 
403
 
2747b0723867
FIXMEs: work on exceptions and javadoc
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
390 
diff
changeset
 | 
258 * Tells manifest revision number that corresponds to the given changeset. May return {@link HgRepository#BAD_REVISION} | 
| 
 
2747b0723867
FIXMEs: work on exceptions and javadoc
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
390 
diff
changeset
 | 
259 * if changeset has no associated manifest (cset records NULL nodeid for manifest). | 
| 
 
2747b0723867
FIXMEs: work on exceptions and javadoc
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
390 
diff
changeset
 | 
260 * @return manifest revision index, non-negative, or {@link HgRepository#BAD_REVISION}. | 
| 
628
 
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
608 
diff
changeset
 | 
261 * @throws HgInvalidRevisionException if method argument specifies non-existent revision index. <em>Runtime exception</em> | 
| 
 
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
608 
diff
changeset
 | 
262 * @throws HgInvalidControlFileException if failed to access revlog index/data entry. <em>Runtime exception</em> | 
| 
 
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
608 
diff
changeset
 | 
263 * @throws HgRuntimeException subclass thereof to indicate other issues with the library. <em>Runtime exception</em> | 
| 
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
 | 
264 */ | 
| 
628
 
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
608 
diff
changeset
 | 
265 /*package-local*/ int fromChangelog(int changesetRevisionIndex) throws HgRuntimeException { | 
| 
368
 
8107b95f4280
Update Javadoc with 'revision index'
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
367 
diff
changeset
 | 
266 if (HgInternals.wrongRevisionIndex(changesetRevisionIndex)) { | 
| 
425
 
48f993aa2f41
FIXMEs: exceptions, javadoc
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
424 
diff
changeset
 | 
267 throw new HgInvalidRevisionException(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
 | 
268 } | 
| 
368
 
8107b95f4280
Update Javadoc with 'revision index'
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
367 
diff
changeset
 | 
269 if (changesetRevisionIndex == HgRepository.WORKING_COPY || changesetRevisionIndex == HgRepository.BAD_REVISION) { | 
| 
425
 
48f993aa2f41
FIXMEs: exceptions, javadoc
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
424 
diff
changeset
 | 
270 throw new HgInvalidRevisionException("Can't use constants like WORKING_COPY or BAD_REVISION", null, changesetRevisionIndex); | 
| 
257
 
f39fb6b3cc76
Handle revision constants correctly
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
254 
diff
changeset
 | 
271 } | 
| 
 
f39fb6b3cc76
Handle revision constants correctly
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
254 
diff
changeset
 | 
272 // revisionNumber == TIP is processed by RevisionMapper | 
| 
607
 
66f1cc23b906
Refresh revlogs if a change to a file has been detected; do not force reload of the whole repository
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
601 
diff
changeset
 | 
273 if (revisionMap == null || content.shallDropDerivedCaches()) { | 
| 
 
66f1cc23b906
Refresh revlogs if a change to a file has been detected; do not force reload of the whole repository
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
601 
diff
changeset
 | 
274 content.detach(revisionMapCleaner); | 
| 
 
66f1cc23b906
Refresh revlogs if a change to a file has been detected; do not force reload of the whole repository
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
601 
diff
changeset
 | 
275 final boolean buildOwnLookup = super.revisionLookup == null; | 
| 
 
66f1cc23b906
Refresh revlogs if a change to a file has been detected; do not force reload of the whole repository
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
601 
diff
changeset
 | 
276 RevisionMapper rmap = new RevisionMapper(buildOwnLookup); | 
| 
 
66f1cc23b906
Refresh revlogs if a change to a file has been detected; do not force reload of the whole repository
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
601 
diff
changeset
 | 
277 content.iterate(0, TIP, false, rmap); | 
| 
 
66f1cc23b906
Refresh revlogs if a change to a file has been detected; do not force reload of the whole repository
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
601 
diff
changeset
 | 
278 rmap.fixReusedManifests(); | 
| 
 
66f1cc23b906
Refresh revlogs if a change to a file has been detected; do not force reload of the whole repository
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
601 
diff
changeset
 | 
279 if (buildOwnLookup && super.useRevisionLookup) { | 
| 
600
 
46f29b73e51e
Utilize RevisionLookup to speed-up getRevisionIndex of both manifest and changelog
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
598 
diff
changeset
 | 
280 // reuse RevisionLookup if there's none yet | 
| 
607
 
66f1cc23b906
Refresh revlogs if a change to a file has been detected; do not force reload of the whole repository
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
601 
diff
changeset
 | 
281 super.setRevisionLookup(rmap.manifestNodeids); | 
| 
600
 
46f29b73e51e
Utilize RevisionLookup to speed-up getRevisionIndex of both manifest and changelog
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
598 
diff
changeset
 | 
282 } | 
| 
607
 
66f1cc23b906
Refresh revlogs if a change to a file has been detected; do not force reload of the whole repository
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
601 
diff
changeset
 | 
283 rmap.manifestNodeids = null; | 
| 
 
66f1cc23b906
Refresh revlogs if a change to a file has been detected; do not force reload of the whole repository
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
601 
diff
changeset
 | 
284 revisionMap = rmap; | 
| 
 
66f1cc23b906
Refresh revlogs if a change to a file has been detected; do not force reload of the whole repository
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
601 
diff
changeset
 | 
285 // although in most cases modified manifest is accessed through one of the methods in this class | 
| 
 
66f1cc23b906
Refresh revlogs if a change to a file has been detected; do not force reload of the whole repository
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
601 
diff
changeset
 | 
286 // and hence won't have a chance till this moment to be reloaded via revisionMapCleaner | 
| 
 
66f1cc23b906
Refresh revlogs if a change to a file has been detected; do not force reload of the whole repository
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
601 
diff
changeset
 | 
287 // (RevlogStream sends events on attempt to read revlog, and so far we haven't tried to read anything, | 
| 
 
66f1cc23b906
Refresh revlogs if a change to a file has been detected; do not force reload of the whole repository
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
601 
diff
changeset
 | 
288 // it's still reasonable to have this cleaner attached, just in case any method from Revlog base class | 
| 
 
66f1cc23b906
Refresh revlogs if a change to a file has been detected; do not force reload of the whole repository
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
601 
diff
changeset
 | 
289 // has been called (e.g. getLastRevision()) | 
| 
 
66f1cc23b906
Refresh revlogs if a change to a file has been detected; do not force reload of the whole repository
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
601 
diff
changeset
 | 
290 content.attach(revisionMapCleaner); | 
| 
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
 | 
291 } | 
| 
368
 
8107b95f4280
Update Javadoc with 'revision index'
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
367 
diff
changeset
 | 
292 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
 | 
293 } | 
| 
 
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
 | 
294 | 
| 
232
 
b7347daa50e3
Allow to cat a file with changeset revision
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
222 
diff
changeset
 | 
295 /** | 
| 
 
b7347daa50e3
Allow to cat a file with changeset revision
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
222 
diff
changeset
 | 
296 * Extracts file revision as it was known at the time of given changeset. | 
| 
426
 
063b0663495a
HgManifest#getFileRevisions refactored into #walkFileRevisions to match pattern throught rest of the library
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
425 
diff
changeset
 | 
297 * <p>For more thorough details about file at specific changeset, use {@link HgChangesetFileSneaker}. | 
| 
 
063b0663495a
HgManifest#getFileRevisions refactored into #walkFileRevisions to match pattern throught rest of the library
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
425 
diff
changeset
 | 
298 * <p>To visit few changesets for the same file, use {@link #walkFileRevisions(Path, Inspector, int...)} | 
| 
232
 
b7347daa50e3
Allow to cat a file with changeset revision
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
222 
diff
changeset
 | 
299 * | 
| 
426
 
063b0663495a
HgManifest#getFileRevisions refactored into #walkFileRevisions to match pattern throught rest of the library
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
425 
diff
changeset
 | 
300 * @see #walkFileRevisions(Path, Inspector, int...) | 
| 
417
 
ccd7d25e5aea
New and better name for HgFileInformer - HgChangesetFileSneaker. Explain (comments) ties between HgManifest, HgDataFile, HgChangesetFileSneaker and reasons for method placement
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
415 
diff
changeset
 | 
301 * @see HgChangesetFileSneaker | 
| 
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
 | 
302 * @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
 | 
303 * @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
 | 
304 * @return file revision or <code>null</code> if manifest at specified revision doesn't list such file | 
| 
628
 
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
608 
diff
changeset
 | 
305 * @throws HgInvalidRevisionException if supplied revision doesn't identify revision from this revlog. <em>Runtime exception</em> | 
| 
 
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
608 
diff
changeset
 | 
306 * @throws HgInvalidControlFileException if failed to access revlog index/data entry. <em>Runtime exception</em> | 
| 
 
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
608 
diff
changeset
 | 
307 * @throws HgRuntimeException subclass thereof to indicate other issues with the library. <em>Runtime exception</em> | 
| 
232
 
b7347daa50e3
Allow to cat a file with changeset revision
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
222 
diff
changeset
 | 
308 */ | 
| 
628
 
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
608 
diff
changeset
 | 
309 public Nodeid getFileRevision(int changelogRevisionIndex, final Path file) throws HgRuntimeException { | 
| 
417
 
ccd7d25e5aea
New and better name for HgFileInformer - HgChangesetFileSneaker. Explain (comments) ties between HgManifest, HgDataFile, HgChangesetFileSneaker and reasons for method placement
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
415 
diff
changeset
 | 
310 // there's no need for HgDataFile to own this method, or get a delegate | 
| 
 
ccd7d25e5aea
New and better name for HgFileInformer - HgChangesetFileSneaker. Explain (comments) ties between HgManifest, HgDataFile, HgChangesetFileSneaker and reasons for method placement
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
415 
diff
changeset
 | 
311 // as most of HgDataFile API is using file revision indexes, and there's easy step from file revision index to | 
| 
 
ccd7d25e5aea
New and better name for HgFileInformer - HgChangesetFileSneaker. Explain (comments) ties between HgManifest, HgDataFile, HgChangesetFileSneaker and reasons for method placement
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
415 
diff
changeset
 | 
312 // both file revision and changeset revision index. But there's no easy way to go from changesetRevisionIndex to | 
| 
547
 
66fc86e8c0dd
#getFileRevision() shall accept TIP as an argument
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
537 
diff
changeset
 | 
313 // file revision (the task this method solves), except for HgFileInformer | 
| 
417
 
ccd7d25e5aea
New and better name for HgFileInformer - HgChangesetFileSneaker. Explain (comments) ties between HgManifest, HgDataFile, HgChangesetFileSneaker and reasons for method placement
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
415 
diff
changeset
 | 
314 // I feel methods dealing with changeset indexes shall be more exposed in HgChangelog and HgManifest API. | 
| 
547
 
66fc86e8c0dd
#getFileRevision() shall accept TIP as an argument
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
537 
diff
changeset
 | 
315 // TODO need tests (e.g. pass TIP here to see resMap.get(-1) doesn't fail) | 
| 
426
 
063b0663495a
HgManifest#getFileRevisions refactored into #walkFileRevisions to match pattern throught rest of the library
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
425 
diff
changeset
 | 
316 int manifestRevIndex = fromChangelog(changelogRevisionIndex); | 
| 
 
063b0663495a
HgManifest#getFileRevisions refactored into #walkFileRevisions to match pattern throught rest of the library
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
425 
diff
changeset
 | 
317 if (manifestRevIndex == BAD_REVISION) { | 
| 
 
063b0663495a
HgManifest#getFileRevisions refactored into #walkFileRevisions to match pattern throught rest of the library
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
425 
diff
changeset
 | 
318 return null; | 
| 
 
063b0663495a
HgManifest#getFileRevisions refactored into #walkFileRevisions to match pattern throught rest of the library
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
425 
diff
changeset
 | 
319 } | 
| 
 
063b0663495a
HgManifest#getFileRevisions refactored into #walkFileRevisions to match pattern throught rest of the library
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
425 
diff
changeset
 | 
320 IntMap<Nodeid> resMap = new IntMap<Nodeid>(3); | 
| 
 
063b0663495a
HgManifest#getFileRevisions refactored into #walkFileRevisions to match pattern throught rest of the library
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
425 
diff
changeset
 | 
321 FileLookupInspector parser = new FileLookupInspector(encodingHelper, file, resMap, null); | 
| 
 
063b0663495a
HgManifest#getFileRevisions refactored into #walkFileRevisions to match pattern throught rest of the library
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
425 
diff
changeset
 | 
322 parser.walk(manifestRevIndex, content); | 
| 
550
 
c1478cc31f45
Regression: expect file to be missing in a manifest
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
547 
diff
changeset
 | 
323 assert resMap.size() <= 1; // size() == 0 if file wasn't found | 
| 
547
 
66fc86e8c0dd
#getFileRevision() shall accept TIP as an argument
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
537 
diff
changeset
 | 
324 // can't use changelogRevisionIndex as key - it might have been TIP | 
| 
550
 
c1478cc31f45
Regression: expect file to be missing in a manifest
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
547 
diff
changeset
 | 
325 return resMap.size() == 0 ? null : resMap.get(resMap.firstKey()); | 
| 
326
 
d42a45a2c9d6
Alternative tag collection approach for a file history
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
324 
diff
changeset
 | 
326 } | 
| 
426
 
063b0663495a
HgManifest#getFileRevisions refactored into #walkFileRevisions to match pattern throught rest of the library
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
425 
diff
changeset
 | 
327 | 
| 
 
063b0663495a
HgManifest#getFileRevisions refactored into #walkFileRevisions to match pattern throught rest of the library
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
425 
diff
changeset
 | 
328 /** | 
| 
 
063b0663495a
HgManifest#getFileRevisions refactored into #walkFileRevisions to match pattern throught rest of the library
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
425 
diff
changeset
 | 
329 * Visit file revisions as they were recorded at the time of given changesets. Same file revision may be reported as many times as | 
| 
 
063b0663495a
HgManifest#getFileRevisions refactored into #walkFileRevisions to match pattern throught rest of the library
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
425 
diff
changeset
 | 
330 * there are changesets that refer to that revision. Both {@link Inspector#begin(int, Nodeid, int)} and {@link Inspector#end(int)} | 
| 
 
063b0663495a
HgManifest#getFileRevisions refactored into #walkFileRevisions to match pattern throught rest of the library
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
425 
diff
changeset
 | 
331 * with appropriate values are invoked around {@link Inspector#next(Nodeid, Path, Flags)} call for the supplied file | 
| 
 
063b0663495a
HgManifest#getFileRevisions refactored into #walkFileRevisions to match pattern throught rest of the library
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
425 
diff
changeset
 | 
332 * | 
| 
 
063b0663495a
HgManifest#getFileRevisions refactored into #walkFileRevisions to match pattern throught rest of the library
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
425 
diff
changeset
 | 
333 * <p>NOTE, this method doesn't respect return values from callback (i.e. to stop iteration), as it's lookup of a single file | 
| 
 
063b0663495a
HgManifest#getFileRevisions refactored into #walkFileRevisions to match pattern throught rest of the library
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
425 
diff
changeset
 | 
334 * and canceling it seems superfluous. However, this may change in future and it's recommended to return <code>true</code> from | 
| 
 
063b0663495a
HgManifest#getFileRevisions refactored into #walkFileRevisions to match pattern throught rest of the library
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
425 
diff
changeset
 | 
335 * all {@link Inspector} methods. | 
| 
 
063b0663495a
HgManifest#getFileRevisions refactored into #walkFileRevisions to match pattern throught rest of the library
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
425 
diff
changeset
 | 
336 * | 
| 
 
063b0663495a
HgManifest#getFileRevisions refactored into #walkFileRevisions to match pattern throught rest of the library
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
425 
diff
changeset
 | 
337 * @see #getFileRevision(int, Path) | 
| 
 
063b0663495a
HgManifest#getFileRevisions refactored into #walkFileRevisions to match pattern throught rest of the library
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
425 
diff
changeset
 | 
338 * @param file path of interest | 
| 
 
063b0663495a
HgManifest#getFileRevisions refactored into #walkFileRevisions to match pattern throught rest of the library
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
425 
diff
changeset
 | 
339 * @param inspector callback to receive details about selected file | 
| 
 
063b0663495a
HgManifest#getFileRevisions refactored into #walkFileRevisions to match pattern throught rest of the library
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
425 
diff
changeset
 | 
340 * @param changelogRevisionIndexes changeset indexes to visit | 
| 
628
 
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
608 
diff
changeset
 | 
341 * @throws HgInvalidRevisionException if supplied revision doesn't identify revision from this revlog. <em>Runtime exception</em> | 
| 
 
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
608 
diff
changeset
 | 
342 * @throws HgInvalidControlFileException if failed to access revlog index/data entry. <em>Runtime exception</em> | 
| 
 
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
608 
diff
changeset
 | 
343 * @throws HgRuntimeException subclass thereof to indicate other issues with the library. <em>Runtime exception</em> | 
| 
426
 
063b0663495a
HgManifest#getFileRevisions refactored into #walkFileRevisions to match pattern throught rest of the library
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
425 
diff
changeset
 | 
344 */ | 
| 
 
063b0663495a
HgManifest#getFileRevisions refactored into #walkFileRevisions to match pattern throught rest of the library
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
425 
diff
changeset
 | 
345 public void walkFileRevisions(Path file, Inspector inspector, int... changelogRevisionIndexes) throws HgRuntimeException { | 
| 
 
063b0663495a
HgManifest#getFileRevisions refactored into #walkFileRevisions to match pattern throught rest of the library
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
425 
diff
changeset
 | 
346 if (file == null || inspector == null || changelogRevisionIndexes == null) { | 
| 
 
063b0663495a
HgManifest#getFileRevisions refactored into #walkFileRevisions to match pattern throught rest of the library
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
425 
diff
changeset
 | 
347 throw new IllegalArgumentException(); | 
| 
 
063b0663495a
HgManifest#getFileRevisions refactored into #walkFileRevisions to match pattern throught rest of the library
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
425 
diff
changeset
 | 
348 } | 
| 
 
063b0663495a
HgManifest#getFileRevisions refactored into #walkFileRevisions to match pattern throught rest of the library
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
425 
diff
changeset
 | 
349 // TODO [post-1.0] need tests. There's Main#checkWalkFileRevisions that may be a starting point | 
| 
 
063b0663495a
HgManifest#getFileRevisions refactored into #walkFileRevisions to match pattern throught rest of the library
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
425 
diff
changeset
 | 
350 int[] manifestRevIndexes = toManifestRevisionIndexes(changelogRevisionIndexes, null); | 
| 
 
063b0663495a
HgManifest#getFileRevisions refactored into #walkFileRevisions to match pattern throught rest of the library
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
425 
diff
changeset
 | 
351 FileLookupInspector parser = new FileLookupInspector(encodingHelper, file, inspector); | 
| 
 
063b0663495a
HgManifest#getFileRevisions refactored into #walkFileRevisions to match pattern throught rest of the library
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
425 
diff
changeset
 | 
352 parser.walk(manifestRevIndexes, content); | 
| 
232
 
b7347daa50e3
Allow to cat a file with changeset revision
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
222 
diff
changeset
 | 
353 } | 
| 
326
 
d42a45a2c9d6
Alternative tag collection approach for a file history
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
324 
diff
changeset
 | 
354 | 
| 
415
 
ee8264d80747
Explicit constant for regular file flags, access to flags for a given file revision
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
414 
diff
changeset
 | 
355 /** | 
| 
417
 
ccd7d25e5aea
New and better name for HgFileInformer - HgChangesetFileSneaker. Explain (comments) ties between HgManifest, HgDataFile, HgChangesetFileSneaker and reasons for method placement
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
415 
diff
changeset
 | 
356 * Extract file {@link Flags flags} as they were recorded in appropriate manifest version. | 
| 
 
ccd7d25e5aea
New and better name for HgFileInformer - HgChangesetFileSneaker. Explain (comments) ties between HgManifest, HgDataFile, HgChangesetFileSneaker and reasons for method placement
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
415 
diff
changeset
 | 
357 * | 
| 
 
ccd7d25e5aea
New and better name for HgFileInformer - HgChangesetFileSneaker. Explain (comments) ties between HgManifest, HgDataFile, HgChangesetFileSneaker and reasons for method placement
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
415 
diff
changeset
 | 
358 * @see HgDataFile#getFlags(int) | 
| 
415
 
ee8264d80747
Explicit constant for regular file flags, access to flags for a given file revision
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
414 
diff
changeset
 | 
359 * @param changesetRevIndex changeset revision index | 
| 
 
ee8264d80747
Explicit constant for regular file flags, access to flags for a given file revision
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
414 
diff
changeset
 | 
360 * @param file path to look up | 
| 
417
 
ccd7d25e5aea
New and better name for HgFileInformer - HgChangesetFileSneaker. Explain (comments) ties between HgManifest, HgDataFile, HgChangesetFileSneaker and reasons for method placement
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
415 
diff
changeset
 | 
361 * @return one of predefined enum values, or <code>null</code> if file was not known in the specified revision | 
| 
628
 
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
608 
diff
changeset
 | 
362 * @throws HgInvalidRevisionException if supplied revision doesn't identify revision from this revlog. <em>Runtime exception</em> | 
| 
 
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
608 
diff
changeset
 | 
363 * @throws HgInvalidControlFileException if failed to access revlog index/data entry. <em>Runtime exception</em> | 
| 
 
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
608 
diff
changeset
 | 
364 * @throws HgRuntimeException subclass thereof to indicate other issues with the library. <em>Runtime exception</em> | 
| 
415
 
ee8264d80747
Explicit constant for regular file flags, access to flags for a given file revision
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
414 
diff
changeset
 | 
365 */ | 
| 
628
 
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
608 
diff
changeset
 | 
366 public Flags getFileFlags(int changesetRevIndex, Path file) throws HgRuntimeException { | 
| 
415
 
ee8264d80747
Explicit constant for regular file flags, access to flags for a given file revision
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
414 
diff
changeset
 | 
367 int manifestRevIdx = fromChangelog(changesetRevIndex); | 
| 
 
ee8264d80747
Explicit constant for regular file flags, access to flags for a given file revision
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
414 
diff
changeset
 | 
368 IntMap<Flags> resMap = new IntMap<Flags>(2); | 
| 
426
 
063b0663495a
HgManifest#getFileRevisions refactored into #walkFileRevisions to match pattern throught rest of the library
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
425 
diff
changeset
 | 
369 FileLookupInspector parser = new FileLookupInspector(encodingHelper, file, null, resMap); | 
| 
 
063b0663495a
HgManifest#getFileRevisions refactored into #walkFileRevisions to match pattern throught rest of the library
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
425 
diff
changeset
 | 
370 parser.walk(manifestRevIdx, content); | 
| 
550
 
c1478cc31f45
Regression: expect file to be missing in a manifest
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
547 
diff
changeset
 | 
371 assert resMap.size() <= 1; // size() == 0 if not found | 
| 
547
 
66fc86e8c0dd
#getFileRevision() shall accept TIP as an argument
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
537 
diff
changeset
 | 
372 // can't use changesetRevIndex as key - it might have been TIP | 
| 
550
 
c1478cc31f45
Regression: expect file to be missing in a manifest
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
547 
diff
changeset
 | 
373 return resMap.size() == 0 ? null : resMap.get(resMap.firstKey()); | 
| 
415
 
ee8264d80747
Explicit constant for regular file flags, access to flags for a given file revision
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
414 
diff
changeset
 | 
374 } | 
| 
 
ee8264d80747
Explicit constant for regular file flags, access to flags for a given file revision
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
414 
diff
changeset
 | 
375 | 
| 
326
 
d42a45a2c9d6
Alternative tag collection approach for a file history
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
324 
diff
changeset
 | 
376 | 
| 
607
 
66f1cc23b906
Refresh revlogs if a change to a file has been detected; do not force reload of the whole repository
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
601 
diff
changeset
 | 
377 /*package-local*/ void dropCachesOnChangelogChange() { | 
| 
 
66f1cc23b906
Refresh revlogs if a change to a file has been detected; do not force reload of the whole repository
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
601 
diff
changeset
 | 
378 // sort of a hack as it may happen that #fromChangelog() | 
| 
 
66f1cc23b906
Refresh revlogs if a change to a file has been detected; do not force reload of the whole repository
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
601 
diff
changeset
 | 
379 // is invoked for modified repository where revisionMap still points to an old state | 
| 
 
66f1cc23b906
Refresh revlogs if a change to a file has been detected; do not force reload of the whole repository
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
601 
diff
changeset
 | 
380 // Since there's no access to RevlogStream in #fromChangelog() if there's revisionMap | 
| 
 
66f1cc23b906
Refresh revlogs if a change to a file has been detected; do not force reload of the whole repository
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
601 
diff
changeset
 | 
381 // in place, there's no chance for RevlogStream to detect the change and to dispatch | 
| 
 
66f1cc23b906
Refresh revlogs if a change to a file has been detected; do not force reload of the whole repository
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
601 
diff
changeset
 | 
382 // change notification so that revisionMap got cleared. | 
| 
 
66f1cc23b906
Refresh revlogs if a change to a file has been detected; do not force reload of the whole repository
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
601 
diff
changeset
 | 
383 revisionMap = null; | 
| 
 
66f1cc23b906
Refresh revlogs if a change to a file has been detected; do not force reload of the whole repository
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
601 
diff
changeset
 | 
384 } | 
| 
 
66f1cc23b906
Refresh revlogs if a change to a file has been detected; do not force reload of the whole repository
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
601 
diff
changeset
 | 
385 | 
| 
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
 | 
386 /** | 
| 
 
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
 | 
387 * @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
 | 
388 * @param inspector may be null if reporting of missing manifests is not needed | 
| 
628
 
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
608 
diff
changeset
 | 
389 * @throws HgInvalidRevisionException if supplied revision doesn't identify revision from this revlog. <em>Runtime exception</em> | 
| 
 
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
608 
diff
changeset
 | 
390 * @throws HgInvalidControlFileException if failed to access revlog index/data entry. <em>Runtime exception</em> | 
| 
 
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
608 
diff
changeset
 | 
391 * @throws HgRuntimeException subclass thereof to indicate other issues with the library. <em>Runtime exception</em> | 
| 
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
 | 
392 */ | 
| 
628
 
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
608 
diff
changeset
 | 
393 private int[] toManifestRevisionIndexes(int[] changelogRevisionIndexes, Inspector inspector) throws HgRuntimeException { | 
| 
368
 
8107b95f4280
Update Javadoc with 'revision index'
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
367 
diff
changeset
 | 
394 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
 | 
395 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
 | 
396 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
 | 
397 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
 | 
398 final int manifestRevisionIndex = fromChangelog(changelogRevisionIndexes[i]); | 
| 
403
 
2747b0723867
FIXMEs: work on exceptions and javadoc
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
390 
diff
changeset
 | 
399 if (manifestRevisionIndex == BAD_REVISION) { | 
| 
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
 | 
400 if (inspector != null) { | 
| 
423
 
9c9c442b5f2e
Major refactoring of exception handling. Low-level API uses RuntimeExceptions, while checked are left for higher level
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
421 
diff
changeset
 | 
401 inspector.begin(NO_REVISION, NULL, changelogRevisionIndexes[i]); | 
| 
 
9c9c442b5f2e
Major refactoring of exception handling. Low-level API uses RuntimeExceptions, while checked are left for higher level
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
421 
diff
changeset
 | 
402 inspector.end(NO_REVISION); | 
| 
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
 | 
403 } | 
| 
 
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
 | 
404 // 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
 | 
405 } 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
 | 
406 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
 | 
407 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
 | 
408 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
 | 
409 } | 
| 
 
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
 | 
410 j++; | 
| 
326
 
d42a45a2c9d6
Alternative tag collection approach for a file history
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
324 
diff
changeset
 | 
411 } | 
| 
 
d42a45a2c9d6
Alternative tag collection approach for a file history
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
324 
diff
changeset
 | 
412 } | 
| 
 
d42a45a2c9d6
Alternative tag collection approach for a file history
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
324 
diff
changeset
 | 
413 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
 | 
414 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
 | 
415 } | 
| 
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
 | 
416 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
 | 
417 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
 | 
418 } 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
 | 
419 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
 | 
420 //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
 | 
421 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
 | 
422 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
 | 
423 } | 
| 
326
 
d42a45a2c9d6
Alternative tag collection approach for a file history
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
324 
diff
changeset
 | 
424 } | 
| 
 
d42a45a2c9d6
Alternative tag collection approach for a file history
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
324 
diff
changeset
 | 
425 | 
| 
423
 
9c9c442b5f2e
Major refactoring of exception handling. Low-level API uses RuntimeExceptions, while checked are left for higher level
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
421 
diff
changeset
 | 
426 @Callback | 
| 
19
 
40532cdc92fc
Inspector (visitor) for manifest
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
16 
diff
changeset
 | 
427 public interface Inspector { | 
| 
285
 
6dbbc53fc46d
Use Path instead of plain String for manifest file names
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
268 
diff
changeset
 | 
428 /** | 
| 
537
 
5a455624be4f
Update javadoc for HgManifest.Inspector and fix erroneous internal API
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
490 
diff
changeset
 | 
429 * Denotes entering specific manifest revision, separate entries are | 
| 
 
5a455624be4f
Update javadoc for HgManifest.Inspector and fix erroneous internal API
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
490 
diff
changeset
 | 
430 * reported with subsequence {@link #next(Nodeid, Path, Flags)} calls. | 
| 
 
5a455624be4f
Update javadoc for HgManifest.Inspector and fix erroneous internal API
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
490 
diff
changeset
 | 
431 * | 
| 
583
 
47dfa0ec7e35
Effective revlog patching
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
574 
diff
changeset
 | 
432 * @param manifestRevisionIndex local revision index of the inspected revision | 
| 
537
 
5a455624be4f
Update javadoc for HgManifest.Inspector and fix erroneous internal API
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
490 
diff
changeset
 | 
433 * @param manifestRevision revision of the manifest we're about to iterate through | 
| 
 
5a455624be4f
Update javadoc for HgManifest.Inspector and fix erroneous internal API
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
490 
diff
changeset
 | 
434 * @param changelogRevisionIndex local revision index of changelog this manifest points to | 
| 
 
5a455624be4f
Update javadoc for HgManifest.Inspector and fix erroneous internal API
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
490 
diff
changeset
 | 
435 * @return <code>true</code> to continue iteration, <code>false</code> to stop | 
| 
628
 
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
608 
diff
changeset
 | 
436 * @throws HgRuntimeException propagates library issues. <em>Runtime exception</em> | 
| 
537
 
5a455624be4f
Update javadoc for HgManifest.Inspector and fix erroneous internal API
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
490 
diff
changeset
 | 
437 */ | 
| 
628
 
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
608 
diff
changeset
 | 
438 boolean begin(int manifestRevisionIndex, Nodeid manifestRevision, int changelogRevisionIndex) throws HgRuntimeException; | 
| 
537
 
5a455624be4f
Update javadoc for HgManifest.Inspector and fix erroneous internal API
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
490 
diff
changeset
 | 
439 | 
| 
 
5a455624be4f
Update javadoc for HgManifest.Inspector and fix erroneous internal API
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
490 
diff
changeset
 | 
440 | 
| 
 
5a455624be4f
Update javadoc for HgManifest.Inspector and fix erroneous internal API
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
490 
diff
changeset
 | 
441 /** | 
| 
 
5a455624be4f
Update javadoc for HgManifest.Inspector and fix erroneous internal API
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
490 
diff
changeset
 | 
442 * Reports each manifest entry | 
| 
 
5a455624be4f
Update javadoc for HgManifest.Inspector and fix erroneous internal API
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
490 
diff
changeset
 | 
443 * | 
| 
415
 
ee8264d80747
Explicit constant for regular file flags, access to flags for a given file revision
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
414 
diff
changeset
 | 
444 * @param nid file revision | 
| 
 
ee8264d80747
Explicit constant for regular file flags, access to flags for a given file revision
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
414 
diff
changeset
 | 
445 * @param fname file name | 
| 
 
ee8264d80747
Explicit constant for regular file flags, access to flags for a given file revision
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
414 
diff
changeset
 | 
446 * @param flags one of {@link HgManifest.Flags} constants, not <code>null</code> | 
| 
 
ee8264d80747
Explicit constant for regular file flags, access to flags for a given file revision
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
414 
diff
changeset
 | 
447 * @return <code>true</code> to continue iteration, <code>false</code> to stop | 
| 
628
 
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
608 
diff
changeset
 | 
448 * @throws HgRuntimeException propagates library issues. <em>Runtime exception</em> | 
| 
415
 
ee8264d80747
Explicit constant for regular file flags, access to flags for a given file revision
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
414 
diff
changeset
 | 
449 */ | 
| 
628
 
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
608 
diff
changeset
 | 
450 boolean next(Nodeid nid, Path fname, Flags flags) throws HgRuntimeException; | 
| 
537
 
5a455624be4f
Update javadoc for HgManifest.Inspector and fix erroneous internal API
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
490 
diff
changeset
 | 
451 | 
| 
 
5a455624be4f
Update javadoc for HgManifest.Inspector and fix erroneous internal API
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
490 
diff
changeset
 | 
452 /** | 
| 
 
5a455624be4f
Update javadoc for HgManifest.Inspector and fix erroneous internal API
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
490 
diff
changeset
 | 
453 * Denotes leaving specific manifest revision, after all entries were reported using {@link #next(Nodeid, Path, Flags)} | 
| 
 
5a455624be4f
Update javadoc for HgManifest.Inspector and fix erroneous internal API
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
490 
diff
changeset
 | 
454 * | 
| 
 
5a455624be4f
Update javadoc for HgManifest.Inspector and fix erroneous internal API
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
490 
diff
changeset
 | 
455 * @param manifestRevisionIndex indicates manifest revision, corresponds to opening {@link #begin(int, Nodeid, int)} | 
| 
 
5a455624be4f
Update javadoc for HgManifest.Inspector and fix erroneous internal API
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
490 
diff
changeset
 | 
456 * @return <code>true</code> to continue iteration, <code>false</code> to stop | 
| 
628
 
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
608 
diff
changeset
 | 
457 * @throws HgRuntimeException propagates library issues. <em>Runtime exception</em> | 
| 
537
 
5a455624be4f
Update javadoc for HgManifest.Inspector and fix erroneous internal API
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
490 
diff
changeset
 | 
458 */ | 
| 
628
 
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
608 
diff
changeset
 | 
459 boolean end(int manifestRevisionIndex) throws HgRuntimeException; | 
| 
267
 
ec921ef0628e
Revert manifest parser changes - no single string and back to HashMap Pool
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
266 
diff
changeset
 | 
460 } | 
| 
424
 
6437d261048a
Deprecated code removed
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
423 
diff
changeset
 | 
461 | 
| 
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
 | 
462 /** | 
| 
 
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
 | 
463 * 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
 | 
464 * 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
 | 
465 * 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
 | 
466 * 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
 | 
467 * | 
| 
285
 
6dbbc53fc46d
Use Path instead of plain String for manifest file names
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
268 
diff
changeset
 | 
468 * 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
 | 
469 * 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
 | 
470 * 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
 | 
471 */ | 
| 
571
 
e4ee4bf4c7d0
Let session context control creation of Path instances
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
550 
diff
changeset
 | 
472 private final 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
 | 
473 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
 | 
474 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
 | 
475 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
 | 
476 private Path result; | 
| 
267
 
ec921ef0628e
Revert manifest parser changes - no single string and back to HashMap Pool
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
266 
diff
changeset
 | 
477 | 
| 
571
 
e4ee4bf4c7d0
Let session context control creation of Path instances
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
550 
diff
changeset
 | 
478 public PathProxy(byte[] data, int start, int length) { | 
| 
267
 
ec921ef0628e
Revert manifest parser changes - no single string and back to HashMap Pool
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
266 
diff
changeset
 | 
479 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
 | 
480 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
 | 
481 this.length = length; | 
| 
 
ec921ef0628e
Revert manifest parser changes - no single string and back to HashMap Pool
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
266 
diff
changeset
 | 
482 | 
| 
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
 | 
483 // 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
 | 
484 // 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
 | 
485 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
 | 
486 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
 | 
487 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
 | 
488 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
 | 
489 } | 
| 
 
ec921ef0628e
Revert manifest parser changes - no single string and back to HashMap Pool
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
266 
diff
changeset
 | 
490 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
 | 
491 } | 
| 
 
ec921ef0628e
Revert manifest parser changes - no single string and back to HashMap Pool
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
266 
diff
changeset
 | 
492 | 
| 
 
ec921ef0628e
Revert manifest parser changes - no single string and back to HashMap Pool
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
266 
diff
changeset
 | 
493 @Override | 
| 
 
ec921ef0628e
Revert manifest parser changes - no single string and back to HashMap Pool
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
266 
diff
changeset
 | 
494 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
 | 
495 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
 | 
496 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
 | 
497 } | 
| 
285
 
6dbbc53fc46d
Use Path instead of plain String for manifest file names
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
268 
diff
changeset
 | 
498 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
 | 
499 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
 | 
500 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
 | 
501 } | 
| 
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
 | 
502 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
 | 
503 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
 | 
504 } | 
| 
 
ec921ef0628e
Revert manifest parser changes - no single string and back to HashMap Pool
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
266 
diff
changeset
 | 
505 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
 | 
506 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
 | 
507 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
 | 
508 } | 
| 
 
ec921ef0628e
Revert manifest parser changes - no single string and back to HashMap Pool
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
266 
diff
changeset
 | 
509 } | 
| 
 
ec921ef0628e
Revert manifest parser changes - no single string and back to HashMap Pool
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
266 
diff
changeset
 | 
510 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
 | 
511 } | 
| 
 
ec921ef0628e
Revert manifest parser changes - no single string and back to HashMap Pool
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
266 
diff
changeset
 | 
512 @Override | 
| 
 
ec921ef0628e
Revert manifest parser changes - no single string and back to HashMap Pool
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
266 
diff
changeset
 | 
513 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
 | 
514 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
 | 
515 } | 
| 
 
ec921ef0628e
Revert manifest parser changes - no single string and back to HashMap Pool
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
266 
diff
changeset
 | 
516 | 
| 
285
 
6dbbc53fc46d
Use Path instead of plain String for manifest file names
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
268 
diff
changeset
 | 
517 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
 | 
518 if (result == null) { | 
| 
574
 
88afffd39899
Improve memory consumption of HgManifest#getFileRevision(): avoid extra byte[] instances
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
571 
diff
changeset
 | 
519 Path.Source pf = HgManifest.this.pathFactory; | 
| 
 
88afffd39899
Improve memory consumption of HgManifest#getFileRevision(): avoid extra byte[] instances
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
571 
diff
changeset
 | 
520 result = pf.path(HgManifest.this.encodingHelper.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
 | 
521 // 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
 | 
522 // 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
 | 
523 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
 | 
524 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
 | 
525 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
 | 
526 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
 | 
527 } | 
| 
 
ec921ef0628e
Revert manifest parser changes - no single string and back to HashMap Pool
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
266 
diff
changeset
 | 
528 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
 | 
529 } | 
| 
 
ec921ef0628e
Revert manifest parser changes - no single string and back to HashMap Pool
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
266 
diff
changeset
 | 
530 } | 
| 
196
 
e2115da4cf6a
Pool objects to avoid memory polution with duplicates
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
157 
diff
changeset
 | 
531 | 
| 
571
 
e4ee4bf4c7d0
Let session context control creation of Path instances
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
550 
diff
changeset
 | 
532 private 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
 | 
533 private final Inspector inspector; | 
| 
431
 
12f668401613
FIXMEs: awkward API refactored, what need to be internal got hidden; public aspects got captured in slim interfaces
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
426 
diff
changeset
 | 
534 private IdentityPool<Nodeid> nodeidPool, thisRevPool; | 
| 
 
12f668401613
FIXMEs: awkward API refactored, what need to be internal got hidden; public aspects got captured in slim interfaces
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
426 
diff
changeset
 | 
535 private final IdentityPool<PathProxy> fnamePool; | 
| 
266
 
0a2f445de774
Improve manifest parsing: reduce number of arrays instantiated for Nodeid
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
264 
diff
changeset
 | 
536 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
 | 
537 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
 | 
538 private IterateControlMediator iterateControl; | 
| 
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
 | 
539 | 
| 
571
 
e4ee4bf4c7d0
Let session context control creation of Path instances
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
550 
diff
changeset
 | 
540 public ManifestParser(Inspector delegate) { | 
| 
196
 
e2115da4cf6a
Pool objects to avoid memory polution with duplicates
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
157 
diff
changeset
 | 
541 assert delegate != null; | 
| 
 
e2115da4cf6a
Pool objects to avoid memory polution with duplicates
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
157 
diff
changeset
 | 
542 inspector = delegate; | 
| 
431
 
12f668401613
FIXMEs: awkward API refactored, what need to be internal got hidden; public aspects got captured in slim interfaces
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
426 
diff
changeset
 | 
543 nodeidPool = new IdentityPool<Nodeid>(); | 
| 
 
12f668401613
FIXMEs: awkward API refactored, what need to be internal got hidden; public aspects got captured in slim interfaces
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
426 
diff
changeset
 | 
544 fnamePool = new IdentityPool<PathProxy>(); | 
| 
 
12f668401613
FIXMEs: awkward API refactored, what need to be internal got hidden; public aspects got captured in slim interfaces
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
426 
diff
changeset
 | 
545 thisRevPool = new IdentityPool<Nodeid>(); | 
| 
312
 
f9f3e9b67ccc
Facilitate cancellation and progress reporting in changelog and manifest iterations
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
304 
diff
changeset
 | 
546 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
 | 
547 } | 
| 
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
 | 
548 | 
| 
628
 
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
608 
diff
changeset
 | 
549 public void next(int revisionNumber, int actualLen, int baseRevision, int linkRevision, int parent1Revision, int parent2Revision, byte[] nodeid, DataAccess da) throws HgRuntimeException { | 
| 
196
 
e2115da4cf6a
Pool objects to avoid memory polution with duplicates
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
157 
diff
changeset
 | 
550 try { | 
| 
312
 
f9f3e9b67ccc
Facilitate cancellation and progress reporting in changelog and manifest iterations
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
304 
diff
changeset
 | 
551 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
 | 
552 iterateControl.stop(); | 
| 
 
f9f3e9b67ccc
Facilitate cancellation and progress reporting in changelog and manifest iterations
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
304 
diff
changeset
 | 
553 return; | 
| 
 
f9f3e9b67ccc
Facilitate cancellation and progress reporting in changelog and manifest iterations
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
304 
diff
changeset
 | 
554 } | 
| 
372
 
155c1893bda4
Issue 22: UnsupportedOperationException on empty manifest entry
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
368 
diff
changeset
 | 
555 if (!da.isEmpty()) { | 
| 
 
155c1893bda4
Issue 22: UnsupportedOperationException on empty manifest entry
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
368 
diff
changeset
 | 
556 // 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
 | 
557 Path fname = null; | 
| 
 
155c1893bda4
Issue 22: UnsupportedOperationException on empty manifest entry
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
368 
diff
changeset
 | 
558 Flags flags = null; | 
| 
 
155c1893bda4
Issue 22: UnsupportedOperationException on empty manifest entry
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
368 
diff
changeset
 | 
559 Nodeid nid = null; | 
| 
 
155c1893bda4
Issue 22: UnsupportedOperationException on empty manifest entry
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
368 
diff
changeset
 | 
560 int i; | 
| 
 
155c1893bda4
Issue 22: UnsupportedOperationException on empty manifest entry
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
368 
diff
changeset
 | 
561 byte[] data = da.byteArray(); | 
| 
 
155c1893bda4
Issue 22: UnsupportedOperationException on empty manifest entry
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
368 
diff
changeset
 | 
562 for (i = 0; i < actualLen; i++) { | 
| 
 
155c1893bda4
Issue 22: UnsupportedOperationException on empty manifest entry
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
368 
diff
changeset
 | 
563 int x = i; | 
| 
 
155c1893bda4
Issue 22: UnsupportedOperationException on empty manifest entry
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
368 
diff
changeset
 | 
564 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
 | 
565 if (fname == null && data[i] == 0) { | 
| 
571
 
e4ee4bf4c7d0
Let session context control creation of Path instances
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
550 
diff
changeset
 | 
566 PathProxy px = fnamePool.unify(new PathProxy(data, x, i - x)); | 
| 
372
 
155c1893bda4
Issue 22: UnsupportedOperationException on empty manifest entry
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
368 
diff
changeset
 | 
567 // 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
 | 
568 // 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
 | 
569 fname = px.freeze(); | 
| 
 
155c1893bda4
Issue 22: UnsupportedOperationException on empty manifest entry
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
368 
diff
changeset
 | 
570 x = i+1; | 
| 
 
155c1893bda4
Issue 22: UnsupportedOperationException on empty manifest entry
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
368 
diff
changeset
 | 
571 } | 
| 
196
 
e2115da4cf6a
Pool objects to avoid memory polution with duplicates
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
157 
diff
changeset
 | 
572 } | 
| 
372
 
155c1893bda4
Issue 22: UnsupportedOperationException on empty manifest entry
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
368 
diff
changeset
 | 
573 if (i < actualLen) { | 
| 
 
155c1893bda4
Issue 22: UnsupportedOperationException on empty manifest entry
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
368 
diff
changeset
 | 
574 assert data[i] == '\n'; | 
| 
 
155c1893bda4
Issue 22: UnsupportedOperationException on empty manifest entry
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
368 
diff
changeset
 | 
575 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
 | 
576 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
 | 
577 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
 | 
578 Nodeid cached = nodeidPool.unify(nid); | 
| 
 
155c1893bda4
Issue 22: UnsupportedOperationException on empty manifest entry
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
368 
diff
changeset
 | 
579 if (cached == nid) { | 
| 
 
155c1893bda4
Issue 22: UnsupportedOperationException on empty manifest entry
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
368 
diff
changeset
 | 
580 // 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
 | 
581 nodeidLookupBuffer = new byte[20]; | 
| 
 
155c1893bda4
Issue 22: UnsupportedOperationException on empty manifest entry
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
368 
diff
changeset
 | 
582 } else { | 
| 
 
155c1893bda4
Issue 22: UnsupportedOperationException on empty manifest entry
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
368 
diff
changeset
 | 
583 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
 | 
584 } // 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
 | 
585 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
 | 
586 if (nodeidLen + x < i) { | 
| 
 
155c1893bda4
Issue 22: UnsupportedOperationException on empty manifest entry
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
368 
diff
changeset
 | 
587 // '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
 | 
588 // 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
 | 
589 // 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
 | 
590 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
 | 
591 } else { | 
| 
415
 
ee8264d80747
Explicit constant for regular file flags, access to flags for a given file revision
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
414 
diff
changeset
 | 
592 flags = Flags.RegularFile; | 
| 
372
 
155c1893bda4
Issue 22: UnsupportedOperationException on empty manifest entry
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
368 
diff
changeset
 | 
593 } | 
| 
424
 
6437d261048a
Deprecated code removed
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
423 
diff
changeset
 | 
594 boolean good2go = inspector.next(nid, fname, flags); | 
| 
372
 
155c1893bda4
Issue 22: UnsupportedOperationException on empty manifest entry
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
368 
diff
changeset
 | 
595 if (!good2go) { | 
| 
 
155c1893bda4
Issue 22: UnsupportedOperationException on empty manifest entry
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
368 
diff
changeset
 | 
596 iterateControl.stop(); | 
| 
 
155c1893bda4
Issue 22: UnsupportedOperationException on empty manifest entry
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
368 
diff
changeset
 | 
597 return; | 
| 
 
155c1893bda4
Issue 22: UnsupportedOperationException on empty manifest entry
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
368 
diff
changeset
 | 
598 } | 
| 
 
155c1893bda4
Issue 22: UnsupportedOperationException on empty manifest entry
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
368 
diff
changeset
 | 
599 } | 
| 
 
155c1893bda4
Issue 22: UnsupportedOperationException on empty manifest entry
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
368 
diff
changeset
 | 
600 nid = null; | 
| 
 
155c1893bda4
Issue 22: UnsupportedOperationException on empty manifest entry
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
368 
diff
changeset
 | 
601 fname = null; | 
| 
 
155c1893bda4
Issue 22: UnsupportedOperationException on empty manifest entry
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
368 
diff
changeset
 | 
602 flags = null; | 
| 
196
 
e2115da4cf6a
Pool objects to avoid memory polution with duplicates
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
157 
diff
changeset
 | 
603 } | 
| 
 
e2115da4cf6a
Pool objects to avoid memory polution with duplicates
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
157 
diff
changeset
 | 
604 } | 
| 
312
 
f9f3e9b67ccc
Facilitate cancellation and progress reporting in changelog and manifest iterations
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
304 
diff
changeset
 | 
605 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
 | 
606 iterateControl.stop(); | 
| 
 
f9f3e9b67ccc
Facilitate cancellation and progress reporting in changelog and manifest iterations
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
304 
diff
changeset
 | 
607 return; | 
| 
 
f9f3e9b67ccc
Facilitate cancellation and progress reporting in changelog and manifest iterations
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
304 
diff
changeset
 | 
608 } | 
| 
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
 | 
609 // | 
| 
 
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
 | 
610 // 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
 | 
611 // (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
 | 
612 // 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
 | 
613 nodeidPool.clear(); | 
| 
431
 
12f668401613
FIXMEs: awkward API refactored, what need to be internal got hidden; public aspects got captured in slim interfaces
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
426 
diff
changeset
 | 
614 IdentityPool<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
 | 
615 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
 | 
616 thisRevPool = t; | 
| 
313
 
c1e3c18fd2f2
Test manifest cancellation
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
312 
diff
changeset
 | 
617 iterateControl.checkCancelled(); | 
| 
312
 
f9f3e9b67ccc
Facilitate cancellation and progress reporting in changelog and manifest iterations
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
304 
diff
changeset
 | 
618 progressHelper.worked(1); | 
| 
196
 
e2115da4cf6a
Pool objects to avoid memory polution with duplicates
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
157 
diff
changeset
 | 
619 } catch (IOException ex) { | 
| 
423
 
9c9c442b5f2e
Major refactoring of exception handling. Low-level API uses RuntimeExceptions, while checked are left for higher level
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
421 
diff
changeset
 | 
620 throw new HgInvalidControlFileException("Failed reading manifest", ex, null).setRevisionIndex(revisionNumber); | 
| 
196
 
e2115da4cf6a
Pool objects to avoid memory polution with duplicates
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
157 
diff
changeset
 | 
621 } | 
| 
 
e2115da4cf6a
Pool objects to avoid memory polution with duplicates
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
157 
diff
changeset
 | 
622 } | 
| 
312
 
f9f3e9b67ccc
Facilitate cancellation and progress reporting in changelog and manifest iterations
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
304 
diff
changeset
 | 
623 | 
| 
 
f9f3e9b67ccc
Facilitate cancellation and progress reporting in changelog and manifest iterations
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
304 
diff
changeset
 | 
624 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
 | 
625 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
 | 
626 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
 | 
627 progressHelper.start(count); | 
| 
 
f9f3e9b67ccc
Facilitate cancellation and progress reporting in changelog and manifest iterations
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
304 
diff
changeset
 | 
628 } | 
| 
 
f9f3e9b67ccc
Facilitate cancellation and progress reporting in changelog and manifest iterations
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
304 
diff
changeset
 | 
629 | 
| 
 
f9f3e9b67ccc
Facilitate cancellation and progress reporting in changelog and manifest iterations
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
304 
diff
changeset
 | 
630 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
 | 
631 progressHelper.done(); | 
| 
 
f9f3e9b67ccc
Facilitate cancellation and progress reporting in changelog and manifest iterations
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
304 
diff
changeset
 | 
632 } | 
| 
196
 
e2115da4cf6a
Pool objects to avoid memory polution with duplicates
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
157 
diff
changeset
 | 
633 } | 
| 
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
 | 
634 | 
| 
600
 
46f29b73e51e
Utilize RevisionLookup to speed-up getRevisionIndex of both manifest and changelog
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
598 
diff
changeset
 | 
635 private class RevisionMapper implements RevlogStream.Inspector, Lifecycle { | 
| 
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
 | 
636 | 
| 
403
 
2747b0723867
FIXMEs: work on exceptions and javadoc
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
390 
diff
changeset
 | 
637 private final int changelogRevisionCount; | 
| 
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
 | 
638 private int[] changelog2manifest; | 
| 
600
 
46f29b73e51e
Utilize RevisionLookup to speed-up getRevisionIndex of both manifest and changelog
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
598 
diff
changeset
 | 
639 RevisionLookup manifestNodeids; | 
| 
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
 | 
640 | 
| 
628
 
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
608 
diff
changeset
 | 
641 private RevisionMapper(boolean useOwnRevisionLookup) throws HgRuntimeException { | 
| 
600
 
46f29b73e51e
Utilize RevisionLookup to speed-up getRevisionIndex of both manifest and changelog
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
598 
diff
changeset
 | 
642 changelogRevisionCount = HgManifest.this.getRepo().getChangelog().getRevisionCount(); | 
| 
 
46f29b73e51e
Utilize RevisionLookup to speed-up getRevisionIndex of both manifest and changelog
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
598 
diff
changeset
 | 
643 if (useOwnRevisionLookup) { | 
| 
 
46f29b73e51e
Utilize RevisionLookup to speed-up getRevisionIndex of both manifest and changelog
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
598 
diff
changeset
 | 
644 manifestNodeids = new RevisionLookup(HgManifest.this.content); | 
| 
 
46f29b73e51e
Utilize RevisionLookup to speed-up getRevisionIndex of both manifest and changelog
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
598 
diff
changeset
 | 
645 } | 
| 
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
 | 
646 } | 
| 
600
 
46f29b73e51e
Utilize RevisionLookup to speed-up getRevisionIndex of both manifest and changelog
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
598 
diff
changeset
 | 
647 | 
| 
403
 
2747b0723867
FIXMEs: work on exceptions and javadoc
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
390 
diff
changeset
 | 
648 /** | 
| 
 
2747b0723867
FIXMEs: work on exceptions and javadoc
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
390 
diff
changeset
 | 
649 * Get index of manifest revision that corresponds to specified changeset | 
| 
 
2747b0723867
FIXMEs: work on exceptions and javadoc
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
390 
diff
changeset
 | 
650 * @param changesetRevisionIndex non-negative index of changelog revision, or {@link HgRepository#TIP} | 
| 
 
2747b0723867
FIXMEs: work on exceptions and javadoc
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
390 
diff
changeset
 | 
651 * @return index of manifest revision, or {@link HgRepository#BAD_REVISION} if changeset doesn't reference a valid manifest | 
| 
 
2747b0723867
FIXMEs: work on exceptions and javadoc
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
390 
diff
changeset
 | 
652 * @throws HgInvalidRevisionException if method argument specifies non-existent revision index | 
| 
 
2747b0723867
FIXMEs: work on exceptions and javadoc
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
390 
diff
changeset
 | 
653 */ | 
| 
 
2747b0723867
FIXMEs: work on exceptions and javadoc
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
390 
diff
changeset
 | 
654 public int at(int changesetRevisionIndex) throws HgInvalidRevisionException { | 
| 
 
2747b0723867
FIXMEs: work on exceptions and javadoc
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
390 
diff
changeset
 | 
655 if (changesetRevisionIndex == TIP) { | 
| 
 
2747b0723867
FIXMEs: work on exceptions and javadoc
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
390 
diff
changeset
 | 
656 changesetRevisionIndex = changelogRevisionCount - 1; | 
| 
 
2747b0723867
FIXMEs: work on exceptions and javadoc
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
390 
diff
changeset
 | 
657 } | 
| 
 
2747b0723867
FIXMEs: work on exceptions and javadoc
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
390 
diff
changeset
 | 
658 if (changesetRevisionIndex >= changelogRevisionCount) { | 
| 
 
2747b0723867
FIXMEs: work on exceptions and javadoc
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
390 
diff
changeset
 | 
659 throw new HgInvalidRevisionException(changesetRevisionIndex); | 
| 
257
 
f39fb6b3cc76
Handle revision constants correctly
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
254 
diff
changeset
 | 
660 } | 
| 
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
 | 
661 if (changelog2manifest != null) { | 
| 
403
 
2747b0723867
FIXMEs: work on exceptions and javadoc
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
390 
diff
changeset
 | 
662 return changelog2manifest[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
 | 
663 } | 
| 
403
 
2747b0723867
FIXMEs: work on exceptions and javadoc
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
390 
diff
changeset
 | 
664 return 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
 | 
665 } | 
| 
 
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
 | 
666 | 
| 
600
 
46f29b73e51e
Utilize RevisionLookup to speed-up getRevisionIndex of both manifest and changelog
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
598 
diff
changeset
 | 
667 // XXX can be replaced with Revlog.RevisionInspector, but I don't want Nodeid instances | 
| 
638
 
2f1cd1c26de5
AIOOBE in HgManifest.RevisionMapper: provide more details about exception context. Create lock file atomically. Picked from changeset 8a5cdcb27b8f
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
583 
diff
changeset
 | 
668 public void next(int revisionNumber, int actualLen, int baseRevision, int linkRevision, int parent1Revision, int parent2Revision, byte[] nodeid, DataAccess data) throws HgInvalidRevisionException { | 
| 
 
2f1cd1c26de5
AIOOBE in HgManifest.RevisionMapper: provide more details about exception context. Create lock file atomically. Picked from changeset 8a5cdcb27b8f
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
583 
diff
changeset
 | 
669 if (linkRevision >= changelogRevisionCount) { | 
| 
631
 
8a5cdcb27b8f
AIOOBE in HgManifest.RevisionMapper. Provide more details about exception context. Create lock file atomically. Test concurrent pull-rebase and read
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
628 
diff
changeset
 | 
670 String storeLock = HgManifest.this.getRepo().getStoreLock().readLockInfo(); | 
| 
638
 
2f1cd1c26de5
AIOOBE in HgManifest.RevisionMapper: provide more details about exception context. Create lock file atomically. Picked from changeset 8a5cdcb27b8f
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
583 
diff
changeset
 | 
671 String message = String.format("Manifest revision %d references changeset %d, which is beyond known scope [0..%d). Lock: %s", revisionNumber, linkRevision, changelogRevisionCount, storeLock); | 
| 
 
2f1cd1c26de5
AIOOBE in HgManifest.RevisionMapper: provide more details about exception context. Create lock file atomically. Picked from changeset 8a5cdcb27b8f
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
583 
diff
changeset
 | 
672 throw new HgInvalidRevisionException(message, null, linkRevision); | 
| 
 
2f1cd1c26de5
AIOOBE in HgManifest.RevisionMapper: provide more details about exception context. Create lock file atomically. Picked from changeset 8a5cdcb27b8f
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
583 
diff
changeset
 | 
673 } | 
| 
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
 | 
674 if (changelog2manifest != null) { | 
| 
220
 
8de327242aa0
Basic information about branches
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
218 
diff
changeset
 | 
675 // 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
 | 
676 // 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
 | 
677 // changeset records one and only one manifest nodeid | 
| 
403
 
2747b0723867
FIXMEs: work on exceptions and javadoc
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
390 
diff
changeset
 | 
678 assert changelog2manifest[linkRevision] == BAD_REVISION : 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
 | 
679 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
 | 
680 } 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
 | 
681 if (revisionNumber != linkRevision) { | 
| 
403
 
2747b0723867
FIXMEs: work on exceptions and javadoc
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
390 
diff
changeset
 | 
682 changelog2manifest = new int[changelogRevisionCount]; | 
| 
 
2747b0723867
FIXMEs: work on exceptions and javadoc
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
390 
diff
changeset
 | 
683 Arrays.fill(changelog2manifest, 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
 | 
684 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
 | 
685 ; | 
| 
 
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
 | 
686 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
 | 
687 } | 
| 
 
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
 | 
688 } | 
| 
600
 
46f29b73e51e
Utilize RevisionLookup to speed-up getRevisionIndex of both manifest and changelog
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
598 
diff
changeset
 | 
689 if (manifestNodeids != null) { | 
| 
 
46f29b73e51e
Utilize RevisionLookup to speed-up getRevisionIndex of both manifest and changelog
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
598 
diff
changeset
 | 
690 manifestNodeids.next(revisionNumber, nodeid); | 
| 
 
46f29b73e51e
Utilize RevisionLookup to speed-up getRevisionIndex of both manifest and changelog
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
598 
diff
changeset
 | 
691 } | 
| 
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
 | 
692 } | 
| 
 
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
 | 
693 | 
| 
 
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
 | 
694 public void start(int count, Callback callback, Object token) { | 
| 
403
 
2747b0723867
FIXMEs: work on exceptions and javadoc
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
390 
diff
changeset
 | 
695 if (count != changelogRevisionCount) { | 
| 
 
2747b0723867
FIXMEs: work on exceptions and javadoc
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
390 
diff
changeset
 | 
696 assert count < changelogRevisionCount; // no idea what to do if manifest has more revisions than changelog | 
| 
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
 | 
697 // 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
 | 
698 // 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
 | 
699 // 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
 | 
700 // in cpython repo are numbered makes me think aforementioned way) | 
| 
403
 
2747b0723867
FIXMEs: work on exceptions and javadoc
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
390 
diff
changeset
 | 
701 changelog2manifest = new int[changelogRevisionCount]; | 
| 
 
2747b0723867
FIXMEs: work on exceptions and javadoc
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
390 
diff
changeset
 | 
702 Arrays.fill(changelog2manifest, 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
 | 
703 } | 
| 
600
 
46f29b73e51e
Utilize RevisionLookup to speed-up getRevisionIndex of both manifest and changelog
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
598 
diff
changeset
 | 
704 if (manifestNodeids != null) { | 
| 
 
46f29b73e51e
Utilize RevisionLookup to speed-up getRevisionIndex of both manifest and changelog
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
598 
diff
changeset
 | 
705 manifestNodeids.prepare(count); | 
| 
 
46f29b73e51e
Utilize RevisionLookup to speed-up getRevisionIndex of both manifest and changelog
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
598 
diff
changeset
 | 
706 } | 
| 
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
 | 
707 } | 
| 
 
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
 | 
708 | 
| 
 
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
 | 
709 public void finish(Object token) { | 
| 
600
 
46f29b73e51e
Utilize RevisionLookup to speed-up getRevisionIndex of both manifest and changelog
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
598 
diff
changeset
 | 
710 // it's not a nice idea to fix changesets that reuse existing manifest entries from inside | 
| 
 
46f29b73e51e
Utilize RevisionLookup to speed-up getRevisionIndex of both manifest and changelog
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
598 
diff
changeset
 | 
711 // #finish, as the manifest read operation is not complete at the moment. | 
| 
 
46f29b73e51e
Utilize RevisionLookup to speed-up getRevisionIndex of both manifest and changelog
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
598 
diff
changeset
 | 
712 } | 
| 
 
46f29b73e51e
Utilize RevisionLookup to speed-up getRevisionIndex of both manifest and changelog
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
598 
diff
changeset
 | 
713 | 
| 
628
 
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
608 
diff
changeset
 | 
714 public void fixReusedManifests() throws HgRuntimeException { | 
| 
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
 | 
715 if (changelog2manifest == null) { | 
| 
600
 
46f29b73e51e
Utilize RevisionLookup to speed-up getRevisionIndex of both manifest and changelog
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
598 
diff
changeset
 | 
716 // direct, 1-1 mapping of changeset indexes to manifest | 
| 
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
 | 
717 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
 | 
718 } | 
| 
 
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
 | 
719 // I assume there'd be not too many revisions we don't know manifest of | 
| 
597
 
c895b5556937
Wrap manifest revision map completion into single file access
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
583 
diff
changeset
 | 
720 IntVector undefinedChangelogRevision = new IntVector(); | 
| 
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
 | 
721 for (int i = 0; i < changelog2manifest.length; i++) { | 
| 
403
 
2747b0723867
FIXMEs: work on exceptions and javadoc
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
390 
diff
changeset
 | 
722 if (changelog2manifest[i] == 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
 | 
723 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
 | 
724 } | 
| 
 
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
 | 
725 } | 
| 
597
 
c895b5556937
Wrap manifest revision map completion into single file access
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
583 
diff
changeset
 | 
726 if (undefinedChangelogRevision.size() > 0) { | 
| 
 
c895b5556937
Wrap manifest revision map completion into single file access
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
583 
diff
changeset
 | 
727 final IntMap<Nodeid> missingCsetToManifest = new IntMap<Nodeid>(undefinedChangelogRevision.size()); | 
| 
 
c895b5556937
Wrap manifest revision map completion into single file access
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
583 
diff
changeset
 | 
728 int[] undefinedClogRevs = undefinedChangelogRevision.toArray(); | 
| 
 
c895b5556937
Wrap manifest revision map completion into single file access
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
583 
diff
changeset
 | 
729 // undefinedChangelogRevision is sorted by the nature it's created | 
| 
600
 
46f29b73e51e
Utilize RevisionLookup to speed-up getRevisionIndex of both manifest and changelog
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
598 
diff
changeset
 | 
730 HgManifest.this.getRepo().getChangelog().rangeInternal(new HgChangelog.Inspector() { | 
| 
597
 
c895b5556937
Wrap manifest revision map completion into single file access
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
583 
diff
changeset
 | 
731 | 
| 
 
c895b5556937
Wrap manifest revision map completion into single file access
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
583 
diff
changeset
 | 
732 public void next(int revisionIndex, Nodeid nodeid, RawChangeset cset) { | 
| 
 
c895b5556937
Wrap manifest revision map completion into single file access
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
583 
diff
changeset
 | 
733 missingCsetToManifest.put(revisionIndex, cset.manifest()); | 
| 
 
c895b5556937
Wrap manifest revision map completion into single file access
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
583 
diff
changeset
 | 
734 } | 
| 
 
c895b5556937
Wrap manifest revision map completion into single file access
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
583 
diff
changeset
 | 
735 }, undefinedClogRevs); | 
| 
 
c895b5556937
Wrap manifest revision map completion into single file access
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
583 
diff
changeset
 | 
736 assert missingCsetToManifest.size() == undefinedChangelogRevision.size(); | 
| 
 
c895b5556937
Wrap manifest revision map completion into single file access
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
583 
diff
changeset
 | 
737 for (int u : undefinedClogRevs) { | 
| 
 
c895b5556937
Wrap manifest revision map completion into single file access
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
583 
diff
changeset
 | 
738 Nodeid manifest = missingCsetToManifest.get(u); | 
| 
 
c895b5556937
Wrap manifest revision map completion into single file access
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
583 
diff
changeset
 | 
739 if (manifest == null || manifest.isNull()) { | 
| 
600
 
46f29b73e51e
Utilize RevisionLookup to speed-up getRevisionIndex of both manifest and changelog
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
598 
diff
changeset
 | 
740 HgManifest.this.getRepo().getSessionContext().getLog().dump(getClass(), Severity.Warn, "Changeset %d has no associated manifest entry", u); | 
| 
 
46f29b73e51e
Utilize RevisionLookup to speed-up getRevisionIndex of both manifest and changelog
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
598 
diff
changeset
 | 
741 // keep BAD_REVISION in the changelog2manifest map. | 
| 
598
 
d29d9dc6c128
Utilize the fact nodeids are very different and are read anyway to speed up reverse lookup
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
597 
diff
changeset
 | 
742 continue; | 
| 
 
d29d9dc6c128
Utilize the fact nodeids are very different and are read anyway to speed up reverse lookup
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
597 
diff
changeset
 | 
743 } | 
| 
600
 
46f29b73e51e
Utilize RevisionLookup to speed-up getRevisionIndex of both manifest and changelog
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
598 
diff
changeset
 | 
744 if (manifestNodeids != null) { | 
| 
 
46f29b73e51e
Utilize RevisionLookup to speed-up getRevisionIndex of both manifest and changelog
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
598 
diff
changeset
 | 
745 int manifestRevIndex = manifestNodeids.findIndex(manifest); | 
| 
 
46f29b73e51e
Utilize RevisionLookup to speed-up getRevisionIndex of both manifest and changelog
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
598 
diff
changeset
 | 
746 // mimic HgManifest#getRevisionIndex() to keep behavior the same | 
| 
 
46f29b73e51e
Utilize RevisionLookup to speed-up getRevisionIndex of both manifest and changelog
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
598 
diff
changeset
 | 
747 if (manifestRevIndex == BAD_REVISION) { | 
| 
 
46f29b73e51e
Utilize RevisionLookup to speed-up getRevisionIndex of both manifest and changelog
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
598 
diff
changeset
 | 
748 throw new HgInvalidRevisionException(String.format("Can't find index of revision %s", manifest.shortNotation()), manifest, null); | 
| 
598
 
d29d9dc6c128
Utilize the fact nodeids are very different and are read anyway to speed up reverse lookup
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
597 
diff
changeset
 | 
749 } | 
| 
600
 
46f29b73e51e
Utilize RevisionLookup to speed-up getRevisionIndex of both manifest and changelog
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
598 
diff
changeset
 | 
750 changelog2manifest[u] = manifestRevIndex; | 
| 
 
46f29b73e51e
Utilize RevisionLookup to speed-up getRevisionIndex of both manifest and changelog
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
598 
diff
changeset
 | 
751 } else { | 
| 
 
46f29b73e51e
Utilize RevisionLookup to speed-up getRevisionIndex of both manifest and changelog
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
598 
diff
changeset
 | 
752 changelog2manifest[u] = HgManifest.this.getRevisionIndex(manifest); | 
| 
597
 
c895b5556937
Wrap manifest revision map completion into single file access
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
583 
diff
changeset
 | 
753 } | 
| 
354
 
5f9073eabf06
Propagate errors with exceptions up to a end client
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
326 
diff
changeset
 | 
754 } | 
| 
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
 | 
755 } | 
| 
 
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
 | 
756 } | 
| 
 
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
 | 
757 } | 
| 
415
 
ee8264d80747
Explicit constant for regular file flags, access to flags for a given file revision
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
414 
diff
changeset
 | 
758 | 
| 
 
ee8264d80747
Explicit constant for regular file flags, access to flags for a given file revision
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
414 
diff
changeset
 | 
759 /** | 
| 
 
ee8264d80747
Explicit constant for regular file flags, access to flags for a given file revision
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
414 
diff
changeset
 | 
760 * Look up specified file in possibly multiple manifest revisions, collect file revision and flags. | 
| 
 
ee8264d80747
Explicit constant for regular file flags, access to flags for a given file revision
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
414 
diff
changeset
 | 
761 */ | 
| 
 
ee8264d80747
Explicit constant for regular file flags, access to flags for a given file revision
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
414 
diff
changeset
 | 
762 private static class FileLookupInspector implements RevlogStream.Inspector { | 
| 
 
ee8264d80747
Explicit constant for regular file flags, access to flags for a given file revision
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
414 
diff
changeset
 | 
763 | 
| 
426
 
063b0663495a
HgManifest#getFileRevisions refactored into #walkFileRevisions to match pattern throught rest of the library
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
425 
diff
changeset
 | 
764 private final Path filename; | 
| 
415
 
ee8264d80747
Explicit constant for regular file flags, access to flags for a given file revision
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
414 
diff
changeset
 | 
765 private final byte[] filenameAsBytes; | 
| 
 
ee8264d80747
Explicit constant for regular file flags, access to flags for a given file revision
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
414 
diff
changeset
 | 
766 private final IntMap<Nodeid> csetIndex2FileRev; | 
| 
 
ee8264d80747
Explicit constant for regular file flags, access to flags for a given file revision
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
414 
diff
changeset
 | 
767 private final IntMap<Flags> csetIndex2Flags; | 
| 
426
 
063b0663495a
HgManifest#getFileRevisions refactored into #walkFileRevisions to match pattern throught rest of the library
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
425 
diff
changeset
 | 
768 private final Inspector delegate; | 
| 
415
 
ee8264d80747
Explicit constant for regular file flags, access to flags for a given file revision
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
414 
diff
changeset
 | 
769 | 
| 
 
ee8264d80747
Explicit constant for regular file flags, access to flags for a given file revision
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
414 
diff
changeset
 | 
770 public FileLookupInspector(EncodingHelper eh, Path fileToLookUp, IntMap<Nodeid> csetIndex2FileRevMap, IntMap<Flags> csetIndex2FlagsMap) { | 
| 
 
ee8264d80747
Explicit constant for regular file flags, access to flags for a given file revision
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
414 
diff
changeset
 | 
771 assert fileToLookUp != null; | 
| 
 
ee8264d80747
Explicit constant for regular file flags, access to flags for a given file revision
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
414 
diff
changeset
 | 
772 // need at least one map for the inspector to make any sense | 
| 
 
ee8264d80747
Explicit constant for regular file flags, access to flags for a given file revision
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
414 
diff
changeset
 | 
773 assert csetIndex2FileRevMap != null || csetIndex2FlagsMap != null; | 
| 
426
 
063b0663495a
HgManifest#getFileRevisions refactored into #walkFileRevisions to match pattern throught rest of the library
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
425 
diff
changeset
 | 
774 filename = fileToLookUp; | 
| 
 
063b0663495a
HgManifest#getFileRevisions refactored into #walkFileRevisions to match pattern throught rest of the library
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
425 
diff
changeset
 | 
775 filenameAsBytes = eh.toManifest(fileToLookUp.toString()); | 
| 
 
063b0663495a
HgManifest#getFileRevisions refactored into #walkFileRevisions to match pattern throught rest of the library
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
425 
diff
changeset
 | 
776 delegate = null; | 
| 
415
 
ee8264d80747
Explicit constant for regular file flags, access to flags for a given file revision
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
414 
diff
changeset
 | 
777 csetIndex2FileRev = csetIndex2FileRevMap; | 
| 
 
ee8264d80747
Explicit constant for regular file flags, access to flags for a given file revision
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
414 
diff
changeset
 | 
778 csetIndex2Flags = csetIndex2FlagsMap; | 
| 
426
 
063b0663495a
HgManifest#getFileRevisions refactored into #walkFileRevisions to match pattern throught rest of the library
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
425 
diff
changeset
 | 
779 } | 
| 
 
063b0663495a
HgManifest#getFileRevisions refactored into #walkFileRevisions to match pattern throught rest of the library
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
425 
diff
changeset
 | 
780 | 
| 
 
063b0663495a
HgManifest#getFileRevisions refactored into #walkFileRevisions to match pattern throught rest of the library
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
425 
diff
changeset
 | 
781 public FileLookupInspector(EncodingHelper eh, Path fileToLookUp, Inspector delegateInspector) { | 
| 
 
063b0663495a
HgManifest#getFileRevisions refactored into #walkFileRevisions to match pattern throught rest of the library
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
425 
diff
changeset
 | 
782 assert fileToLookUp != null; | 
| 
 
063b0663495a
HgManifest#getFileRevisions refactored into #walkFileRevisions to match pattern throught rest of the library
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
425 
diff
changeset
 | 
783 assert delegateInspector != null; | 
| 
 
063b0663495a
HgManifest#getFileRevisions refactored into #walkFileRevisions to match pattern throught rest of the library
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
425 
diff
changeset
 | 
784 filename = fileToLookUp; | 
| 
415
 
ee8264d80747
Explicit constant for regular file flags, access to flags for a given file revision
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
414 
diff
changeset
 | 
785 filenameAsBytes = eh.toManifest(fileToLookUp.toString()); | 
| 
426
 
063b0663495a
HgManifest#getFileRevisions refactored into #walkFileRevisions to match pattern throught rest of the library
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
425 
diff
changeset
 | 
786 delegate = delegateInspector; | 
| 
 
063b0663495a
HgManifest#getFileRevisions refactored into #walkFileRevisions to match pattern throught rest of the library
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
425 
diff
changeset
 | 
787 csetIndex2FileRev = null; | 
| 
 
063b0663495a
HgManifest#getFileRevisions refactored into #walkFileRevisions to match pattern throught rest of the library
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
425 
diff
changeset
 | 
788 csetIndex2Flags = null; | 
| 
 
063b0663495a
HgManifest#getFileRevisions refactored into #walkFileRevisions to match pattern throught rest of the library
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
425 
diff
changeset
 | 
789 } | 
| 
 
063b0663495a
HgManifest#getFileRevisions refactored into #walkFileRevisions to match pattern throught rest of the library
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
425 
diff
changeset
 | 
790 | 
| 
628
 
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
608 
diff
changeset
 | 
791 void walk(int manifestRevIndex, RevlogStream content) throws HgRuntimeException { | 
| 
426
 
063b0663495a
HgManifest#getFileRevisions refactored into #walkFileRevisions to match pattern throught rest of the library
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
425 
diff
changeset
 | 
792 content.iterate(manifestRevIndex, manifestRevIndex, true, this); | 
| 
 
063b0663495a
HgManifest#getFileRevisions refactored into #walkFileRevisions to match pattern throught rest of the library
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
425 
diff
changeset
 | 
793 } | 
| 
 
063b0663495a
HgManifest#getFileRevisions refactored into #walkFileRevisions to match pattern throught rest of the library
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
425 
diff
changeset
 | 
794 | 
| 
628
 
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
608 
diff
changeset
 | 
795 void walk(int[] manifestRevIndexes, RevlogStream content) throws HgRuntimeException { | 
| 
426
 
063b0663495a
HgManifest#getFileRevisions refactored into #walkFileRevisions to match pattern throught rest of the library
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
425 
diff
changeset
 | 
796 content.iterate(manifestRevIndexes, true, this); | 
| 
415
 
ee8264d80747
Explicit constant for regular file flags, access to flags for a given file revision
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
414 
diff
changeset
 | 
797 } | 
| 
 
ee8264d80747
Explicit constant for regular file flags, access to flags for a given file revision
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
414 
diff
changeset
 | 
798 | 
| 
628
 
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
608 
diff
changeset
 | 
799 public void next(int revisionNumber, int actualLen, int baseRevision, int linkRevision, int parent1Revision, int parent2Revision, byte[] nodeid, DataAccess data) throws HgRuntimeException { | 
| 
574
 
88afffd39899
Improve memory consumption of HgManifest#getFileRevision(): avoid extra byte[] instances
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
571 
diff
changeset
 | 
800 ByteVector byteVector = new ByteVector(256, 128); // allocate for long paths right away | 
| 
415
 
ee8264d80747
Explicit constant for regular file flags, access to flags for a given file revision
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
414 
diff
changeset
 | 
801 try { | 
| 
 
ee8264d80747
Explicit constant for regular file flags, access to flags for a given file revision
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
414 
diff
changeset
 | 
802 byte b; | 
| 
 
ee8264d80747
Explicit constant for regular file flags, access to flags for a given file revision
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
414 
diff
changeset
 | 
803 while (!data.isEmpty() && (b = data.readByte()) != '\n') { | 
| 
 
ee8264d80747
Explicit constant for regular file flags, access to flags for a given file revision
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
414 
diff
changeset
 | 
804 if (b != 0) { | 
| 
574
 
88afffd39899
Improve memory consumption of HgManifest#getFileRevision(): avoid extra byte[] instances
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
571 
diff
changeset
 | 
805 byteVector.add(b); | 
| 
415
 
ee8264d80747
Explicit constant for regular file flags, access to flags for a given file revision
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
414 
diff
changeset
 | 
806 } else { | 
| 
574
 
88afffd39899
Improve memory consumption of HgManifest#getFileRevision(): avoid extra byte[] instances
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
571 
diff
changeset
 | 
807 if (byteVector.equalsTo(filenameAsBytes)) { | 
| 
426
 
063b0663495a
HgManifest#getFileRevisions refactored into #walkFileRevisions to match pattern throught rest of the library
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
425 
diff
changeset
 | 
808 Nodeid fileRev = null; | 
| 
 
063b0663495a
HgManifest#getFileRevisions refactored into #walkFileRevisions to match pattern throught rest of the library
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
425 
diff
changeset
 | 
809 Flags flags = null; | 
| 
 
063b0663495a
HgManifest#getFileRevisions refactored into #walkFileRevisions to match pattern throught rest of the library
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
425 
diff
changeset
 | 
810 if (csetIndex2FileRev != null || delegate != null) { | 
| 
415
 
ee8264d80747
Explicit constant for regular file flags, access to flags for a given file revision
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
414 
diff
changeset
 | 
811 byte[] nid = new byte[40]; | 
| 
 
ee8264d80747
Explicit constant for regular file flags, access to flags for a given file revision
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
414 
diff
changeset
 | 
812 data.readBytes(nid, 0, 40); | 
| 
426
 
063b0663495a
HgManifest#getFileRevisions refactored into #walkFileRevisions to match pattern throught rest of the library
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
425 
diff
changeset
 | 
813 fileRev = Nodeid.fromAscii(nid, 0, 40); | 
| 
415
 
ee8264d80747
Explicit constant for regular file flags, access to flags for a given file revision
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
414 
diff
changeset
 | 
814 } else { | 
| 
 
ee8264d80747
Explicit constant for regular file flags, access to flags for a given file revision
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
414 
diff
changeset
 | 
815 data.skip(40); | 
| 
 
ee8264d80747
Explicit constant for regular file flags, access to flags for a given file revision
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
414 
diff
changeset
 | 
816 } | 
| 
426
 
063b0663495a
HgManifest#getFileRevisions refactored into #walkFileRevisions to match pattern throught rest of the library
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
425 
diff
changeset
 | 
817 if (csetIndex2Flags != null || delegate != null) { | 
| 
574
 
88afffd39899
Improve memory consumption of HgManifest#getFileRevision(): avoid extra byte[] instances
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
571 
diff
changeset
 | 
818 byteVector.clear(); | 
| 
415
 
ee8264d80747
Explicit constant for regular file flags, access to flags for a given file revision
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
414 
diff
changeset
 | 
819 while (!data.isEmpty() && (b = data.readByte()) != '\n') { | 
| 
574
 
88afffd39899
Improve memory consumption of HgManifest#getFileRevision(): avoid extra byte[] instances
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
571 
diff
changeset
 | 
820 byteVector.add(b); | 
| 
415
 
ee8264d80747
Explicit constant for regular file flags, access to flags for a given file revision
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
414 
diff
changeset
 | 
821 } | 
| 
574
 
88afffd39899
Improve memory consumption of HgManifest#getFileRevision(): avoid extra byte[] instances
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
571 
diff
changeset
 | 
822 if (byteVector.size() == 0) { | 
| 
415
 
ee8264d80747
Explicit constant for regular file flags, access to flags for a given file revision
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
414 
diff
changeset
 | 
823 flags = Flags.RegularFile; | 
| 
 
ee8264d80747
Explicit constant for regular file flags, access to flags for a given file revision
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
414 
diff
changeset
 | 
824 } else { | 
| 
574
 
88afffd39899
Improve memory consumption of HgManifest#getFileRevision(): avoid extra byte[] instances
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
571 
diff
changeset
 | 
825 flags = Flags.parse(byteVector.toByteArray(), 0, byteVector.size()); | 
| 
415
 
ee8264d80747
Explicit constant for regular file flags, access to flags for a given file revision
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
414 
diff
changeset
 | 
826 } | 
| 
426
 
063b0663495a
HgManifest#getFileRevisions refactored into #walkFileRevisions to match pattern throught rest of the library
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
425 
diff
changeset
 | 
827 } | 
| 
 
063b0663495a
HgManifest#getFileRevisions refactored into #walkFileRevisions to match pattern throught rest of the library
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
425 
diff
changeset
 | 
828 if (delegate != null) { | 
| 
 
063b0663495a
HgManifest#getFileRevisions refactored into #walkFileRevisions to match pattern throught rest of the library
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
425 
diff
changeset
 | 
829 assert flags != null; | 
| 
 
063b0663495a
HgManifest#getFileRevisions refactored into #walkFileRevisions to match pattern throught rest of the library
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
425 
diff
changeset
 | 
830 assert fileRev != null; | 
| 
 
063b0663495a
HgManifest#getFileRevisions refactored into #walkFileRevisions to match pattern throught rest of the library
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
425 
diff
changeset
 | 
831 delegate.begin(revisionNumber, Nodeid.fromBinary(nodeid, 0), linkRevision); | 
| 
 
063b0663495a
HgManifest#getFileRevisions refactored into #walkFileRevisions to match pattern throught rest of the library
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
425 
diff
changeset
 | 
832 delegate.next(fileRev, filename, flags); | 
| 
 
063b0663495a
HgManifest#getFileRevisions refactored into #walkFileRevisions to match pattern throught rest of the library
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
425 
diff
changeset
 | 
833 delegate.end(revisionNumber); | 
| 
 
063b0663495a
HgManifest#getFileRevisions refactored into #walkFileRevisions to match pattern throught rest of the library
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
425 
diff
changeset
 | 
834 | 
| 
 
063b0663495a
HgManifest#getFileRevisions refactored into #walkFileRevisions to match pattern throught rest of the library
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
425 
diff
changeset
 | 
835 } else { | 
| 
 
063b0663495a
HgManifest#getFileRevisions refactored into #walkFileRevisions to match pattern throught rest of the library
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
425 
diff
changeset
 | 
836 if (csetIndex2FileRev != null) { | 
| 
 
063b0663495a
HgManifest#getFileRevisions refactored into #walkFileRevisions to match pattern throught rest of the library
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
425 
diff
changeset
 | 
837 csetIndex2FileRev.put(linkRevision, fileRev); | 
| 
 
063b0663495a
HgManifest#getFileRevisions refactored into #walkFileRevisions to match pattern throught rest of the library
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
425 
diff
changeset
 | 
838 } | 
| 
 
063b0663495a
HgManifest#getFileRevisions refactored into #walkFileRevisions to match pattern throught rest of the library
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
425 
diff
changeset
 | 
839 if (csetIndex2Flags != null) { | 
| 
 
063b0663495a
HgManifest#getFileRevisions refactored into #walkFileRevisions to match pattern throught rest of the library
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
425 
diff
changeset
 | 
840 csetIndex2Flags.put(linkRevision, flags); | 
| 
 
063b0663495a
HgManifest#getFileRevisions refactored into #walkFileRevisions to match pattern throught rest of the library
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
425 
diff
changeset
 | 
841 } | 
| 
415
 
ee8264d80747
Explicit constant for regular file flags, access to flags for a given file revision
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
414 
diff
changeset
 | 
842 } | 
| 
 
ee8264d80747
Explicit constant for regular file flags, access to flags for a given file revision
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
414 
diff
changeset
 | 
843 break; | 
| 
 
ee8264d80747
Explicit constant for regular file flags, access to flags for a given file revision
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
414 
diff
changeset
 | 
844 } else { | 
| 
 
ee8264d80747
Explicit constant for regular file flags, access to flags for a given file revision
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
414 
diff
changeset
 | 
845 data.skip(40); | 
| 
 
ee8264d80747
Explicit constant for regular file flags, access to flags for a given file revision
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
414 
diff
changeset
 | 
846 } | 
| 
 
ee8264d80747
Explicit constant for regular file flags, access to flags for a given file revision
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
414 
diff
changeset
 | 
847 // else skip to the end of line | 
| 
 
ee8264d80747
Explicit constant for regular file flags, access to flags for a given file revision
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
414 
diff
changeset
 | 
848 while (!data.isEmpty() && (b = data.readByte()) != '\n') | 
| 
 
ee8264d80747
Explicit constant for regular file flags, access to flags for a given file revision
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
414 
diff
changeset
 | 
849 ; | 
| 
574
 
88afffd39899
Improve memory consumption of HgManifest#getFileRevision(): avoid extra byte[] instances
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
571 
diff
changeset
 | 
850 | 
| 
 
88afffd39899
Improve memory consumption of HgManifest#getFileRevision(): avoid extra byte[] instances
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
571 
diff
changeset
 | 
851 byteVector.clear(); | 
| 
415
 
ee8264d80747
Explicit constant for regular file flags, access to flags for a given file revision
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
414 
diff
changeset
 | 
852 } | 
| 
 
ee8264d80747
Explicit constant for regular file flags, access to flags for a given file revision
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
414 
diff
changeset
 | 
853 } | 
| 
 
ee8264d80747
Explicit constant for regular file flags, access to flags for a given file revision
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
414 
diff
changeset
 | 
854 } catch (IOException ex) { | 
| 
423
 
9c9c442b5f2e
Major refactoring of exception handling. Low-level API uses RuntimeExceptions, while checked are left for higher level
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
421 
diff
changeset
 | 
855 throw new HgInvalidControlFileException("Failed reading manifest", ex, null); | 
| 
415
 
ee8264d80747
Explicit constant for regular file flags, access to flags for a given file revision
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
414 
diff
changeset
 | 
856 } | 
| 
 
ee8264d80747
Explicit constant for regular file flags, access to flags for a given file revision
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
414 
diff
changeset
 | 
857 } | 
| 
 
ee8264d80747
Explicit constant for regular file flags, access to flags for a given file revision
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
414 
diff
changeset
 | 
858 } | 
| 
2
 
08db726a0fb7
Shaping out low-level Hg structures
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
859 } | 
