Mercurial > hg4j
annotate src/org/tmatesoft/hg/repo/HgDirstate.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 | 2f9ed6bcefa2 |
children |
rev | line source |
---|---|
10
382cfe9463db
Dirstate parsing. DataAccess refactored to allow reuse and control over constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
1 /* |
525
0be5be8d57e9
Repository checkout support, first iteration
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
501
diff
changeset
|
2 * Copyright (c) 2010-2013 TMate Software Ltd |
74
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
59
diff
changeset
|
3 * |
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
59
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:
59
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:
59
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:
59
diff
changeset
|
7 * |
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
59
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:
59
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:
59
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:
59
diff
changeset
|
11 * GNU General Public License for more details. |
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
59
diff
changeset
|
12 * |
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
59
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:
59
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:
93
diff
changeset
|
15 * contact TMate Software at support@hg4j.com |
10
382cfe9463db
Dirstate parsing. DataAccess refactored to allow reuse and control over constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
16 */ |
74
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
59
diff
changeset
|
17 package org.tmatesoft.hg.repo; |
10
382cfe9463db
Dirstate parsing. DataAccess refactored to allow reuse and control over constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
18 |
382cfe9463db
Dirstate parsing. DataAccess refactored to allow reuse and control over constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
19 import java.util.Collections; |
293
9774f47d904d
Issue 13: Status reports filenames with case other than in dirstate incorrectly
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
291
diff
changeset
|
20 import java.util.HashMap; |
18
02ee376bee79
status operation against current working directory
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
14
diff
changeset
|
21 import java.util.LinkedHashMap; |
02ee376bee79
status operation against current working directory
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
14
diff
changeset
|
22 import java.util.Map; |
02ee376bee79
status operation against current working directory
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
14
diff
changeset
|
23 import java.util.TreeSet; |
10
382cfe9463db
Dirstate parsing. DataAccess refactored to allow reuse and control over constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
24 |
231
1792b37650f2
Introduced access to conflict resolution information (merge state)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
227
diff
changeset
|
25 import org.tmatesoft.hg.core.Nodeid; |
526
2f9ed6bcefa2
Initial support for Revert command with accompanying minor refactoring
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
525
diff
changeset
|
26 import org.tmatesoft.hg.internal.DirstateReader; |
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
|
27 import org.tmatesoft.hg.internal.Internals; |
284
7232b94f2ae3
HgDirstate shall operate with Path instead of String for file names. Use of Pair instead of array of unspecified length for parents.
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
280
diff
changeset
|
28 import org.tmatesoft.hg.util.Pair; |
141
8248aae33f7d
Adopt FileIterator moving towards WCStatusCollector parameterizing. Improved path handling, move 'em around
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
29 import org.tmatesoft.hg.util.Path; |
291
1483e57541ef
Refactor PathRewrite to accept any char sequence, not only string
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
290
diff
changeset
|
30 import org.tmatesoft.hg.util.PathRewrite; |
74
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
59
diff
changeset
|
31 |
10
382cfe9463db
Dirstate parsing. DataAccess refactored to allow reuse and control over constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
32 |
382cfe9463db
Dirstate parsing. DataAccess refactored to allow reuse and control over constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
33 /** |
382cfe9463db
Dirstate parsing. DataAccess refactored to allow reuse and control over constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
34 * @see http://mercurial.selenic.com/wiki/DirState |
382cfe9463db
Dirstate parsing. DataAccess refactored to allow reuse and control over constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
35 * @see http://mercurial.selenic.com/wiki/FileFormats#dirstate |
74
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
59
diff
changeset
|
36 * |
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
59
diff
changeset
|
37 * @author Artem Tikhomirov |
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
59
diff
changeset
|
38 * @author TMate Software Ltd. |
10
382cfe9463db
Dirstate parsing. DataAccess refactored to allow reuse and control over constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
39 */ |
290
8faad08c709b
Expose dirstate to allow pre-configuration of FileIterators for status collection in particular
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
284
diff
changeset
|
40 public final class HgDirstate /* XXX RepoChangeListener */{ |
8faad08c709b
Expose dirstate to allow pre-configuration of FileIterators for status collection in particular
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
284
diff
changeset
|
41 |
8faad08c709b
Expose dirstate to allow pre-configuration of FileIterators for status collection in particular
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
284
diff
changeset
|
42 public enum EntryKind { |
8faad08c709b
Expose dirstate to allow pre-configuration of FileIterators for status collection in particular
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
284
diff
changeset
|
43 Normal, Added, Removed, Merged, // order is being used in code of this class, don't change unless any use is checked |
8faad08c709b
Expose dirstate to allow pre-configuration of FileIterators for status collection in particular
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
284
diff
changeset
|
44 } |
10
382cfe9463db
Dirstate parsing. DataAccess refactored to allow reuse and control over constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
45 |
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
|
46 private final Internals repo; |
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:
430
diff
changeset
|
47 private final Path.Source pathPool; |
291
1483e57541ef
Refactor PathRewrite to accept any char sequence, not only string
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
290
diff
changeset
|
48 private final PathRewrite canonicalPathRewrite; |
284
7232b94f2ae3
HgDirstate shall operate with Path instead of String for file names. Use of Pair instead of array of unspecified length for parents.
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
280
diff
changeset
|
49 private Map<Path, Record> normal; |
7232b94f2ae3
HgDirstate shall operate with Path instead of String for file names. Use of Pair instead of array of unspecified length for parents.
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
280
diff
changeset
|
50 private Map<Path, Record> added; |
7232b94f2ae3
HgDirstate shall operate with Path instead of String for file names. Use of Pair instead of array of unspecified length for parents.
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
280
diff
changeset
|
51 private Map<Path, Record> removed; |
7232b94f2ae3
HgDirstate shall operate with Path instead of String for file names. Use of Pair instead of array of unspecified length for parents.
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
280
diff
changeset
|
52 private Map<Path, Record> merged; |
293
9774f47d904d
Issue 13: Status reports filenames with case other than in dirstate incorrectly
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
291
diff
changeset
|
53 /* map of canonicalized file names to their originals from dirstate file. |
9774f47d904d
Issue 13: Status reports filenames with case other than in dirstate incorrectly
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
291
diff
changeset
|
54 * Note, only those canonical names that differ from their dirstate counterpart are recorded here |
9774f47d904d
Issue 13: Status reports filenames with case other than in dirstate incorrectly
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
291
diff
changeset
|
55 */ |
9774f47d904d
Issue 13: Status reports filenames with case other than in dirstate incorrectly
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
291
diff
changeset
|
56 private Map<Path, Path> canonical2dirstateName; |
284
7232b94f2ae3
HgDirstate shall operate with Path instead of String for file names. Use of Pair instead of array of unspecified length for parents.
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
280
diff
changeset
|
57 private Pair<Nodeid, Nodeid> parents; |
252
a6d19adc2636
HgRepository.getWorkingCopyBranchName() to retrieve branch associated with working directory
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
231
diff
changeset
|
58 |
291
1483e57541ef
Refactor PathRewrite to accept any char sequence, not only string
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
290
diff
changeset
|
59 // canonicalPath may be null if we don't need to check for names other than in dirstate |
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
|
60 /*package-local*/ HgDirstate(Internals hgRepo, Path.Source pathSource, PathRewrite canonicalPath) { |
252
a6d19adc2636
HgRepository.getWorkingCopyBranchName() to retrieve branch associated with working directory
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
231
diff
changeset
|
61 repo = hgRepo; |
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:
430
diff
changeset
|
62 pathPool = pathSource; |
291
1483e57541ef
Refactor PathRewrite to accept any char sequence, not only string
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
290
diff
changeset
|
63 canonicalPathRewrite = canonicalPath; |
10
382cfe9463db
Dirstate parsing. DataAccess refactored to allow reuse and control over constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
64 } |
382cfe9463db
Dirstate parsing. DataAccess refactored to allow reuse and control over constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
65 |
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
|
66 /*package-local*/ void read() throws HgInvalidControlFileException { |
284
7232b94f2ae3
HgDirstate shall operate with Path instead of String for file names. Use of Pair instead of array of unspecified length for parents.
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
280
diff
changeset
|
67 normal = added = removed = merged = Collections.<Path, Record>emptyMap(); |
371
aa2e589d4e84
NPE in HgWCStatusCollector:initDirstateParentManifest (aka AssertionError in HgDirstate:parents())
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
348
diff
changeset
|
68 parents = new Pair<Nodeid,Nodeid>(Nodeid.NULL, Nodeid.NULL); |
332
72c6eda838a6
NPE in HgDirstate.known() when no dirstate file present
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
295
diff
changeset
|
69 if (canonicalPathRewrite != null) { |
72c6eda838a6
NPE in HgDirstate.known() when no dirstate file present
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
295
diff
changeset
|
70 canonical2dirstateName = new HashMap<Path,Path>(); |
72c6eda838a6
NPE in HgDirstate.known() when no dirstate file present
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
295
diff
changeset
|
71 } else { |
72c6eda838a6
NPE in HgDirstate.known() when no dirstate file present
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
295
diff
changeset
|
72 canonical2dirstateName = Collections.emptyMap(); |
72c6eda838a6
NPE in HgDirstate.known() when no dirstate file present
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
295
diff
changeset
|
73 } |
526
2f9ed6bcefa2
Initial support for Revert command with accompanying minor refactoring
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
525
diff
changeset
|
74 // not sure linked is really needed here, just for ease of debug |
2f9ed6bcefa2
Initial support for Revert command with accompanying minor refactoring
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
525
diff
changeset
|
75 normal = new LinkedHashMap<Path, Record>(); |
2f9ed6bcefa2
Initial support for Revert command with accompanying minor refactoring
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
525
diff
changeset
|
76 added = new LinkedHashMap<Path, Record>(); |
2f9ed6bcefa2
Initial support for Revert command with accompanying minor refactoring
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
525
diff
changeset
|
77 removed = new LinkedHashMap<Path, Record>(); |
2f9ed6bcefa2
Initial support for Revert command with accompanying minor refactoring
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
525
diff
changeset
|
78 merged = new LinkedHashMap<Path, Record>(); |
2f9ed6bcefa2
Initial support for Revert command with accompanying minor refactoring
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
525
diff
changeset
|
79 |
2f9ed6bcefa2
Initial support for Revert command with accompanying minor refactoring
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
525
diff
changeset
|
80 DirstateReader dirstateReader = new DirstateReader(repo, pathPool); |
2f9ed6bcefa2
Initial support for Revert command with accompanying minor refactoring
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
525
diff
changeset
|
81 dirstateReader.readInto(new Inspector() { |
421
fdd7d756dea0
Allow IOException from DataAccess methods for subclasses with non-trivial implementations, to avoid exception dumps when inapropriate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
418
diff
changeset
|
82 |
526
2f9ed6bcefa2
Initial support for Revert command with accompanying minor refactoring
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
525
diff
changeset
|
83 public boolean next(EntryKind kind, Record r) { |
293
9774f47d904d
Issue 13: Status reports filenames with case other than in dirstate incorrectly
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
291
diff
changeset
|
84 if (canonicalPathRewrite != null) { |
526
2f9ed6bcefa2
Initial support for Revert command with accompanying minor refactoring
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
525
diff
changeset
|
85 Path canonicalPath = pathPool.path(canonicalPathRewrite.rewrite(r.name())); |
293
9774f47d904d
Issue 13: Status reports filenames with case other than in dirstate incorrectly
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
291
diff
changeset
|
86 if (canonicalPath != r.name()) { // == as they come from the same pool |
9774f47d904d
Issue 13: Status reports filenames with case other than in dirstate incorrectly
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
291
diff
changeset
|
87 assert !canonical2dirstateName.containsKey(canonicalPath); // otherwise there's already a file with same canonical name |
9774f47d904d
Issue 13: Status reports filenames with case other than in dirstate incorrectly
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
291
diff
changeset
|
88 // which can't happen for case-insensitive file system (or there's erroneous PathRewrite, perhaps doing smth else) |
9774f47d904d
Issue 13: Status reports filenames with case other than in dirstate incorrectly
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
291
diff
changeset
|
89 canonical2dirstateName.put(canonicalPath, r.name()); |
9774f47d904d
Issue 13: Status reports filenames with case other than in dirstate incorrectly
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
291
diff
changeset
|
90 } |
526
2f9ed6bcefa2
Initial support for Revert command with accompanying minor refactoring
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
525
diff
changeset
|
91 if (r.copySource() != null) { |
293
9774f47d904d
Issue 13: Status reports filenames with case other than in dirstate incorrectly
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
291
diff
changeset
|
92 // not sure I need copy origin in the map, I don't seem to use it anywhere, |
9774f47d904d
Issue 13: Status reports filenames with case other than in dirstate incorrectly
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
291
diff
changeset
|
93 // but I guess I'll have to use it some day. |
526
2f9ed6bcefa2
Initial support for Revert command with accompanying minor refactoring
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
525
diff
changeset
|
94 canonicalPath = pathPool.path(canonicalPathRewrite.rewrite(r.copySource())); |
293
9774f47d904d
Issue 13: Status reports filenames with case other than in dirstate incorrectly
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
291
diff
changeset
|
95 if (canonicalPath != r.copySource()) { |
9774f47d904d
Issue 13: Status reports filenames with case other than in dirstate incorrectly
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
291
diff
changeset
|
96 canonical2dirstateName.put(canonicalPath, r.copySource()); |
9774f47d904d
Issue 13: Status reports filenames with case other than in dirstate incorrectly
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
291
diff
changeset
|
97 } |
9774f47d904d
Issue 13: Status reports filenames with case other than in dirstate incorrectly
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
291
diff
changeset
|
98 } |
9774f47d904d
Issue 13: Status reports filenames with case other than in dirstate incorrectly
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
291
diff
changeset
|
99 } |
526
2f9ed6bcefa2
Initial support for Revert command with accompanying minor refactoring
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
525
diff
changeset
|
100 switch (kind) { |
2f9ed6bcefa2
Initial support for Revert command with accompanying minor refactoring
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
525
diff
changeset
|
101 case Normal : normal.put(r.name(), r); break; |
2f9ed6bcefa2
Initial support for Revert command with accompanying minor refactoring
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
525
diff
changeset
|
102 case Added : added.put(r.name(), r); break; |
2f9ed6bcefa2
Initial support for Revert command with accompanying minor refactoring
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
525
diff
changeset
|
103 case Removed : removed.put(r.name(), r); break; |
2f9ed6bcefa2
Initial support for Revert command with accompanying minor refactoring
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
525
diff
changeset
|
104 case Merged : merged.put(r.name1, r); break; |
2f9ed6bcefa2
Initial support for Revert command with accompanying minor refactoring
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
525
diff
changeset
|
105 default: throw new HgInvalidStateException(String.format("Unexpected entry in the dirstate: %s", kind)); |
10
382cfe9463db
Dirstate parsing. DataAccess refactored to allow reuse and control over constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
106 } |
526
2f9ed6bcefa2
Initial support for Revert command with accompanying minor refactoring
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
525
diff
changeset
|
107 return true; |
227
0fd10e5016dd
IOException on empty repository with 40-byte dirstate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
141
diff
changeset
|
108 } |
526
2f9ed6bcefa2
Initial support for Revert command with accompanying minor refactoring
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
525
diff
changeset
|
109 }); |
2f9ed6bcefa2
Initial support for Revert command with accompanying minor refactoring
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
525
diff
changeset
|
110 parents = dirstateReader.parents(); |
10
382cfe9463db
Dirstate parsing. DataAccess refactored to allow reuse and control over constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
111 } |
382cfe9463db
Dirstate parsing. DataAccess refactored to allow reuse and control over constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
112 |
284
7232b94f2ae3
HgDirstate shall operate with Path instead of String for file names. Use of Pair instead of array of unspecified length for parents.
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
280
diff
changeset
|
113 /** |
290
8faad08c709b
Expose dirstate to allow pre-configuration of FileIterators for status collection in particular
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
284
diff
changeset
|
114 * @return pair of working copy parents, with {@link Nodeid#NULL} for missing values. |
284
7232b94f2ae3
HgDirstate shall operate with Path instead of String for file names. Use of Pair instead of array of unspecified length for parents.
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
280
diff
changeset
|
115 */ |
7232b94f2ae3
HgDirstate shall operate with Path instead of String for file names. Use of Pair instead of array of unspecified length for parents.
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
280
diff
changeset
|
116 public Pair<Nodeid,Nodeid> parents() { |
348
a0864b2892cd
Expose errors reading mercurial control files with exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
332
diff
changeset
|
117 assert parents != null; // instance not initialized with #read() |
284
7232b94f2ae3
HgDirstate shall operate with Path instead of String for file names. Use of Pair instead of array of unspecified length for parents.
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
280
diff
changeset
|
118 return parents; |
7232b94f2ae3
HgDirstate shall operate with Path instead of String for file names. Use of Pair instead of array of unspecified length for parents.
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
280
diff
changeset
|
119 } |
7232b94f2ae3
HgDirstate shall operate with Path instead of String for file names. Use of Pair instead of array of unspecified length for parents.
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
280
diff
changeset
|
120 |
18
02ee376bee79
status operation against current working directory
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
14
diff
changeset
|
121 // new, modifiable collection |
284
7232b94f2ae3
HgDirstate shall operate with Path instead of String for file names. Use of Pair instead of array of unspecified length for parents.
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
280
diff
changeset
|
122 /*package-local*/ TreeSet<Path> all() { |
348
a0864b2892cd
Expose errors reading mercurial control files with exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
332
diff
changeset
|
123 assert normal != null; |
284
7232b94f2ae3
HgDirstate shall operate with Path instead of String for file names. Use of Pair instead of array of unspecified length for parents.
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
280
diff
changeset
|
124 TreeSet<Path> rv = new TreeSet<Path>(); |
18
02ee376bee79
status operation against current working directory
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
14
diff
changeset
|
125 @SuppressWarnings("unchecked") |
284
7232b94f2ae3
HgDirstate shall operate with Path instead of String for file names. Use of Pair instead of array of unspecified length for parents.
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
280
diff
changeset
|
126 Map<Path, Record>[] all = new Map[] { normal, added, removed, merged }; |
18
02ee376bee79
status operation against current working directory
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
14
diff
changeset
|
127 for (int i = 0; i < all.length; i++) { |
02ee376bee79
status operation against current working directory
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
14
diff
changeset
|
128 for (Record r : all[i].values()) { |
02ee376bee79
status operation against current working directory
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
14
diff
changeset
|
129 rv.add(r.name1); |
02ee376bee79
status operation against current working directory
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
14
diff
changeset
|
130 } |
02ee376bee79
status operation against current working directory
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
14
diff
changeset
|
131 } |
02ee376bee79
status operation against current working directory
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
14
diff
changeset
|
132 return rv; |
02ee376bee79
status operation against current working directory
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
14
diff
changeset
|
133 } |
02ee376bee79
status operation against current working directory
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
14
diff
changeset
|
134 |
141
8248aae33f7d
Adopt FileIterator moving towards WCStatusCollector parameterizing. Improved path handling, move 'em around
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
135 /*package-local*/ Record checkNormal(Path fname) { |
293
9774f47d904d
Issue 13: Status reports filenames with case other than in dirstate incorrectly
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
291
diff
changeset
|
136 return internalCheck(normal, fname); |
18
02ee376bee79
status operation against current working directory
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
14
diff
changeset
|
137 } |
02ee376bee79
status operation against current working directory
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
14
diff
changeset
|
138 |
141
8248aae33f7d
Adopt FileIterator moving towards WCStatusCollector parameterizing. Improved path handling, move 'em around
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
139 /*package-local*/ Record checkAdded(Path fname) { |
293
9774f47d904d
Issue 13: Status reports filenames with case other than in dirstate incorrectly
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
291
diff
changeset
|
140 return internalCheck(added, fname); |
141
8248aae33f7d
Adopt FileIterator moving towards WCStatusCollector parameterizing. Improved path handling, move 'em around
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
141 } |
8248aae33f7d
Adopt FileIterator moving towards WCStatusCollector parameterizing. Improved path handling, move 'em around
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
142 /*package-local*/ Record checkRemoved(Path fname) { |
293
9774f47d904d
Issue 13: Status reports filenames with case other than in dirstate incorrectly
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
291
diff
changeset
|
143 return internalCheck(removed, fname); |
18
02ee376bee79
status operation against current working directory
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
14
diff
changeset
|
144 } |
141
8248aae33f7d
Adopt FileIterator moving towards WCStatusCollector parameterizing. Improved path handling, move 'em around
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
145 /*package-local*/ Record checkMerged(Path fname) { |
293
9774f47d904d
Issue 13: Status reports filenames with case other than in dirstate incorrectly
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
291
diff
changeset
|
146 return internalCheck(merged, fname); |
18
02ee376bee79
status operation against current working directory
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
14
diff
changeset
|
147 } |
02ee376bee79
status operation against current working directory
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
14
diff
changeset
|
148 |
293
9774f47d904d
Issue 13: Status reports filenames with case other than in dirstate incorrectly
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
291
diff
changeset
|
149 |
9774f47d904d
Issue 13: Status reports filenames with case other than in dirstate incorrectly
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
291
diff
changeset
|
150 // return non-null if fname is known, either as is, or its canonical form. in latter case, this canonical form is return value |
9774f47d904d
Issue 13: Status reports filenames with case other than in dirstate incorrectly
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
291
diff
changeset
|
151 /*package-local*/ Path known(Path fname) { |
9774f47d904d
Issue 13: Status reports filenames with case other than in dirstate incorrectly
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
291
diff
changeset
|
152 Path fnameCanonical = null; |
9774f47d904d
Issue 13: Status reports filenames with case other than in dirstate incorrectly
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
291
diff
changeset
|
153 if (canonicalPathRewrite != null) { |
9774f47d904d
Issue 13: Status reports filenames with case other than in dirstate incorrectly
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
291
diff
changeset
|
154 fnameCanonical = pathPool.path(canonicalPathRewrite.rewrite(fname).toString()); |
9774f47d904d
Issue 13: Status reports filenames with case other than in dirstate incorrectly
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
291
diff
changeset
|
155 if (fnameCanonical != fname && canonical2dirstateName.containsKey(fnameCanonical)) { |
9774f47d904d
Issue 13: Status reports filenames with case other than in dirstate incorrectly
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
291
diff
changeset
|
156 // we know right away there's name in dirstate with alternative canonical form |
9774f47d904d
Issue 13: Status reports filenames with case other than in dirstate incorrectly
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
291
diff
changeset
|
157 return canonical2dirstateName.get(fnameCanonical); |
9774f47d904d
Issue 13: Status reports filenames with case other than in dirstate incorrectly
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
291
diff
changeset
|
158 } |
9774f47d904d
Issue 13: Status reports filenames with case other than in dirstate incorrectly
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
291
diff
changeset
|
159 } |
9774f47d904d
Issue 13: Status reports filenames with case other than in dirstate incorrectly
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
291
diff
changeset
|
160 @SuppressWarnings("unchecked") |
9774f47d904d
Issue 13: Status reports filenames with case other than in dirstate incorrectly
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
291
diff
changeset
|
161 Map<Path, Record>[] all = new Map[] { normal, added, removed, merged }; |
9774f47d904d
Issue 13: Status reports filenames with case other than in dirstate incorrectly
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
291
diff
changeset
|
162 for (int i = 0; i < all.length; i++) { |
9774f47d904d
Issue 13: Status reports filenames with case other than in dirstate incorrectly
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
291
diff
changeset
|
163 if (all[i].containsKey(fname)) { |
9774f47d904d
Issue 13: Status reports filenames with case other than in dirstate incorrectly
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
291
diff
changeset
|
164 return fname; |
9774f47d904d
Issue 13: Status reports filenames with case other than in dirstate incorrectly
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
291
diff
changeset
|
165 } |
9774f47d904d
Issue 13: Status reports filenames with case other than in dirstate incorrectly
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
291
diff
changeset
|
166 if (fnameCanonical != null && all[i].containsKey(fnameCanonical)) { |
9774f47d904d
Issue 13: Status reports filenames with case other than in dirstate incorrectly
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
291
diff
changeset
|
167 return fnameCanonical; |
9774f47d904d
Issue 13: Status reports filenames with case other than in dirstate incorrectly
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
291
diff
changeset
|
168 } |
9774f47d904d
Issue 13: Status reports filenames with case other than in dirstate incorrectly
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
291
diff
changeset
|
169 } |
9774f47d904d
Issue 13: Status reports filenames with case other than in dirstate incorrectly
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
291
diff
changeset
|
170 return null; |
9774f47d904d
Issue 13: Status reports filenames with case other than in dirstate incorrectly
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
291
diff
changeset
|
171 } |
18
02ee376bee79
status operation against current working directory
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
14
diff
changeset
|
172 |
293
9774f47d904d
Issue 13: Status reports filenames with case other than in dirstate incorrectly
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
291
diff
changeset
|
173 private Record internalCheck(Map<Path, Record> map, Path fname) { |
9774f47d904d
Issue 13: Status reports filenames with case other than in dirstate incorrectly
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
291
diff
changeset
|
174 Record rv = map.get(fname); |
9774f47d904d
Issue 13: Status reports filenames with case other than in dirstate incorrectly
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
291
diff
changeset
|
175 if (rv != null || canonicalPathRewrite == null) { |
9774f47d904d
Issue 13: Status reports filenames with case other than in dirstate incorrectly
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
291
diff
changeset
|
176 return rv; |
9774f47d904d
Issue 13: Status reports filenames with case other than in dirstate incorrectly
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
291
diff
changeset
|
177 } |
9774f47d904d
Issue 13: Status reports filenames with case other than in dirstate incorrectly
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
291
diff
changeset
|
178 Path fnameCanonical = pathPool.path(canonicalPathRewrite.rewrite(fname).toString()); |
9774f47d904d
Issue 13: Status reports filenames with case other than in dirstate incorrectly
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
291
diff
changeset
|
179 if (fnameCanonical != fname) { |
9774f47d904d
Issue 13: Status reports filenames with case other than in dirstate incorrectly
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
291
diff
changeset
|
180 // case when fname = /a/B/c, and dirstate is /a/b/C |
9774f47d904d
Issue 13: Status reports filenames with case other than in dirstate incorrectly
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
291
diff
changeset
|
181 if (canonical2dirstateName.containsKey(fnameCanonical)) { |
9774f47d904d
Issue 13: Status reports filenames with case other than in dirstate incorrectly
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
291
diff
changeset
|
182 return map.get(canonical2dirstateName.get(fnameCanonical)); |
9774f47d904d
Issue 13: Status reports filenames with case other than in dirstate incorrectly
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
291
diff
changeset
|
183 } |
9774f47d904d
Issue 13: Status reports filenames with case other than in dirstate incorrectly
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
291
diff
changeset
|
184 // try canonical directly, fname = /a/B/C, dirstate has /a/b/c |
9774f47d904d
Issue 13: Status reports filenames with case other than in dirstate incorrectly
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
291
diff
changeset
|
185 if ((rv = map.get(fnameCanonical)) != null) { |
9774f47d904d
Issue 13: Status reports filenames with case other than in dirstate incorrectly
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
291
diff
changeset
|
186 return rv; |
9774f47d904d
Issue 13: Status reports filenames with case other than in dirstate incorrectly
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
291
diff
changeset
|
187 } |
9774f47d904d
Issue 13: Status reports filenames with case other than in dirstate incorrectly
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
291
diff
changeset
|
188 } |
9774f47d904d
Issue 13: Status reports filenames with case other than in dirstate incorrectly
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
291
diff
changeset
|
189 return null; |
9774f47d904d
Issue 13: Status reports filenames with case other than in dirstate incorrectly
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
291
diff
changeset
|
190 } |
18
02ee376bee79
status operation against current working directory
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
14
diff
changeset
|
191 |
290
8faad08c709b
Expose dirstate to allow pre-configuration of FileIterators for status collection in particular
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
284
diff
changeset
|
192 public void walk(Inspector inspector) { |
348
a0864b2892cd
Expose errors reading mercurial control files with exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
332
diff
changeset
|
193 assert normal != null; |
290
8faad08c709b
Expose dirstate to allow pre-configuration of FileIterators for status collection in particular
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
284
diff
changeset
|
194 @SuppressWarnings("unchecked") |
8faad08c709b
Expose dirstate to allow pre-configuration of FileIterators for status collection in particular
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
284
diff
changeset
|
195 Map<Path, Record>[] all = new Map[] { normal, added, removed, merged }; |
8faad08c709b
Expose dirstate to allow pre-configuration of FileIterators for status collection in particular
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
284
diff
changeset
|
196 for (int i = 0; i < all.length; i++) { |
8faad08c709b
Expose dirstate to allow pre-configuration of FileIterators for status collection in particular
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
284
diff
changeset
|
197 EntryKind k = EntryKind.values()[i]; |
8faad08c709b
Expose dirstate to allow pre-configuration of FileIterators for status collection in particular
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
284
diff
changeset
|
198 for (Record r : all[i].values()) { |
8faad08c709b
Expose dirstate to allow pre-configuration of FileIterators for status collection in particular
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
284
diff
changeset
|
199 if (!inspector.next(k, r)) { |
8faad08c709b
Expose dirstate to allow pre-configuration of FileIterators for status collection in particular
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
284
diff
changeset
|
200 return; |
8faad08c709b
Expose dirstate to allow pre-configuration of FileIterators for status collection in particular
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
284
diff
changeset
|
201 } |
8faad08c709b
Expose dirstate to allow pre-configuration of FileIterators for status collection in particular
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
284
diff
changeset
|
202 } |
8faad08c709b
Expose dirstate to allow pre-configuration of FileIterators for status collection in particular
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
284
diff
changeset
|
203 } |
8faad08c709b
Expose dirstate to allow pre-configuration of FileIterators for status collection in particular
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
284
diff
changeset
|
204 } |
8faad08c709b
Expose dirstate to allow pre-configuration of FileIterators for status collection in particular
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
284
diff
changeset
|
205 |
8faad08c709b
Expose dirstate to allow pre-configuration of FileIterators for status collection in particular
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
284
diff
changeset
|
206 public interface Inspector { |
293
9774f47d904d
Issue 13: Status reports filenames with case other than in dirstate incorrectly
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
291
diff
changeset
|
207 /** |
9774f47d904d
Issue 13: Status reports filenames with case other than in dirstate incorrectly
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
291
diff
changeset
|
208 * Invoked for each entry in the directory state file |
9774f47d904d
Issue 13: Status reports filenames with case other than in dirstate incorrectly
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
291
diff
changeset
|
209 * @param kind file record kind |
9774f47d904d
Issue 13: Status reports filenames with case other than in dirstate incorrectly
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
291
diff
changeset
|
210 * @param entry file record. Note, do not cache instance as it may be reused between the calls |
9774f47d904d
Issue 13: Status reports filenames with case other than in dirstate incorrectly
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
291
diff
changeset
|
211 * @return <code>true</code> to indicate further records are still of interest, <code>false</code> to stop iteration |
9774f47d904d
Issue 13: Status reports filenames with case other than in dirstate incorrectly
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
291
diff
changeset
|
212 */ |
290
8faad08c709b
Expose dirstate to allow pre-configuration of FileIterators for status collection in particular
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
284
diff
changeset
|
213 boolean next(EntryKind kind, Record entry); |
8faad08c709b
Expose dirstate to allow pre-configuration of FileIterators for status collection in particular
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
284
diff
changeset
|
214 } |
8faad08c709b
Expose dirstate to allow pre-configuration of FileIterators for status collection in particular
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
284
diff
changeset
|
215 |
293
9774f47d904d
Issue 13: Status reports filenames with case other than in dirstate incorrectly
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
291
diff
changeset
|
216 public static final class Record implements Cloneable { |
290
8faad08c709b
Expose dirstate to allow pre-configuration of FileIterators for status collection in particular
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
284
diff
changeset
|
217 private final int mode, size, time; |
8faad08c709b
Expose dirstate to allow pre-configuration of FileIterators for status collection in particular
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
284
diff
changeset
|
218 // Dirstate keeps local file size (i.e. that with any filters already applied). |
280
35125450c804
Erroneous and slow status for working copies based on non-tip revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
252
diff
changeset
|
219 // Thus, can't compare directly to HgDataFile.length() |
290
8faad08c709b
Expose dirstate to allow pre-configuration of FileIterators for status collection in particular
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
284
diff
changeset
|
220 private final Path name1, name2; |
10
382cfe9463db
Dirstate parsing. DataAccess refactored to allow reuse and control over constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
221 |
525
0be5be8d57e9
Repository checkout support, first iteration
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
501
diff
changeset
|
222 public Record(int fmode, int fsize, int ftime, Path name1, Path name2) { |
10
382cfe9463db
Dirstate parsing. DataAccess refactored to allow reuse and control over constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
223 mode = fmode; |
382cfe9463db
Dirstate parsing. DataAccess refactored to allow reuse and control over constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
224 size = fsize; |
382cfe9463db
Dirstate parsing. DataAccess refactored to allow reuse and control over constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
225 time = ftime; |
382cfe9463db
Dirstate parsing. DataAccess refactored to allow reuse and control over constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
226 this.name1 = name1; |
382cfe9463db
Dirstate parsing. DataAccess refactored to allow reuse and control over constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
227 this.name2 = name2; |
382cfe9463db
Dirstate parsing. DataAccess refactored to allow reuse and control over constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
228 |
382cfe9463db
Dirstate parsing. DataAccess refactored to allow reuse and control over constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
229 } |
290
8faad08c709b
Expose dirstate to allow pre-configuration of FileIterators for status collection in particular
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
284
diff
changeset
|
230 |
8faad08c709b
Expose dirstate to allow pre-configuration of FileIterators for status collection in particular
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
284
diff
changeset
|
231 public Path name() { |
8faad08c709b
Expose dirstate to allow pre-configuration of FileIterators for status collection in particular
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
284
diff
changeset
|
232 return name1; |
8faad08c709b
Expose dirstate to allow pre-configuration of FileIterators for status collection in particular
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
284
diff
changeset
|
233 } |
8faad08c709b
Expose dirstate to allow pre-configuration of FileIterators for status collection in particular
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
284
diff
changeset
|
234 |
8faad08c709b
Expose dirstate to allow pre-configuration of FileIterators for status collection in particular
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
284
diff
changeset
|
235 /** |
8faad08c709b
Expose dirstate to allow pre-configuration of FileIterators for status collection in particular
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
284
diff
changeset
|
236 * @return non-<code>null</code> for copy/move |
8faad08c709b
Expose dirstate to allow pre-configuration of FileIterators for status collection in particular
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
284
diff
changeset
|
237 */ |
8faad08c709b
Expose dirstate to allow pre-configuration of FileIterators for status collection in particular
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
284
diff
changeset
|
238 public Path copySource() { |
8faad08c709b
Expose dirstate to allow pre-configuration of FileIterators for status collection in particular
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
284
diff
changeset
|
239 return name2; |
8faad08c709b
Expose dirstate to allow pre-configuration of FileIterators for status collection in particular
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
284
diff
changeset
|
240 } |
8faad08c709b
Expose dirstate to allow pre-configuration of FileIterators for status collection in particular
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
284
diff
changeset
|
241 |
8faad08c709b
Expose dirstate to allow pre-configuration of FileIterators for status collection in particular
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
284
diff
changeset
|
242 public int modificationTime() { |
8faad08c709b
Expose dirstate to allow pre-configuration of FileIterators for status collection in particular
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
284
diff
changeset
|
243 return time; |
8faad08c709b
Expose dirstate to allow pre-configuration of FileIterators for status collection in particular
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
284
diff
changeset
|
244 } |
8faad08c709b
Expose dirstate to allow pre-configuration of FileIterators for status collection in particular
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
284
diff
changeset
|
245 |
8faad08c709b
Expose dirstate to allow pre-configuration of FileIterators for status collection in particular
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
284
diff
changeset
|
246 public int size() { |
8faad08c709b
Expose dirstate to allow pre-configuration of FileIterators for status collection in particular
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
284
diff
changeset
|
247 return size; |
8faad08c709b
Expose dirstate to allow pre-configuration of FileIterators for status collection in particular
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
284
diff
changeset
|
248 } |
293
9774f47d904d
Issue 13: Status reports filenames with case other than in dirstate incorrectly
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
291
diff
changeset
|
249 |
348
a0864b2892cd
Expose errors reading mercurial control files with exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
332
diff
changeset
|
250 public int mode() { |
a0864b2892cd
Expose errors reading mercurial control files with exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
332
diff
changeset
|
251 return mode; |
a0864b2892cd
Expose errors reading mercurial control files with exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
332
diff
changeset
|
252 } |
a0864b2892cd
Expose errors reading mercurial control files with exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
332
diff
changeset
|
253 |
293
9774f47d904d
Issue 13: Status reports filenames with case other than in dirstate incorrectly
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
291
diff
changeset
|
254 @Override |
9774f47d904d
Issue 13: Status reports filenames with case other than in dirstate incorrectly
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
291
diff
changeset
|
255 public Record clone() { |
9774f47d904d
Issue 13: Status reports filenames with case other than in dirstate incorrectly
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
291
diff
changeset
|
256 try { |
9774f47d904d
Issue 13: Status reports filenames with case other than in dirstate incorrectly
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
291
diff
changeset
|
257 return (Record) super.clone(); |
9774f47d904d
Issue 13: Status reports filenames with case other than in dirstate incorrectly
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
291
diff
changeset
|
258 } catch (CloneNotSupportedException ex) { |
9774f47d904d
Issue 13: Status reports filenames with case other than in dirstate incorrectly
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
291
diff
changeset
|
259 throw new InternalError(ex.toString()); |
9774f47d904d
Issue 13: Status reports filenames with case other than in dirstate incorrectly
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
291
diff
changeset
|
260 } |
9774f47d904d
Issue 13: Status reports filenames with case other than in dirstate incorrectly
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
291
diff
changeset
|
261 } |
10
382cfe9463db
Dirstate parsing. DataAccess refactored to allow reuse and control over constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
262 } |
382cfe9463db
Dirstate parsing. DataAccess refactored to allow reuse and control over constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
263 } |