annotate src/org/tmatesoft/hg/repo/HgWorkingCopyStatusCollector.java @ 429:cd658b24a620

FIXMEs: javadoc, proper use of constants
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Thu, 29 Mar 2012 18:29:03 +0200
parents 48f993aa2f41
children 12f668401613
rev   line source
58
4cfc47bc14cc Status against local working dir extracted into distinct class. Iterating over local files extracted for ease of os-dependant patching
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
1 /*
397
5e95b0da26f2 Issue 24: IAE, Underflow in FilterDataAccess. Issue 26:UnsupportedOperationException when patching empty base revision. Tests
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 367
diff changeset
2 * Copyright (c) 2011-2012 TMate Software Ltd
74
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 68
diff changeset
3 *
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 68
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: 68
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: 68
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: 68
diff changeset
7 *
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 68
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: 68
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: 68
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: 68
diff changeset
11 * GNU General Public License for more details.
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 68
diff changeset
12 *
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 68
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: 68
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: 94
diff changeset
15 * contact TMate Software at support@hg4j.com
58
4cfc47bc14cc Status against local working dir extracted into distinct class. Iterating over local files extracted for ease of os-dependant patching
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
16 */
74
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 68
diff changeset
17 package org.tmatesoft.hg.repo;
58
4cfc47bc14cc Status against local working dir extracted into distinct class. Iterating over local files extracted for ease of os-dependant patching
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
18
120
b19f0ac5ee62 Check against working copy shall expect non-persistent modifications done by filters and not report such files as modified
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 117
diff changeset
19 import static java.lang.Math.max;
117
6c0be854d149 Enable filters for status operation (ToRepo case)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 102
diff changeset
20 import static java.lang.Math.min;
218
047b1dec7a04 Issue 7: Correctly handle manifest and changelog with different number of (or non-matching) revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 195
diff changeset
21 import static org.tmatesoft.hg.repo.HgRepository.*;
58
4cfc47bc14cc Status against local working dir extracted into distinct class. Iterating over local files extracted for ease of os-dependant patching
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
22
4cfc47bc14cc Status against local working dir extracted into distinct class. Iterating over local files extracted for ease of os-dependant patching
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
23 import java.io.File;
4cfc47bc14cc Status against local working dir extracted into distinct class. Iterating over local files extracted for ease of os-dependant patching
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
24 import java.io.IOException;
117
6c0be854d149 Enable filters for status operation (ToRepo case)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 102
diff changeset
25 import java.nio.ByteBuffer;
287
ed6b74a58c66 Use FileInfo abstraction with necessary subset of File functionality instead of File to facilitate other effective file system iterators
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 285
diff changeset
26 import java.nio.channels.ReadableByteChannel;
229
1ec6b327a6ac Scope for status reworked: explicit files or a general matcher
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 226
diff changeset
27 import java.util.ArrayList;
58
4cfc47bc14cc Status against local working dir extracted into distinct class. Iterating over local files extracted for ease of os-dependant patching
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
28 import java.util.Collections;
226
26ad7827a62d Support status query for a single file or a subdirectory of a repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 219
diff changeset
29 import java.util.NoSuchElementException;
58
4cfc47bc14cc Status against local working dir extracted into distinct class. Iterating over local files extracted for ease of os-dependant patching
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
30 import java.util.Set;
4cfc47bc14cc Status against local working dir extracted into distinct class. Iterating over local files extracted for ease of os-dependant patching
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
31 import java.util.TreeSet;
4cfc47bc14cc Status against local working dir extracted into distinct class. Iterating over local files extracted for ease of os-dependant patching
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
32
74
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 68
diff changeset
33 import org.tmatesoft.hg.core.Nodeid;
425
48f993aa2f41 FIXMEs: exceptions, javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 423
diff changeset
34 import org.tmatesoft.hg.core.SessionContext;
157
d5268ca7715b Merged branch wrap-data-access into default for resource-friendly data access. Updated API to promote that friendliness to clients (channels, not byte[]). More exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 148
diff changeset
35 import org.tmatesoft.hg.internal.ByteArrayChannel;
226
26ad7827a62d Support status query for a single file or a subdirectory of a repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 219
diff changeset
36 import org.tmatesoft.hg.internal.Experimental;
117
6c0be854d149 Enable filters for status operation (ToRepo case)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 102
diff changeset
37 import org.tmatesoft.hg.internal.FilterByteChannel;
413
7f27122011c3 Support and respect for symbolic links and executable flag, with /bin/ls backed implementation to discover these
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 405
diff changeset
38 import org.tmatesoft.hg.internal.Internals;
248
3fbfce107f94 Issue 8: Means to find out information about given file at specific changeset. Inner ManifestRevisionInspector got promoted to ManifestRevision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 246
diff changeset
39 import org.tmatesoft.hg.internal.ManifestRevision;
229
1ec6b327a6ac Scope for status reworked: explicit files or a general matcher
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 226
diff changeset
40 import org.tmatesoft.hg.internal.PathScope;
355
f2c11fe7f3e9 Newline filter shall respect whole stream when deciding whether to process line terminators, hence added stream preview functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 354
diff changeset
41 import org.tmatesoft.hg.internal.Preview;
356
91d75e1bac9f Consistent approach to deal with adaptable objects. Give adaptable precedence over instanceof to allow conditional response when classes do implement desired interface
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 355
diff changeset
42 import org.tmatesoft.hg.util.Adaptable;
117
6c0be854d149 Enable filters for status operation (ToRepo case)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 102
diff changeset
43 import org.tmatesoft.hg.util.ByteChannel;
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: 415
diff changeset
44 import org.tmatesoft.hg.util.CancelSupport;
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>
parents: 148
diff changeset
45 import org.tmatesoft.hg.util.CancelledException;
287
ed6b74a58c66 Use FileInfo abstraction with necessary subset of File functionality instead of File to facilitate other effective file system iterators
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 285
diff changeset
46 import org.tmatesoft.hg.util.FileInfo;
141
8248aae33f7d Adopt FileIterator moving towards WCStatusCollector parameterizing. Improved path handling, move 'em around
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 133
diff changeset
47 import org.tmatesoft.hg.util.FileIterator;
226
26ad7827a62d Support status query for a single file or a subdirectory of a repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 219
diff changeset
48 import org.tmatesoft.hg.util.FileWalker;
133
4a948ec83980 core.Path to util.Path as it's not Hg repo dependant
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 120
diff changeset
49 import org.tmatesoft.hg.util.Path;
93
d55d4eedfc57 Switch to Path instead of String in filenames returned by various status operations
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 91
diff changeset
50 import org.tmatesoft.hg.util.PathPool;
d55d4eedfc57 Switch to Path instead of String in filenames returned by various status operations
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 91
diff changeset
51 import org.tmatesoft.hg.util.PathRewrite;
287
ed6b74a58c66 Use FileInfo abstraction with necessary subset of File functionality instead of File to facilitate other effective file system iterators
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 285
diff changeset
52 import org.tmatesoft.hg.util.RegularFileInfo;
58
4cfc47bc14cc Status against local working dir extracted into distinct class. Iterating over local files extracted for ease of os-dependant patching
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
53
4cfc47bc14cc Status against local working dir extracted into distinct class. Iterating over local files extracted for ease of os-dependant patching
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
54 /**
4cfc47bc14cc Status against local working dir extracted into distinct class. Iterating over local files extracted for ease of os-dependant patching
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
55 *
74
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 68
diff changeset
56 * @author Artem Tikhomirov
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 68
diff changeset
57 * @author TMate Software Ltd.
58
4cfc47bc14cc Status against local working dir extracted into distinct class. Iterating over local files extracted for ease of os-dependant patching
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
58 */
94
af1f3b78b918 *StatusCollector renamed to Hg*StatusCollector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 93
diff changeset
59 public class HgWorkingCopyStatusCollector {
58
4cfc47bc14cc Status against local working dir extracted into distinct class. Iterating over local files extracted for ease of os-dependant patching
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
60
4cfc47bc14cc Status against local working dir extracted into distinct class. Iterating over local files extracted for ease of os-dependant patching
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
61 private final HgRepository repo;
141
8248aae33f7d Adopt FileIterator moving towards WCStatusCollector parameterizing. Improved path handling, move 'em around
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 133
diff changeset
62 private final FileIterator repoWalker;
59
b771e94a4f7c Introduce Internals to keep LocalHgRepo casts and alike in a single place. WCSC optionally to reuse SC data
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 58
diff changeset
63 private HgDirstate dirstate;
94
af1f3b78b918 *StatusCollector renamed to Hg*StatusCollector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 93
diff changeset
64 private HgStatusCollector baseRevisionCollector;
93
d55d4eedfc57 Switch to Path instead of String in filenames returned by various status operations
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 91
diff changeset
65 private PathPool pathPool;
282
e51dd9a14b6f Yet another WC status fix, where dirstate parent and base revision are treated right (dirstate parent other than tip and explicit baseRevision are not the same)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 280
diff changeset
66 private ManifestRevision dirstateParentManifest;
58
4cfc47bc14cc Status against local working dir extracted into distinct class. Iterating over local files extracted for ease of os-dependant patching
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
67
362
4937e35b805b Report dirstate access error with Exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 360
diff changeset
68 /**
4937e35b805b Report dirstate access error with Exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 360
diff changeset
69 * Collector that iterates over complete working copy
4937e35b805b Report dirstate access error with Exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 360
diff changeset
70 */
94
af1f3b78b918 *StatusCollector renamed to Hg*StatusCollector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 93
diff changeset
71 public HgWorkingCopyStatusCollector(HgRepository hgRepo) {
229
1ec6b327a6ac Scope for status reworked: explicit files or a general matcher
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 226
diff changeset
72 this(hgRepo, new HgInternals(hgRepo).createWorkingDirWalker(null));
74
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 68
diff changeset
73 }
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 68
diff changeset
74
362
4937e35b805b Report dirstate access error with Exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 360
diff changeset
75 /**
4937e35b805b Report dirstate access error with Exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 360
diff changeset
76 * Collector may analyze and report status for any arbitrary sub-tree of the working copy.
4937e35b805b Report dirstate access error with Exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 360
diff changeset
77 * File iterator shall return names of the files relative to the repository root.
4937e35b805b Report dirstate access error with Exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 360
diff changeset
78 *
4937e35b805b Report dirstate access error with Exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 360
diff changeset
79 * @param hgRepo status target repository
4937e35b805b Report dirstate access error with Exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 360
diff changeset
80 * @param workingCopyWalker iterator over files in the working copy
4937e35b805b Report dirstate access error with Exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 360
diff changeset
81 */
4937e35b805b Report dirstate access error with Exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 360
diff changeset
82 public HgWorkingCopyStatusCollector(HgRepository hgRepo, FileIterator workingCopyWalker) {
218
047b1dec7a04 Issue 7: Correctly handle manifest and changelog with different number of (or non-matching) revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 195
diff changeset
83 repo = hgRepo;
362
4937e35b805b Report dirstate access error with Exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 360
diff changeset
84 repoWalker = workingCopyWalker;
58
4cfc47bc14cc Status against local working dir extracted into distinct class. Iterating over local files extracted for ease of os-dependant patching
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
85 }
59
b771e94a4f7c Introduce Internals to keep LocalHgRepo casts and alike in a single place. WCSC optionally to reuse SC data
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 58
diff changeset
86
b771e94a4f7c Introduce Internals to keep LocalHgRepo casts and alike in a single place. WCSC optionally to reuse SC data
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 58
diff changeset
87 /**
b771e94a4f7c Introduce Internals to keep LocalHgRepo casts and alike in a single place. WCSC optionally to reuse SC data
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 58
diff changeset
88 * Optionally, supply a collector instance that may cache (or have already cached) base revision
b771e94a4f7c Introduce Internals to keep LocalHgRepo casts and alike in a single place. WCSC optionally to reuse SC data
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 58
diff changeset
89 * @param sc may be null
b771e94a4f7c Introduce Internals to keep LocalHgRepo casts and alike in a single place. WCSC optionally to reuse SC data
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 58
diff changeset
90 */
94
af1f3b78b918 *StatusCollector renamed to Hg*StatusCollector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 93
diff changeset
91 public void setBaseRevisionCollector(HgStatusCollector sc) {
59
b771e94a4f7c Introduce Internals to keep LocalHgRepo casts and alike in a single place. WCSC optionally to reuse SC data
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 58
diff changeset
92 baseRevisionCollector = sc;
b771e94a4f7c Introduce Internals to keep LocalHgRepo casts and alike in a single place. WCSC optionally to reuse SC data
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 58
diff changeset
93 }
93
d55d4eedfc57 Switch to Path instead of String in filenames returned by various status operations
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 91
diff changeset
94
d55d4eedfc57 Switch to Path instead of String in filenames returned by various status operations
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 91
diff changeset
95 /*package-local*/ PathPool getPathPool() {
d55d4eedfc57 Switch to Path instead of String in filenames returned by various status operations
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 91
diff changeset
96 if (pathPool == null) {
d55d4eedfc57 Switch to Path instead of String in filenames returned by various status operations
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 91
diff changeset
97 if (baseRevisionCollector == null) {
d55d4eedfc57 Switch to Path instead of String in filenames returned by various status operations
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 91
diff changeset
98 pathPool = new PathPool(new PathRewrite.Empty());
d55d4eedfc57 Switch to Path instead of String in filenames returned by various status operations
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 91
diff changeset
99 } else {
d55d4eedfc57 Switch to Path instead of String in filenames returned by various status operations
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 91
diff changeset
100 return baseRevisionCollector.getPathPool();
d55d4eedfc57 Switch to Path instead of String in filenames returned by various status operations
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 91
diff changeset
101 }
d55d4eedfc57 Switch to Path instead of String in filenames returned by various status operations
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 91
diff changeset
102 }
d55d4eedfc57 Switch to Path instead of String in filenames returned by various status operations
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 91
diff changeset
103 return pathPool;
d55d4eedfc57 Switch to Path instead of String in filenames returned by various status operations
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 91
diff changeset
104 }
d55d4eedfc57 Switch to Path instead of String in filenames returned by various status operations
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 91
diff changeset
105
d55d4eedfc57 Switch to Path instead of String in filenames returned by various status operations
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 91
diff changeset
106 public void setPathPool(PathPool pathPool) {
d55d4eedfc57 Switch to Path instead of String in filenames returned by various status operations
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 91
diff changeset
107 this.pathPool = pathPool;
d55d4eedfc57 Switch to Path instead of String in filenames returned by various status operations
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 91
diff changeset
108 }
d55d4eedfc57 Switch to Path instead of String in filenames returned by various status operations
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 91
diff changeset
109
290
8faad08c709b Expose dirstate to allow pre-configuration of FileIterators for status collection in particular
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 287
diff changeset
110 /**
8faad08c709b Expose dirstate to allow pre-configuration of FileIterators for status collection in particular
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 287
diff changeset
111 * Access to directory state information this collector uses.
8faad08c709b Expose dirstate to allow pre-configuration of FileIterators for status collection in particular
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 287
diff changeset
112 * @return directory state holder, never <code>null</code>
8faad08c709b Expose dirstate to allow pre-configuration of FileIterators for status collection in particular
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 287
diff changeset
113 */
348
a0864b2892cd Expose errors reading mercurial control files with exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 337
diff changeset
114 public HgDirstate getDirstate() throws HgInvalidControlFileException {
59
b771e94a4f7c Introduce Internals to keep LocalHgRepo casts and alike in a single place. WCSC optionally to reuse SC data
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 58
diff changeset
115 if (dirstate == 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: 282
diff changeset
116 dirstate = repo.loadDirstate(getPathPool());
59
b771e94a4f7c Introduce Internals to keep LocalHgRepo casts and alike in a single place. WCSC optionally to reuse SC data
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 58
diff changeset
117 }
b771e94a4f7c Introduce Internals to keep LocalHgRepo casts and alike in a single place. WCSC optionally to reuse SC data
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 58
diff changeset
118 return dirstate;
b771e94a4f7c Introduce Internals to keep LocalHgRepo casts and alike in a single place. WCSC optionally to reuse SC data
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 58
diff changeset
119 }
275
6d1804fe0ed7 Issue 10: Report file content length with respect of metadata. Respect dirstate parents for WC's status. Exceptions to keep useful attributes of the location
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 248
diff changeset
120
348
a0864b2892cd Expose errors reading mercurial control files with exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 337
diff changeset
121 private HgDirstate getDirstateImpl() {
a0864b2892cd Expose errors reading mercurial control files with exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 337
diff changeset
122 return dirstate;
a0864b2892cd Expose errors reading mercurial control files with exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 337
diff changeset
123 }
a0864b2892cd Expose errors reading mercurial control files with exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 337
diff changeset
124
366
189dc6dc1c3e Use exceptions to expose errors reading mercurial data
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 362
diff changeset
125 private ManifestRevision getManifest(int changelogLocalRev) 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: 282
diff changeset
126 assert changelogLocalRev >= 0;
282
e51dd9a14b6f Yet another WC status fix, where dirstate parent and base revision are treated right (dirstate parent other than tip and explicit baseRevision are not the same)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 280
diff changeset
127 ManifestRevision mr;
e51dd9a14b6f Yet another WC status fix, where dirstate parent and base revision are treated right (dirstate parent other than tip and explicit baseRevision are not the same)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 280
diff changeset
128 if (baseRevisionCollector != null) {
e51dd9a14b6f Yet another WC status fix, where dirstate parent and base revision are treated right (dirstate parent other than tip and explicit baseRevision are not the same)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 280
diff changeset
129 mr = baseRevisionCollector.raw(changelogLocalRev);
e51dd9a14b6f Yet another WC status fix, where dirstate parent and base revision are treated right (dirstate parent other than tip and explicit baseRevision are not the same)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 280
diff changeset
130 } else {
e51dd9a14b6f Yet another WC status fix, where dirstate parent and base revision are treated right (dirstate parent other than tip and explicit baseRevision are not the same)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 280
diff changeset
131 mr = new ManifestRevision(null, null);
e51dd9a14b6f Yet another WC status fix, where dirstate parent and base revision are treated right (dirstate parent other than tip and explicit baseRevision are not the same)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 280
diff changeset
132 repo.getManifest().walk(changelogLocalRev, changelogLocalRev, mr);
e51dd9a14b6f Yet another WC status fix, where dirstate parent and base revision are treated right (dirstate parent other than tip and explicit baseRevision are not the same)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 280
diff changeset
133 }
e51dd9a14b6f Yet another WC status fix, where dirstate parent and base revision are treated right (dirstate parent other than tip and explicit baseRevision are not the same)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 280
diff changeset
134 return mr;
e51dd9a14b6f Yet another WC status fix, where dirstate parent and base revision are treated right (dirstate parent other than tip and explicit baseRevision are not the same)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 280
diff changeset
135 }
354
5f9073eabf06 Propagate errors with exceptions up to a end client
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 350
diff changeset
136
5f9073eabf06 Propagate errors with exceptions up to a end client
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 350
diff changeset
137 private void initDirstateParentManifest() throws HgInvalidControlFileException {
5f9073eabf06 Propagate errors with exceptions up to a end client
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 350
diff changeset
138 Nodeid dirstateParent = getDirstateImpl().parents().first();
5f9073eabf06 Propagate errors with exceptions up to a end client
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 350
diff changeset
139 if (dirstateParent.isNull()) {
405
866fc3b597a0 Add an explicit constant instead of -1 to indicate 'no revision' case
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 397
diff changeset
140 dirstateParentManifest = baseRevisionCollector != null ? baseRevisionCollector.raw(NO_REVISION) : HgStatusCollector.createEmptyManifestRevision();
354
5f9073eabf06 Propagate errors with exceptions up to a end client
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 350
diff changeset
141 } else {
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
142 int changeloRevIndex = repo.getChangelog().getRevisionIndex(dirstateParent);
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
143 dirstateParentManifest = getManifest(changeloRevIndex);
354
5f9073eabf06 Propagate errors with exceptions up to a end client
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 350
diff changeset
144 }
5f9073eabf06 Propagate errors with exceptions up to a end client
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 350
diff changeset
145 }
5f9073eabf06 Propagate errors with exceptions up to a end client
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 350
diff changeset
146
5f9073eabf06 Propagate errors with exceptions up to a end client
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 350
diff changeset
147 // WC not necessarily points to TIP, but may be result of update to any previous revision.
5f9073eabf06 Propagate errors with exceptions up to a end client
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 350
diff changeset
148 // In such case, we need to compare local files not to their TIP content, but to specific version at the time of selected revision
282
e51dd9a14b6f Yet another WC status fix, where dirstate parent and base revision are treated right (dirstate parent other than tip and explicit baseRevision are not the same)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 280
diff changeset
149 private ManifestRevision getDirstateParentManifest() {
e51dd9a14b6f Yet another WC status fix, where dirstate parent and base revision are treated right (dirstate parent other than tip and explicit baseRevision are not the same)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 280
diff changeset
150 return dirstateParentManifest;
e51dd9a14b6f Yet another WC status fix, where dirstate parent and base revision are treated right (dirstate parent other than tip and explicit baseRevision are not the same)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 280
diff changeset
151 }
e51dd9a14b6f Yet another WC status fix, where dirstate parent and base revision are treated right (dirstate parent other than tip and explicit baseRevision are not the same)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 280
diff changeset
152
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: 415
diff changeset
153 /**
429
cd658b24a620 FIXMEs: javadoc, proper use of constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 425
diff changeset
154 * Walk working copy, analyze status for each file found and missing.
cd658b24a620 FIXMEs: javadoc, proper use of constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 425
diff changeset
155 * May be invoked few times.
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: 415
diff changeset
156 *
429
cd658b24a620 FIXMEs: javadoc, proper use of constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 425
diff changeset
157 * <p>There's no dedicated constant to for working copy parent, at least now.
cd658b24a620 FIXMEs: javadoc, proper use of constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 425
diff changeset
158 * Use {@link HgRepository#WORKING_COPY} to indicate comparison
cd658b24a620 FIXMEs: javadoc, proper use of constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 425
diff changeset
159 * shall be run against working copy parent. Although a bit confusing, single case doesn't
cd658b24a620 FIXMEs: javadoc, proper use of constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 425
diff changeset
160 * justify a dedicated constant.
cd658b24a620 FIXMEs: javadoc, proper use of constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 425
diff changeset
161 *
cd658b24a620 FIXMEs: javadoc, proper use of constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 425
diff changeset
162 * @param baseRevision revision index to check against, or {@link HgRepository#WORKING_COPY}. Note, {@link HgRepository#TIP} is not supported.
cd658b24a620 FIXMEs: javadoc, proper use of constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 425
diff changeset
163 * @param inspector callback to receive status information
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: 415
diff changeset
164 * @throws IOException to propagate IO errors from {@link FileIterator}
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: 415
diff changeset
165 * @throws CancelledException if operation execution was cancelled
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: 415
diff changeset
166 * @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: 415
diff changeset
167 */
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: 415
diff changeset
168 public void walk(int baseRevision, HgStatusInspector inspector) throws IOException, CancelledException, HgRuntimeException {
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
169 if (HgInternals.wrongRevisionIndex(baseRevision) || baseRevision == BAD_REVISION) {
425
48f993aa2f41 FIXMEs: exceptions, javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 423
diff changeset
170 throw new HgInvalidRevisionException(baseRevision);
218
047b1dec7a04 Issue 7: Correctly handle manifest and changelog with different number of (or non-matching) revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 195
diff changeset
171 }
362
4937e35b805b Report dirstate access error with Exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 360
diff changeset
172 if (getDirstateImpl() == null) {
4937e35b805b Report dirstate access error with Exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 360
diff changeset
173 getDirstate();
4937e35b805b Report dirstate access error with Exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 360
diff changeset
174 }
4937e35b805b Report dirstate access error with Exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 360
diff changeset
175 if (getDirstateParentManifest() == null) {
4937e35b805b Report dirstate access error with Exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 360
diff changeset
176 initDirstateParentManifest();
348
a0864b2892cd Expose errors reading mercurial control files with exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 337
diff changeset
177 }
429
cd658b24a620 FIXMEs: javadoc, proper use of constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 425
diff changeset
178 // XXX NOTE, use of TIP for working copy parent is questionable, at least. Instead, TIP shall mean latest cset or not allowed at all
282
e51dd9a14b6f Yet another WC status fix, where dirstate parent and base revision are treated right (dirstate parent other than tip and explicit baseRevision are not the same)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 280
diff changeset
179 ManifestRevision collect = null; // non null indicates we compare against base revision
285
6dbbc53fc46d Use Path instead of plain String for manifest file names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 284
diff changeset
180 Set<Path> baseRevFiles = Collections.emptySet(); // files from base revision not affected by status calculation
282
e51dd9a14b6f Yet another WC status fix, where dirstate parent and base revision are treated right (dirstate parent other than tip and explicit baseRevision are not the same)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 280
diff changeset
181 if (baseRevision != TIP && baseRevision != WORKING_COPY) {
e51dd9a14b6f Yet another WC status fix, where dirstate parent and base revision are treated right (dirstate parent other than tip and explicit baseRevision are not the same)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 280
diff changeset
182 collect = getManifest(baseRevision);
285
6dbbc53fc46d Use Path instead of plain String for manifest file names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 284
diff changeset
183 baseRevFiles = new TreeSet<Path>(collect.files());
58
4cfc47bc14cc Status against local working dir extracted into distinct class. Iterating over local files extracted for ease of os-dependant patching
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
184 }
94
af1f3b78b918 *StatusCollector renamed to Hg*StatusCollector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 93
diff changeset
185 if (inspector instanceof HgStatusCollector.Record) {
af1f3b78b918 *StatusCollector renamed to Hg*StatusCollector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 93
diff changeset
186 HgStatusCollector sc = baseRevisionCollector == null ? new HgStatusCollector(repo) : baseRevisionCollector;
282
e51dd9a14b6f Yet another WC status fix, where dirstate parent and base revision are treated right (dirstate parent other than tip and explicit baseRevision are not the same)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 280
diff changeset
187 // nodeidAfterChange(dirstate's parent) doesn't make too much sense,
e51dd9a14b6f Yet another WC status fix, where dirstate parent and base revision are treated right (dirstate parent other than tip and explicit baseRevision are not the same)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 280
diff changeset
188 // because the change might be actually in working copy. Nevertheless,
e51dd9a14b6f Yet another WC status fix, where dirstate parent and base revision are treated right (dirstate parent other than tip and explicit baseRevision are not the same)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 280
diff changeset
189 // as long as no nodeids can be provided for WC, seems reasonable to report
e51dd9a14b6f Yet another WC status fix, where dirstate parent and base revision are treated right (dirstate parent other than tip and explicit baseRevision are not the same)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 280
diff changeset
190 // latest known nodeid change (although at the moment this is not used and
e51dd9a14b6f Yet another WC status fix, where dirstate parent and base revision are treated right (dirstate parent other than tip and explicit baseRevision are not the same)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 280
diff changeset
191 // is done mostly not to leave stale initialization in the Record)
e51dd9a14b6f Yet another WC status fix, where dirstate parent and base revision are treated right (dirstate parent other than tip and explicit baseRevision are not the same)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 280
diff changeset
192 int rev1,rev2 = getDirstateParentManifest().changesetLocalRev();
e51dd9a14b6f Yet another WC status fix, where dirstate parent and base revision are treated right (dirstate parent other than tip and explicit baseRevision are not the same)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 280
diff changeset
193 if (baseRevision == TIP || baseRevision == WORKING_COPY) {
e51dd9a14b6f Yet another WC status fix, where dirstate parent and base revision are treated right (dirstate parent other than tip and explicit baseRevision are not the same)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 280
diff changeset
194 rev1 = rev2 - 1; // just use revision prior to dirstate's parent
e51dd9a14b6f Yet another WC status fix, where dirstate parent and base revision are treated right (dirstate parent other than tip and explicit baseRevision are not the same)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 280
diff changeset
195 } else {
e51dd9a14b6f Yet another WC status fix, where dirstate parent and base revision are treated right (dirstate parent other than tip and explicit baseRevision are not the same)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 280
diff changeset
196 rev1 = baseRevision;
e51dd9a14b6f Yet another WC status fix, where dirstate parent and base revision are treated right (dirstate parent other than tip and explicit baseRevision are not the same)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 280
diff changeset
197 }
e51dd9a14b6f Yet another WC status fix, where dirstate parent and base revision are treated right (dirstate parent other than tip and explicit baseRevision are not the same)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 280
diff changeset
198 ((HgStatusCollector.Record) inspector).init(rev1, rev2, sc);
68
0e499fed9b3d StatusCommand with tests. Extra constants to indicate common revision cases
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 63
diff changeset
199 }
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: 415
diff changeset
200 final CancelSupport cs = CancelSupport.Factory.get(inspector);
282
e51dd9a14b6f Yet another WC status fix, where dirstate parent and base revision are treated right (dirstate parent other than tip and explicit baseRevision are not the same)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 280
diff changeset
201 final HgIgnore hgIgnore = repo.getIgnore();
58
4cfc47bc14cc Status against local working dir extracted into distinct class. Iterating over local files extracted for ease of os-dependant patching
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
202 repoWalker.reset();
293
9774f47d904d Issue 13: Status reports filenames with case other than in dirstate incorrectly
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 290
diff changeset
203 TreeSet<Path> processed = new TreeSet<Path>(); // names of files we handled as they known to Dirstate (not FileIterator)
348
a0864b2892cd Expose errors reading mercurial control files with exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 337
diff changeset
204 final HgDirstate ds = getDirstateImpl();
293
9774f47d904d Issue 13: Status reports filenames with case other than in dirstate incorrectly
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 290
diff changeset
205 TreeSet<Path> knownEntries = ds.all(); // here just to get dirstate initialized
58
4cfc47bc14cc Status against local working dir extracted into distinct class. Iterating over local files extracted for ease of os-dependant patching
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
206 while (repoWalker.hasNext()) {
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: 415
diff changeset
207 cs.checkCancelled();
58
4cfc47bc14cc Status against local working dir extracted into distinct class. Iterating over local files extracted for ease of os-dependant patching
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
208 repoWalker.next();
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: 282
diff changeset
209 final Path fname = getPathPool().path(repoWalker.name());
287
ed6b74a58c66 Use FileInfo abstraction with necessary subset of File functionality instead of File to facilitate other effective file system iterators
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 285
diff changeset
210 FileInfo f = repoWalker.file();
293
9774f47d904d Issue 13: Status reports filenames with case other than in dirstate incorrectly
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 290
diff changeset
211 Path knownInDirstate;
226
26ad7827a62d Support status query for a single file or a subdirectory of a repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 219
diff changeset
212 if (!f.exists()) {
26ad7827a62d Support status query for a single file or a subdirectory of a repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 219
diff changeset
213 // file coming from iterator doesn't exist.
293
9774f47d904d Issue 13: Status reports filenames with case other than in dirstate incorrectly
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 290
diff changeset
214 if ((knownInDirstate = ds.known(fname)) != null) {
9774f47d904d Issue 13: Status reports filenames with case other than in dirstate incorrectly
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 290
diff changeset
215 // found in dirstate
9774f47d904d Issue 13: Status reports filenames with case other than in dirstate incorrectly
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 290
diff changeset
216 processed.add(knownInDirstate);
294
32890bab7209 Issue 13: Report filenames as they are known in repository rather than from file system
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 293
diff changeset
217 if (ds.checkRemoved(knownInDirstate) == null) {
32890bab7209 Issue 13: Report filenames as they are known in repository rather than from file system
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 293
diff changeset
218 inspector.missing(knownInDirstate);
226
26ad7827a62d Support status query for a single file or a subdirectory of a repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 219
diff changeset
219 } else {
294
32890bab7209 Issue 13: Report filenames as they are known in repository rather than from file system
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 293
diff changeset
220 inspector.removed(knownInDirstate);
226
26ad7827a62d Support status query for a single file or a subdirectory of a repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 219
diff changeset
221 }
26ad7827a62d Support status query for a single file or a subdirectory of a repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 219
diff changeset
222 // do not report it as removed later
26ad7827a62d Support status query for a single file or a subdirectory of a repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 219
diff changeset
223 if (collect != null) {
294
32890bab7209 Issue 13: Report filenames as they are known in repository rather than from file system
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 293
diff changeset
224 baseRevFiles.remove(knownInDirstate);
226
26ad7827a62d Support status query for a single file or a subdirectory of a repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 219
diff changeset
225 }
26ad7827a62d Support status query for a single file or a subdirectory of a repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 219
diff changeset
226 } else {
26ad7827a62d Support status query for a single file or a subdirectory of a repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 219
diff changeset
227 // chances are it was known in baseRevision. We may rely
26ad7827a62d Support status query for a single file or a subdirectory of a repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 219
diff changeset
228 // that later iteration over baseRevFiles leftovers would yield correct Removed,
26ad7827a62d Support status query for a single file or a subdirectory of a repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 219
diff changeset
229 // but it doesn't hurt to be explicit (provided we know fname *is* inScope of the FileIterator
285
6dbbc53fc46d Use Path instead of plain String for manifest file names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 284
diff changeset
230 if (collect != null && baseRevFiles.remove(fname)) {
226
26ad7827a62d Support status query for a single file or a subdirectory of a repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 219
diff changeset
231 inspector.removed(fname);
26ad7827a62d Support status query for a single file or a subdirectory of a repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 219
diff changeset
232 } else {
26ad7827a62d Support status query for a single file or a subdirectory of a repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 219
diff changeset
233 // not sure I shall report such files (i.e. arbitrary name coming from FileIterator)
26ad7827a62d Support status query for a single file or a subdirectory of a repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 219
diff changeset
234 // as unknown. Command-line HG aborts "system can't find the file specified"
26ad7827a62d Support status query for a single file or a subdirectory of a repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 219
diff changeset
235 // in similar case (against wc), or just gives nothing if --change <rev> is specified.
26ad7827a62d Support status query for a single file or a subdirectory of a repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 219
diff changeset
236 // however, as it's unlikely to get unexisting files from FileIterator, and
26ad7827a62d Support status query for a single file or a subdirectory of a repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 219
diff changeset
237 // its better to see erroneous file status rather than not to see any (which is too easy
26ad7827a62d Support status query for a single file or a subdirectory of a repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 219
diff changeset
238 // to overlook), I think unknown() is reasonable approach here
26ad7827a62d Support status query for a single file or a subdirectory of a repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 219
diff changeset
239 inspector.unknown(fname);
26ad7827a62d Support status query for a single file or a subdirectory of a repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 219
diff changeset
240 }
26ad7827a62d Support status query for a single file or a subdirectory of a repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 219
diff changeset
241 }
26ad7827a62d Support status query for a single file or a subdirectory of a repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 219
diff changeset
242 continue;
26ad7827a62d Support status query for a single file or a subdirectory of a repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 219
diff changeset
243 }
293
9774f47d904d Issue 13: Status reports filenames with case other than in dirstate incorrectly
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 290
diff changeset
244 if ((knownInDirstate = ds.known(fname)) != null) {
226
26ad7827a62d Support status query for a single file or a subdirectory of a repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 219
diff changeset
245 // tracked file.
58
4cfc47bc14cc Status against local working dir extracted into distinct class. Iterating over local files extracted for ease of os-dependant patching
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
246 // modified, added, removed, clean
293
9774f47d904d Issue 13: Status reports filenames with case other than in dirstate incorrectly
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 290
diff changeset
247 processed.add(knownInDirstate);
58
4cfc47bc14cc Status against local working dir extracted into distinct class. Iterating over local files extracted for ease of os-dependant patching
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
248 if (collect != null) { // need to check against base revision, not FS file
294
32890bab7209 Issue 13: Report filenames as they are known in repository rather than from file system
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 293
diff changeset
249 checkLocalStatusAgainstBaseRevision(baseRevFiles, collect, baseRevision, knownInDirstate, f, inspector);
58
4cfc47bc14cc Status against local working dir extracted into distinct class. Iterating over local files extracted for ease of os-dependant patching
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
250 } else {
294
32890bab7209 Issue 13: Report filenames as they are known in repository rather than from file system
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 293
diff changeset
251 checkLocalStatusAgainstFile(knownInDirstate, f, inspector);
58
4cfc47bc14cc Status against local working dir extracted into distinct class. Iterating over local files extracted for ease of os-dependant patching
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
252 }
4cfc47bc14cc Status against local working dir extracted into distinct class. Iterating over local files extracted for ease of os-dependant patching
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
253 } else {
226
26ad7827a62d Support status query for a single file or a subdirectory of a repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 219
diff changeset
254 if (hgIgnore.isIgnored(fname)) { // hgignore shall be consulted only for non-tracked files
26ad7827a62d Support status query for a single file or a subdirectory of a repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 219
diff changeset
255 inspector.ignored(fname);
26ad7827a62d Support status query for a single file or a subdirectory of a repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 219
diff changeset
256 } else {
26ad7827a62d Support status query for a single file or a subdirectory of a repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 219
diff changeset
257 inspector.unknown(fname);
26ad7827a62d Support status query for a single file or a subdirectory of a repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 219
diff changeset
258 }
26ad7827a62d Support status query for a single file or a subdirectory of a repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 219
diff changeset
259 // the file is not tracked. Even if it's known at baseRevision, we don't need to remove it
26ad7827a62d Support status query for a single file or a subdirectory of a repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 219
diff changeset
260 // from baseRevFiles, it might need to be reported as removed as well (cmdline client does
26ad7827a62d Support status query for a single file or a subdirectory of a repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 219
diff changeset
261 // yield two statuses for the same file)
58
4cfc47bc14cc Status against local working dir extracted into distinct class. Iterating over local files extracted for ease of os-dependant patching
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
262 }
4cfc47bc14cc Status against local working dir extracted into distinct class. Iterating over local files extracted for ease of os-dependant patching
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
263 }
4cfc47bc14cc Status against local working dir extracted into distinct class. Iterating over local files extracted for ease of os-dependant patching
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
264 if (collect != null) {
285
6dbbc53fc46d Use Path instead of plain String for manifest file names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 284
diff changeset
265 for (Path fromBase : baseRevFiles) {
226
26ad7827a62d Support status query for a single file or a subdirectory of a repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 219
diff changeset
266 if (repoWalker.inScope(fromBase)) {
26ad7827a62d Support status query for a single file or a subdirectory of a repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 219
diff changeset
267 inspector.removed(fromBase);
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: 415
diff changeset
268 cs.checkCancelled();
226
26ad7827a62d Support status query for a single file or a subdirectory of a repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 219
diff changeset
269 }
58
4cfc47bc14cc Status against local working dir extracted into distinct class. Iterating over local files extracted for ease of os-dependant patching
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
270 }
4cfc47bc14cc Status against local working dir extracted into distinct class. Iterating over local files extracted for ease of os-dependant patching
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
271 }
293
9774f47d904d Issue 13: Status reports filenames with case other than in dirstate incorrectly
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 290
diff changeset
272 knownEntries.removeAll(processed);
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: 282
diff changeset
273 for (Path m : knownEntries) {
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: 282
diff changeset
274 if (!repoWalker.inScope(m)) {
226
26ad7827a62d Support status query for a single file or a subdirectory of a repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 219
diff changeset
275 // do not report as missing/removed those FileIterator doesn't care about.
26ad7827a62d Support status query for a single file or a subdirectory of a repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 219
diff changeset
276 continue;
26ad7827a62d Support status query for a single file or a subdirectory of a repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 219
diff changeset
277 }
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: 415
diff changeset
278 cs.checkCancelled();
74
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 68
diff changeset
279 // missing known file from a working dir
293
9774f47d904d Issue 13: Status reports filenames with case other than in dirstate incorrectly
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 290
diff changeset
280 if (ds.checkRemoved(m) == null) {
74
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 68
diff changeset
281 // not removed from the repository = 'deleted'
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: 282
diff changeset
282 inspector.missing(m);
74
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 68
diff changeset
283 } else {
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 68
diff changeset
284 // removed from the repo
76
658fa6b3a371 Fixed a defect when a file added and removed past some revision was reported as R for status against that rev
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 74
diff changeset
285 // if we check against non-tip revision, do not report files that were added past that revision and now removed.
285
6dbbc53fc46d Use Path instead of plain String for manifest file names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 284
diff changeset
286 if (collect == null || baseRevFiles.contains(m)) {
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: 282
diff changeset
287 inspector.removed(m);
76
658fa6b3a371 Fixed a defect when a file added and removed past some revision was reported as R for status against that rev
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 74
diff changeset
288 }
58
4cfc47bc14cc Status against local working dir extracted into distinct class. Iterating over local files extracted for ease of os-dependant patching
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
289 }
4cfc47bc14cc Status against local working dir extracted into distinct class. Iterating over local files extracted for ease of os-dependant patching
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
290 }
4cfc47bc14cc Status against local working dir extracted into distinct class. Iterating over local files extracted for ease of os-dependant patching
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
291 }
4cfc47bc14cc Status against local working dir extracted into distinct class. Iterating over local files extracted for ease of os-dependant patching
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
292
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: 415
diff changeset
293 /**
429
cd658b24a620 FIXMEs: javadoc, proper use of constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 425
diff changeset
294 * A {@link #walk(int, HgStatusInspector)} that records all the status information in the {@link HgStatusCollector.Record} object.
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: 415
diff changeset
295 *
429
cd658b24a620 FIXMEs: javadoc, proper use of constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 425
diff changeset
296 * @see #walk(int, HgStatusInspector)
cd658b24a620 FIXMEs: javadoc, proper use of constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 425
diff changeset
297 * @param baseRevision revision index to check against, or {@link HgRepository#WORKING_COPY}. Note, {@link HgRepository#TIP} is not supported.
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: 415
diff changeset
298 * @return information object that describes change between the revisions
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: 415
diff changeset
299 * @throws IOException to propagate IO errors from {@link FileIterator}
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: 415
diff changeset
300 * @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: 415
diff changeset
301 */
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: 415
diff changeset
302 public HgStatusCollector.Record status(int baseRevision) throws IOException, HgRuntimeException {
94
af1f3b78b918 *StatusCollector renamed to Hg*StatusCollector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 93
diff changeset
303 HgStatusCollector.Record rv = new HgStatusCollector.Record();
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: 415
diff changeset
304 try {
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: 415
diff changeset
305 walk(baseRevision, rv);
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: 415
diff changeset
306 } catch (CancelledException ex) {
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: 415
diff changeset
307 // can't happen as long our Record class doesn't implement CancelSupport
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: 415
diff changeset
308 HgInvalidStateException t = new HgInvalidStateException("Internal error");
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: 415
diff changeset
309 t.initCause(ex);
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: 415
diff changeset
310 throw t;
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: 415
diff changeset
311 }
58
4cfc47bc14cc Status against local working dir extracted into distinct class. Iterating over local files extracted for ease of os-dependant patching
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
312 return rv;
4cfc47bc14cc Status against local working dir extracted into distinct class. Iterating over local files extracted for ease of os-dependant patching
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
313 }
4cfc47bc14cc Status against local working dir extracted into distinct class. Iterating over local files extracted for ease of os-dependant patching
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
314
4cfc47bc14cc Status against local working dir extracted into distinct class. Iterating over local files extracted for ease of os-dependant patching
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
315 //********************************************
4cfc47bc14cc Status against local working dir extracted into distinct class. Iterating over local files extracted for ease of os-dependant patching
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
316
4cfc47bc14cc Status against local working dir extracted into distinct class. Iterating over local files extracted for ease of os-dependant patching
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
317
287
ed6b74a58c66 Use FileInfo abstraction with necessary subset of File functionality instead of File to facilitate other effective file system iterators
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 285
diff changeset
318 private void checkLocalStatusAgainstFile(Path fname, FileInfo f, HgStatusInspector inspector) {
58
4cfc47bc14cc Status against local working dir extracted into distinct class. Iterating over local files extracted for ease of os-dependant patching
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
319 HgDirstate.Record r;
348
a0864b2892cd Expose errors reading mercurial control files with exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 337
diff changeset
320 if ((r = getDirstateImpl().checkNormal(fname)) != null) {
58
4cfc47bc14cc Status against local working dir extracted into distinct class. Iterating over local files extracted for ease of os-dependant patching
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
321 // either clean or modified
290
8faad08c709b Expose dirstate to allow pre-configuration of FileIterators for status collection in particular
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 287
diff changeset
322 final boolean timestampEqual = f.lastModified() == r.modificationTime(), sizeEqual = r.size() == f.length();
280
35125450c804 Erroneous and slow status for working copies based on non-tip revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 275
diff changeset
323 if (timestampEqual && sizeEqual) {
413
7f27122011c3 Support and respect for symbolic links and executable flag, with /bin/ls backed implementation to discover these
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 405
diff changeset
324 // if flags change (chmod -x), timestamp does not change
7f27122011c3 Support and respect for symbolic links and executable flag, with /bin/ls backed implementation to discover these
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 405
diff changeset
325 if (checkFlagsEqual(f, r.mode())) {
7f27122011c3 Support and respect for symbolic links and executable flag, with /bin/ls backed implementation to discover these
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 405
diff changeset
326 inspector.clean(fname);
7f27122011c3 Support and respect for symbolic links and executable flag, with /bin/ls backed implementation to discover these
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 405
diff changeset
327 } else {
7f27122011c3 Support and respect for symbolic links and executable flag, with /bin/ls backed implementation to discover these
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 405
diff changeset
328 inspector.modified(fname); // flags are not the same
7f27122011c3 Support and respect for symbolic links and executable flag, with /bin/ls backed implementation to discover these
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 405
diff changeset
329 }
290
8faad08c709b Expose dirstate to allow pre-configuration of FileIterators for status collection in particular
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 287
diff changeset
330 } else if (!sizeEqual && r.size() >= 0) {
280
35125450c804 Erroneous and slow status for working copies based on non-tip revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 275
diff changeset
331 inspector.modified(fname);
58
4cfc47bc14cc Status against local working dir extracted into distinct class. Iterating over local files extracted for ease of os-dependant patching
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
332 } else {
413
7f27122011c3 Support and respect for symbolic links and executable flag, with /bin/ls backed implementation to discover these
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 405
diff changeset
333 // size is the same or unknown, and, perhaps, different timestamp
7f27122011c3 Support and respect for symbolic links and executable flag, with /bin/ls backed implementation to discover these
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 405
diff changeset
334 // check actual content to avoid false modified files
397
5e95b0da26f2 Issue 24: IAE, Underflow in FilterDataAccess. Issue 26:UnsupportedOperationException when patching empty base revision. Tests
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 367
diff changeset
335 try {
413
7f27122011c3 Support and respect for symbolic links and executable flag, with /bin/ls backed implementation to discover these
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 405
diff changeset
336 if (!checkFlagsEqual(f, r.mode())) {
7f27122011c3 Support and respect for symbolic links and executable flag, with /bin/ls backed implementation to discover these
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 405
diff changeset
337 // flags modified, no need to do expensive content check
7f27122011c3 Support and respect for symbolic links and executable flag, with /bin/ls backed implementation to discover these
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 405
diff changeset
338 inspector.modified(fname);
397
5e95b0da26f2 Issue 24: IAE, Underflow in FilterDataAccess. Issue 26:UnsupportedOperationException when patching empty base revision. Tests
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 367
diff changeset
339 } else {
413
7f27122011c3 Support and respect for symbolic links and executable flag, with /bin/ls backed implementation to discover these
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 405
diff changeset
340 HgDataFile df = repo.getFileNode(fname);
7f27122011c3 Support and respect for symbolic links and executable flag, with /bin/ls backed implementation to discover these
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 405
diff changeset
341 if (!df.exists()) {
7f27122011c3 Support and respect for symbolic links and executable flag, with /bin/ls backed implementation to discover these
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 405
diff changeset
342 String msg = String.format("File %s known as normal in dirstate (%d, %d), doesn't exist at %s", fname, r.modificationTime(), r.size(), repo.getStoragePath(df));
7f27122011c3 Support and respect for symbolic links and executable flag, with /bin/ls backed implementation to discover these
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 405
diff changeset
343 throw new HgInvalidFileException(msg, null).setFileName(fname);
7f27122011c3 Support and respect for symbolic links and executable flag, with /bin/ls backed implementation to discover these
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 405
diff changeset
344 }
7f27122011c3 Support and respect for symbolic links and executable flag, with /bin/ls backed implementation to discover these
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 405
diff changeset
345 Nodeid rev = getDirstateParentManifest().nodeid(fname);
7f27122011c3 Support and respect for symbolic links and executable flag, with /bin/ls backed implementation to discover these
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 405
diff changeset
346 // rev might be null here if fname comes to dirstate as a result of a merge operation
7f27122011c3 Support and respect for symbolic links and executable flag, with /bin/ls backed implementation to discover these
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 405
diff changeset
347 // where one of the parents (first parent) had no fname file, but second parent had.
7f27122011c3 Support and respect for symbolic links and executable flag, with /bin/ls backed implementation to discover these
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 405
diff changeset
348 // E.g. fork revision 3, revision 4 gets .hgtags, few modifications and merge(3,12)
7f27122011c3 Support and respect for symbolic links and executable flag, with /bin/ls backed implementation to discover these
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 405
diff changeset
349 // see Issue 14 for details
7f27122011c3 Support and respect for symbolic links and executable flag, with /bin/ls backed implementation to discover these
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 405
diff changeset
350 if (rev == null || !areTheSame(f, df, rev)) {
7f27122011c3 Support and respect for symbolic links and executable flag, with /bin/ls backed implementation to discover these
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 405
diff changeset
351 inspector.modified(df.getPath());
7f27122011c3 Support and respect for symbolic links and executable flag, with /bin/ls backed implementation to discover these
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 405
diff changeset
352 } else {
7f27122011c3 Support and respect for symbolic links and executable flag, with /bin/ls backed implementation to discover these
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 405
diff changeset
353 inspector.clean(df.getPath());
7f27122011c3 Support and respect for symbolic links and executable flag, with /bin/ls backed implementation to discover these
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 405
diff changeset
354 }
397
5e95b0da26f2 Issue 24: IAE, Underflow in FilterDataAccess. Issue 26:UnsupportedOperationException when patching empty base revision. Tests
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 367
diff changeset
355 }
425
48f993aa2f41 FIXMEs: exceptions, javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 423
diff changeset
356 } catch (HgRuntimeException ex) {
397
5e95b0da26f2 Issue 24: IAE, Underflow in FilterDataAccess. Issue 26:UnsupportedOperationException when patching empty base revision. Tests
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 367
diff changeset
357 repo.getContext().getLog().warn(getClass(), ex, null);
5e95b0da26f2 Issue 24: IAE, Underflow in FilterDataAccess. Issue 26:UnsupportedOperationException when patching empty base revision. Tests
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 367
diff changeset
358 inspector.invalid(fname, ex);
120
b19f0ac5ee62 Check against working copy shall expect non-persistent modifications done by filters and not report such files as modified
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 117
diff changeset
359 }
58
4cfc47bc14cc Status against local working dir extracted into distinct class. Iterating over local files extracted for ease of os-dependant patching
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
360 }
348
a0864b2892cd Expose errors reading mercurial control files with exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 337
diff changeset
361 } else if ((r = getDirstateImpl().checkAdded(fname)) != null) {
290
8faad08c709b Expose dirstate to allow pre-configuration of FileIterators for status collection in particular
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 287
diff changeset
362 if (r.copySource() == null) {
280
35125450c804 Erroneous and slow status for working copies based on non-tip revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 275
diff changeset
363 inspector.added(fname);
58
4cfc47bc14cc Status against local working dir extracted into distinct class. Iterating over local files extracted for ease of os-dependant patching
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
364 } else {
290
8faad08c709b Expose dirstate to allow pre-configuration of FileIterators for status collection in particular
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 287
diff changeset
365 inspector.copied(r.copySource(), fname);
58
4cfc47bc14cc Status against local working dir extracted into distinct class. Iterating over local files extracted for ease of os-dependant patching
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
366 }
348
a0864b2892cd Expose errors reading mercurial control files with exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 337
diff changeset
367 } else if ((r = getDirstateImpl().checkRemoved(fname)) != null) {
280
35125450c804 Erroneous and slow status for working copies based on non-tip revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 275
diff changeset
368 inspector.removed(fname);
348
a0864b2892cd Expose errors reading mercurial control files with exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 337
diff changeset
369 } else if ((r = getDirstateImpl().checkMerged(fname)) != null) {
280
35125450c804 Erroneous and slow status for working copies based on non-tip revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 275
diff changeset
370 inspector.modified(fname);
58
4cfc47bc14cc Status against local working dir extracted into distinct class. Iterating over local files extracted for ease of os-dependant patching
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
371 }
4cfc47bc14cc Status against local working dir extracted into distinct class. Iterating over local files extracted for ease of os-dependant patching
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
372 }
4cfc47bc14cc Status against local working dir extracted into distinct class. Iterating over local files extracted for ease of os-dependant patching
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
373
4cfc47bc14cc Status against local working dir extracted into distinct class. Iterating over local files extracted for ease of os-dependant patching
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
374 // XXX refactor checkLocalStatus methods in more OO way
287
ed6b74a58c66 Use FileInfo abstraction with necessary subset of File functionality instead of File to facilitate other effective file system iterators
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 285
diff changeset
375 private void checkLocalStatusAgainstBaseRevision(Set<Path> baseRevNames, ManifestRevision collect, int baseRevision, Path fname, FileInfo f, HgStatusInspector inspector) {
58
4cfc47bc14cc Status against local working dir extracted into distinct class. Iterating over local files extracted for ease of os-dependant patching
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
376 // fname is in the dirstate, either Normal, Added, Removed or Merged
285
6dbbc53fc46d Use Path instead of plain String for manifest file names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 284
diff changeset
377 Nodeid nid1 = collect.nodeid(fname);
6dbbc53fc46d Use Path instead of plain String for manifest file names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 284
diff changeset
378 HgManifest.Flags flags = collect.flags(fname);
58
4cfc47bc14cc Status against local working dir extracted into distinct class. Iterating over local files extracted for ease of os-dependant patching
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
379 HgDirstate.Record r;
4cfc47bc14cc Status against local working dir extracted into distinct class. Iterating over local files extracted for ease of os-dependant patching
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
380 if (nid1 == null) {
4cfc47bc14cc Status against local working dir extracted into distinct class. Iterating over local files extracted for ease of os-dependant patching
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
381 // normal: added?
4cfc47bc14cc Status against local working dir extracted into distinct class. Iterating over local files extracted for ease of os-dependant patching
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
382 // added: not known at the time of baseRevision, shall report
4cfc47bc14cc Status against local working dir extracted into distinct class. Iterating over local files extracted for ease of os-dependant patching
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
383 // merged: was not known, report as added?
348
a0864b2892cd Expose errors reading mercurial control files with exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 337
diff changeset
384 if ((r = getDirstateImpl().checkNormal(fname)) != null) {
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>
parents: 148
diff changeset
385 try {
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>
parents: 148
diff changeset
386 Path origin = HgStatusCollector.getOriginIfCopy(repo, fname, baseRevNames, baseRevision);
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>
parents: 148
diff changeset
387 if (origin != null) {
226
26ad7827a62d Support status query for a single file or a subdirectory of a repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 219
diff changeset
388 inspector.copied(getPathPool().path(origin), fname);
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>
parents: 148
diff changeset
389 return;
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>
parents: 148
diff changeset
390 }
425
48f993aa2f41 FIXMEs: exceptions, javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 423
diff changeset
391 } catch (HgInvalidFileException ex) {
360
150500515714 Report non-critical errors during status operation to handler/inspector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 356
diff changeset
392 // report failure and continue status collection
150500515714 Report non-critical errors during status operation to handler/inspector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 356
diff changeset
393 inspector.invalid(fname, ex);
90
a95c700408a9 Correctly report copy/rename events for rev..working copy case
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 89
diff changeset
394 }
348
a0864b2892cd Expose errors reading mercurial control files with exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 337
diff changeset
395 } else if ((r = getDirstateImpl().checkAdded(fname)) != null) {
290
8faad08c709b Expose dirstate to allow pre-configuration of FileIterators for status collection in particular
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 287
diff changeset
396 if (r.copySource() != null && baseRevNames.contains(r.copySource())) {
8faad08c709b Expose dirstate to allow pre-configuration of FileIterators for status collection in particular
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 287
diff changeset
397 baseRevNames.remove(r.copySource()); // XXX surely I shall not report rename source as Removed?
8faad08c709b Expose dirstate to allow pre-configuration of FileIterators for status collection in particular
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 287
diff changeset
398 inspector.copied(r.copySource(), fname);
58
4cfc47bc14cc Status against local working dir extracted into distinct class. Iterating over local files extracted for ease of os-dependant patching
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
399 return;
4cfc47bc14cc Status against local working dir extracted into distinct class. Iterating over local files extracted for ease of os-dependant patching
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
400 }
4cfc47bc14cc Status against local working dir extracted into distinct class. Iterating over local files extracted for ease of os-dependant patching
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
401 // fall-through, report as added
348
a0864b2892cd Expose errors reading mercurial control files with exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 337
diff changeset
402 } else if (getDirstateImpl().checkRemoved(fname) != null) {
58
4cfc47bc14cc Status against local working dir extracted into distinct class. Iterating over local files extracted for ease of os-dependant patching
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
403 // removed: removed file was not known at the time of baseRevision, and we should not report it as removed
4cfc47bc14cc Status against local working dir extracted into distinct class. Iterating over local files extracted for ease of os-dependant patching
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
404 return;
4cfc47bc14cc Status against local working dir extracted into distinct class. Iterating over local files extracted for ease of os-dependant patching
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
405 }
226
26ad7827a62d Support status query for a single file or a subdirectory of a repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 219
diff changeset
406 inspector.added(fname);
58
4cfc47bc14cc Status against local working dir extracted into distinct class. Iterating over local files extracted for ease of os-dependant patching
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
407 } else {
4cfc47bc14cc Status against local working dir extracted into distinct class. Iterating over local files extracted for ease of os-dependant patching
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
408 // was known; check whether clean or modified
285
6dbbc53fc46d Use Path instead of plain String for manifest file names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 284
diff changeset
409 Nodeid nidFromDirstate = getDirstateParentManifest().nodeid(fname);
348
a0864b2892cd Expose errors reading mercurial control files with exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 337
diff changeset
410 if ((r = getDirstateImpl().checkNormal(fname)) != null && nid1.equals(nidFromDirstate)) {
282
e51dd9a14b6f Yet another WC status fix, where dirstate parent and base revision are treated right (dirstate parent other than tip and explicit baseRevision are not the same)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 280
diff changeset
411 // regular file, was the same up to WC initialization. Check if was modified since, and, if not, report right away
e51dd9a14b6f Yet another WC status fix, where dirstate parent and base revision are treated right (dirstate parent other than tip and explicit baseRevision are not the same)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 280
diff changeset
412 // same code as in #checkLocalStatusAgainstFile
290
8faad08c709b Expose dirstate to allow pre-configuration of FileIterators for status collection in particular
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 287
diff changeset
413 final boolean timestampEqual = f.lastModified() == r.modificationTime(), sizeEqual = r.size() == f.length();
282
e51dd9a14b6f Yet another WC status fix, where dirstate parent and base revision are treated right (dirstate parent other than tip and explicit baseRevision are not the same)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 280
diff changeset
414 boolean handled = false;
280
35125450c804 Erroneous and slow status for working copies based on non-tip revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 275
diff changeset
415 if (timestampEqual && sizeEqual) {
35125450c804 Erroneous and slow status for working copies based on non-tip revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 275
diff changeset
416 inspector.clean(fname);
282
e51dd9a14b6f Yet another WC status fix, where dirstate parent and base revision are treated right (dirstate parent other than tip and explicit baseRevision are not the same)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 280
diff changeset
417 handled = true;
290
8faad08c709b Expose dirstate to allow pre-configuration of FileIterators for status collection in particular
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 287
diff changeset
418 } else if (!sizeEqual && r.size() >= 0) {
280
35125450c804 Erroneous and slow status for working copies based on non-tip revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 275
diff changeset
419 inspector.modified(fname);
282
e51dd9a14b6f Yet another WC status fix, where dirstate parent and base revision are treated right (dirstate parent other than tip and explicit baseRevision are not the same)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 280
diff changeset
420 handled = true;
413
7f27122011c3 Support and respect for symbolic links and executable flag, with /bin/ls backed implementation to discover these
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 405
diff changeset
421 } else if (!checkFlagsEqual(f, flags)) {
282
e51dd9a14b6f Yet another WC status fix, where dirstate parent and base revision are treated right (dirstate parent other than tip and explicit baseRevision are not the same)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 280
diff changeset
422 // seems like flags have changed, no reason to check content further
e51dd9a14b6f Yet another WC status fix, where dirstate parent and base revision are treated right (dirstate parent other than tip and explicit baseRevision are not the same)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 280
diff changeset
423 inspector.modified(fname);
e51dd9a14b6f Yet another WC status fix, where dirstate parent and base revision are treated right (dirstate parent other than tip and explicit baseRevision are not the same)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 280
diff changeset
424 handled = true;
e51dd9a14b6f Yet another WC status fix, where dirstate parent and base revision are treated right (dirstate parent other than tip and explicit baseRevision are not the same)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 280
diff changeset
425 }
e51dd9a14b6f Yet another WC status fix, where dirstate parent and base revision are treated right (dirstate parent other than tip and explicit baseRevision are not the same)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 280
diff changeset
426 if (handled) {
285
6dbbc53fc46d Use Path instead of plain String for manifest file names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 284
diff changeset
427 baseRevNames.remove(fname); // consumed, processed, handled.
280
35125450c804 Erroneous and slow status for working copies based on non-tip revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 275
diff changeset
428 return;
35125450c804 Erroneous and slow status for working copies based on non-tip revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 275
diff changeset
429 }
282
e51dd9a14b6f Yet another WC status fix, where dirstate parent and base revision are treated right (dirstate parent other than tip and explicit baseRevision are not the same)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 280
diff changeset
430 // otherwise, shall check actual content (size not the same, or unknown (-1 or -2), or timestamp is different,
e51dd9a14b6f Yet another WC status fix, where dirstate parent and base revision are treated right (dirstate parent other than tip and explicit baseRevision are not the same)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 280
diff changeset
431 // or nodeid in dirstate is different, but local change might have brought it back to baseRevision state)
280
35125450c804 Erroneous and slow status for working copies based on non-tip revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 275
diff changeset
432 // FALL THROUGH
35125450c804 Erroneous and slow status for working copies based on non-tip revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 275
diff changeset
433 }
348
a0864b2892cd Expose errors reading mercurial control files with exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 337
diff changeset
434 if (r != null || (r = getDirstateImpl().checkMerged(fname)) != null || (r = getDirstateImpl().checkAdded(fname)) != null) {
397
5e95b0da26f2 Issue 24: IAE, Underflow in FilterDataAccess. Issue 26:UnsupportedOperationException when patching empty base revision. Tests
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 367
diff changeset
435 try {
5e95b0da26f2 Issue 24: IAE, Underflow in FilterDataAccess. Issue 26:UnsupportedOperationException when patching empty base revision. Tests
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 367
diff changeset
436 // check actual content to see actual changes
5e95b0da26f2 Issue 24: IAE, Underflow in FilterDataAccess. Issue 26:UnsupportedOperationException when patching empty base revision. Tests
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 367
diff changeset
437 // when added - seems to be the case of a file added once again, hence need to check if content is different
5e95b0da26f2 Issue 24: IAE, Underflow in FilterDataAccess. Issue 26:UnsupportedOperationException when patching empty base revision. Tests
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 367
diff changeset
438 // either clean or modified
5e95b0da26f2 Issue 24: IAE, Underflow in FilterDataAccess. Issue 26:UnsupportedOperationException when patching empty base revision. Tests
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 367
diff changeset
439 HgDataFile fileNode = repo.getFileNode(fname);
5e95b0da26f2 Issue 24: IAE, Underflow in FilterDataAccess. Issue 26:UnsupportedOperationException when patching empty base revision. Tests
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 367
diff changeset
440 if (areTheSame(f, fileNode, nid1)) {
5e95b0da26f2 Issue 24: IAE, Underflow in FilterDataAccess. Issue 26:UnsupportedOperationException when patching empty base revision. Tests
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 367
diff changeset
441 inspector.clean(fname);
5e95b0da26f2 Issue 24: IAE, Underflow in FilterDataAccess. Issue 26:UnsupportedOperationException when patching empty base revision. Tests
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 367
diff changeset
442 } else {
5e95b0da26f2 Issue 24: IAE, Underflow in FilterDataAccess. Issue 26:UnsupportedOperationException when patching empty base revision. Tests
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 367
diff changeset
443 inspector.modified(fname);
5e95b0da26f2 Issue 24: IAE, Underflow in FilterDataAccess. Issue 26:UnsupportedOperationException when patching empty base revision. Tests
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 367
diff changeset
444 }
425
48f993aa2f41 FIXMEs: exceptions, javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 423
diff changeset
445 } catch (HgRuntimeException ex) {
397
5e95b0da26f2 Issue 24: IAE, Underflow in FilterDataAccess. Issue 26:UnsupportedOperationException when patching empty base revision. Tests
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 367
diff changeset
446 repo.getContext().getLog().warn(getClass(), ex, null);
5e95b0da26f2 Issue 24: IAE, Underflow in FilterDataAccess. Issue 26:UnsupportedOperationException when patching empty base revision. Tests
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 367
diff changeset
447 inspector.invalid(fname, ex);
58
4cfc47bc14cc Status against local working dir extracted into distinct class. Iterating over local files extracted for ease of os-dependant patching
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
448 }
285
6dbbc53fc46d Use Path instead of plain String for manifest file names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 284
diff changeset
449 baseRevNames.remove(fname); // consumed, processed, handled.
348
a0864b2892cd Expose errors reading mercurial control files with exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 337
diff changeset
450 } else if (getDirstateImpl().checkRemoved(fname) != null) {
226
26ad7827a62d Support status query for a single file or a subdirectory of a repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 219
diff changeset
451 // was known, and now marked as removed, report it right away, do not rely on baseRevNames processing later
26ad7827a62d Support status query for a single file or a subdirectory of a repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 219
diff changeset
452 inspector.removed(fname);
285
6dbbc53fc46d Use Path instead of plain String for manifest file names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 284
diff changeset
453 baseRevNames.remove(fname); // consumed, processed, handled.
58
4cfc47bc14cc Status against local working dir extracted into distinct class. Iterating over local files extracted for ease of os-dependant patching
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
454 }
226
26ad7827a62d Support status query for a single file or a subdirectory of a repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 219
diff changeset
455 // only those left in baseRevNames after processing are reported as removed
58
4cfc47bc14cc Status against local working dir extracted into distinct class. Iterating over local files extracted for ease of os-dependant patching
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
456 }
4cfc47bc14cc Status against local working dir extracted into distinct class. Iterating over local files extracted for ease of os-dependant patching
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
457
4cfc47bc14cc Status against local working dir extracted into distinct class. Iterating over local files extracted for ease of os-dependant patching
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
458 // TODO think over if content comparison may be done more effectively by e.g. calculating nodeid for a local file and comparing it with nodeid from manifest
4cfc47bc14cc Status against local working dir extracted into distinct class. Iterating over local files extracted for ease of os-dependant patching
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
459 // we don't need to tell exact difference, hash should be enough to detect difference, and it doesn't involve reading historical file content, and it's relatively
4cfc47bc14cc Status against local working dir extracted into distinct class. Iterating over local files extracted for ease of os-dependant patching
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
460 // cheap to calc hash on a file (no need to keep it completely in memory). OTOH, if I'm right that the next approach is used for nodeids:
4cfc47bc14cc Status against local working dir extracted into distinct class. Iterating over local files extracted for ease of os-dependant patching
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
461 // changeset nodeid + hash(actual content) => entry (Nodeid) in the next Manifest
4cfc47bc14cc Status against local working dir extracted into distinct class. Iterating over local files extracted for ease of os-dependant patching
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
462 // then it's sufficient to check parents from dirstate, and if they do not match parents from file's baseRevision (non matching parents means different nodeids).
4cfc47bc14cc Status against local working dir extracted into distinct class. Iterating over local files extracted for ease of os-dependant patching
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
463 // The question is whether original Hg treats this case (same content, different parents and hence nodeids) as 'modified' or 'clean'
4cfc47bc14cc Status against local working dir extracted into distinct class. Iterating over local files extracted for ease of os-dependant patching
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
464 }
4cfc47bc14cc Status against local working dir extracted into distinct class. Iterating over local files extracted for ease of os-dependant patching
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
465
425
48f993aa2f41 FIXMEs: exceptions, javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 423
diff changeset
466 private boolean areTheSame(FileInfo f, HgDataFile dataFile, Nodeid revision) throws HgInvalidFileException {
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>
parents: 148
diff changeset
467 // XXX consider adding HgDataDile.compare(File/byte[]/whatever) operation to optimize comparison
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>
parents: 148
diff changeset
468 ByteArrayChannel bac = new ByteArrayChannel();
d5268ca7715b Merged branch wrap-data-access into default for resource-friendly data access. Updated API to promote that friendliness to clients (channels, not byte[]). More exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 148
diff changeset
469 try {
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
470 int fileRevisionIndex = dataFile.getRevisionIndex(revision);
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>
parents: 148
diff changeset
471 // need content with metadata striped off - although theoretically chances are metadata may be different,
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>
parents: 148
diff changeset
472 // WC doesn't have it anyway
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
473 dataFile.content(fileRevisionIndex, bac);
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>
parents: 148
diff changeset
474 } catch (CancelledException ex) {
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>
parents: 148
diff changeset
475 // silently ignore - can't happen, ByteArrayChannel is not cancellable
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>
parents: 148
diff changeset
476 }
397
5e95b0da26f2 Issue 24: IAE, Underflow in FilterDataAccess. Issue 26:UnsupportedOperationException when patching empty base revision. Tests
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 367
diff changeset
477 return areTheSame(f, bac.toArray(), dataFile.getPath());
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>
parents: 148
diff changeset
478 }
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>
parents: 148
diff changeset
479
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: 415
diff changeset
480 private boolean areTheSame(FileInfo f, final byte[] data, Path p) throws HgInvalidFileException {
287
ed6b74a58c66 Use FileInfo abstraction with necessary subset of File functionality instead of File to facilitate other effective file system iterators
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 285
diff changeset
481 ReadableByteChannel is = null;
295
981f9f50bb6c Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 294
diff changeset
482 class Check implements ByteChannel {
981f9f50bb6c Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 294
diff changeset
483 final boolean debug = repo.getContext().getLog().isDebug();
981f9f50bb6c Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 294
diff changeset
484 boolean sameSoFar = true;
981f9f50bb6c Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 294
diff changeset
485 int x = 0;
219
d63583b47bfa ArrayIndexOutOfBoundsException when file appended. Erroneous 'areTheSame' when trailing were deleted.
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 218
diff changeset
486
295
981f9f50bb6c Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 294
diff changeset
487 public int write(ByteBuffer buffer) {
981f9f50bb6c Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 294
diff changeset
488 for (int i = buffer.remaining(); i > 0; i--, x++) {
981f9f50bb6c Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 294
diff changeset
489 if (x >= data.length /*file has been appended*/ || data[x] != buffer.get()) {
981f9f50bb6c Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 294
diff changeset
490 if (debug) {
981f9f50bb6c Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 294
diff changeset
491 byte[] xx = new byte[15];
981f9f50bb6c Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 294
diff changeset
492 if (buffer.position() > 5) {
981f9f50bb6c Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 294
diff changeset
493 buffer.position(buffer.position() - 5);
117
6c0be854d149 Enable filters for status operation (ToRepo case)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 102
diff changeset
494 }
334
15e1961719f2 Investigate sporadic BufferUnderflowException
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 323
diff changeset
495 buffer.get(xx, 0, min(xx.length, i-1 /*-1 for the one potentially read at buffer.get in if() */));
15e1961719f2 Investigate sporadic BufferUnderflowException
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 323
diff changeset
496 String exp;
15e1961719f2 Investigate sporadic BufferUnderflowException
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 323
diff changeset
497 if (x < data.length) {
15e1961719f2 Investigate sporadic BufferUnderflowException
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 323
diff changeset
498 exp = new String(data, max(0, x - 4), min(data.length - x, 20));
15e1961719f2 Investigate sporadic BufferUnderflowException
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 323
diff changeset
499 } else {
15e1961719f2 Investigate sporadic BufferUnderflowException
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 323
diff changeset
500 int offset = max(0, x - 4);
15e1961719f2 Investigate sporadic BufferUnderflowException
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 323
diff changeset
501 exp = new String(data, offset, min(data.length - offset, 20));
15e1961719f2 Investigate sporadic BufferUnderflowException
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 323
diff changeset
502 }
15e1961719f2 Investigate sporadic BufferUnderflowException
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 323
diff changeset
503 repo.getContext().getLog().debug(getClass(), "expected >>%s<< but got >>%s<<", exp, new String(xx));
117
6c0be854d149 Enable filters for status operation (ToRepo case)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 102
diff changeset
504 }
295
981f9f50bb6c Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 294
diff changeset
505 sameSoFar = false;
981f9f50bb6c Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 294
diff changeset
506 break;
219
d63583b47bfa ArrayIndexOutOfBoundsException when file appended. Erroneous 'areTheSame' when trailing were deleted.
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 218
diff changeset
507 }
117
6c0be854d149 Enable filters for status operation (ToRepo case)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 102
diff changeset
508 }
295
981f9f50bb6c Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 294
diff changeset
509 buffer.position(buffer.limit()); // mark as read
981f9f50bb6c Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 294
diff changeset
510 return buffer.limit();
981f9f50bb6c Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 294
diff changeset
511 }
981f9f50bb6c Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 294
diff changeset
512
981f9f50bb6c Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 294
diff changeset
513 public boolean sameSoFar() {
981f9f50bb6c Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 294
diff changeset
514 return sameSoFar;
981f9f50bb6c Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 294
diff changeset
515 }
981f9f50bb6c Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 294
diff changeset
516 public boolean ultimatelyTheSame() {
981f9f50bb6c Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 294
diff changeset
517 return sameSoFar && x == data.length;
981f9f50bb6c Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 294
diff changeset
518 }
981f9f50bb6c Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 294
diff changeset
519 };
981f9f50bb6c Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 294
diff changeset
520 Check check = new Check();
981f9f50bb6c Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 294
diff changeset
521 try {
981f9f50bb6c Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 294
diff changeset
522 is = f.newInputChannel();
981f9f50bb6c Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 294
diff changeset
523 ByteBuffer fb = ByteBuffer.allocate(min(1 + data.length * 2 /*to fit couple of lines appended; never zero*/, 8192));
981f9f50bb6c Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 294
diff changeset
524 FilterByteChannel filters = new FilterByteChannel(check, repo.getFiltersFromWorkingDirToRepo(p));
356
91d75e1bac9f Consistent approach to deal with adaptable objects. Give adaptable precedence over instanceof to allow conditional response when classes do implement desired interface
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 355
diff changeset
525 Preview preview = Adaptable.Factory.getAdapter(filters, Preview.class, null);
355
f2c11fe7f3e9 Newline filter shall respect whole stream when deciding whether to process line terminators, hence added stream preview functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 354
diff changeset
526 if (preview != null) {
f2c11fe7f3e9 Newline filter shall respect whole stream when deciding whether to process line terminators, hence added stream preview functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 354
diff changeset
527 while (is.read(fb) != -1) {
f2c11fe7f3e9 Newline filter shall respect whole stream when deciding whether to process line terminators, hence added stream preview functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 354
diff changeset
528 fb.flip();
f2c11fe7f3e9 Newline filter shall respect whole stream when deciding whether to process line terminators, hence added stream preview functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 354
diff changeset
529 preview.preview(fb);
f2c11fe7f3e9 Newline filter shall respect whole stream when deciding whether to process line terminators, hence added stream preview functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 354
diff changeset
530 fb.clear();
f2c11fe7f3e9 Newline filter shall respect whole stream when deciding whether to process line terminators, hence added stream preview functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 354
diff changeset
531 }
f2c11fe7f3e9 Newline filter shall respect whole stream when deciding whether to process line terminators, hence added stream preview functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 354
diff changeset
532 // reset channel to read once again
f2c11fe7f3e9 Newline filter shall respect whole stream when deciding whether to process line terminators, hence added stream preview functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 354
diff changeset
533 try {
f2c11fe7f3e9 Newline filter shall respect whole stream when deciding whether to process line terminators, hence added stream preview functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 354
diff changeset
534 is.close();
f2c11fe7f3e9 Newline filter shall respect whole stream when deciding whether to process line terminators, hence added stream preview functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 354
diff changeset
535 } catch (IOException ex) {
f2c11fe7f3e9 Newline filter shall respect whole stream when deciding whether to process line terminators, hence added stream preview functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 354
diff changeset
536 repo.getContext().getLog().info(getClass(), ex, null);
f2c11fe7f3e9 Newline filter shall respect whole stream when deciding whether to process line terminators, hence added stream preview functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 354
diff changeset
537 }
f2c11fe7f3e9 Newline filter shall respect whole stream when deciding whether to process line terminators, hence added stream preview functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 354
diff changeset
538 is = f.newInputChannel();
f2c11fe7f3e9 Newline filter shall respect whole stream when deciding whether to process line terminators, hence added stream preview functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 354
diff changeset
539 fb.clear();
f2c11fe7f3e9 Newline filter shall respect whole stream when deciding whether to process line terminators, hence added stream preview functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 354
diff changeset
540 }
295
981f9f50bb6c Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 294
diff changeset
541 while (is.read(fb) != -1 && check.sameSoFar()) {
981f9f50bb6c Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 294
diff changeset
542 fb.flip();
981f9f50bb6c Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 294
diff changeset
543 filters.write(fb);
981f9f50bb6c Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 294
diff changeset
544 fb.compact();
981f9f50bb6c Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 294
diff changeset
545 }
981f9f50bb6c Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 294
diff changeset
546 return check.ultimatelyTheSame();
981f9f50bb6c Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 294
diff changeset
547 } catch (CancelledException ex) {
981f9f50bb6c Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 294
diff changeset
548 repo.getContext().getLog().warn(getClass(), ex, "Unexpected cancellation");
981f9f50bb6c Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 294
diff changeset
549 return check.ultimatelyTheSame();
981f9f50bb6c Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 294
diff changeset
550 } catch (IOException ex) {
397
5e95b0da26f2 Issue 24: IAE, Underflow in FilterDataAccess. Issue 26:UnsupportedOperationException when patching empty base revision. Tests
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 367
diff changeset
551 throw new HgInvalidFileException("File comparison failed", ex).setFileName(p);
295
981f9f50bb6c Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 294
diff changeset
552 } finally {
981f9f50bb6c Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 294
diff changeset
553 if (is != null) {
981f9f50bb6c Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 294
diff changeset
554 try {
287
ed6b74a58c66 Use FileInfo abstraction with necessary subset of File functionality instead of File to facilitate other effective file system iterators
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 285
diff changeset
555 is.close();
295
981f9f50bb6c Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 294
diff changeset
556 } catch (IOException ex) {
981f9f50bb6c Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 294
diff changeset
557 repo.getContext().getLog().info(getClass(), ex, null);
117
6c0be854d149 Enable filters for status operation (ToRepo case)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 102
diff changeset
558 }
6c0be854d149 Enable filters for status operation (ToRepo case)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 102
diff changeset
559 }
6c0be854d149 Enable filters for status operation (ToRepo case)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 102
diff changeset
560 }
6c0be854d149 Enable filters for status operation (ToRepo case)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 102
diff changeset
561 }
6c0be854d149 Enable filters for status operation (ToRepo case)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 102
diff changeset
562
413
7f27122011c3 Support and respect for symbolic links and executable flag, with /bin/ls backed implementation to discover these
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 405
diff changeset
563 /**
7f27122011c3 Support and respect for symbolic links and executable flag, with /bin/ls backed implementation to discover these
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 405
diff changeset
564 * @return <code>true</code> if flags are the same
7f27122011c3 Support and respect for symbolic links and executable flag, with /bin/ls backed implementation to discover these
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 405
diff changeset
565 */
7f27122011c3 Support and respect for symbolic links and executable flag, with /bin/ls backed implementation to discover these
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 405
diff changeset
566 private boolean checkFlagsEqual(FileInfo f, HgManifest.Flags originalManifestFlags) {
7f27122011c3 Support and respect for symbolic links and executable flag, with /bin/ls backed implementation to discover these
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 405
diff changeset
567 boolean same = true;
7f27122011c3 Support and respect for symbolic links and executable flag, with /bin/ls backed implementation to discover these
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 405
diff changeset
568 if (repoWalker.supportsLinkFlag()) {
7f27122011c3 Support and respect for symbolic links and executable flag, with /bin/ls backed implementation to discover these
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 405
diff changeset
569 if (originalManifestFlags == HgManifest.Flags.Link) {
7f27122011c3 Support and respect for symbolic links and executable flag, with /bin/ls backed implementation to discover these
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 405
diff changeset
570 return f.isSymlink();
7f27122011c3 Support and respect for symbolic links and executable flag, with /bin/ls backed implementation to discover these
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 405
diff changeset
571 }
7f27122011c3 Support and respect for symbolic links and executable flag, with /bin/ls backed implementation to discover these
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 405
diff changeset
572 // original flag is not link, hence flags are the same if file is not link, too.
7f27122011c3 Support and respect for symbolic links and executable flag, with /bin/ls backed implementation to discover these
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 405
diff changeset
573 same = !f.isSymlink();
7f27122011c3 Support and respect for symbolic links and executable flag, with /bin/ls backed implementation to discover these
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 405
diff changeset
574 } // otherwise treat flags the same
7f27122011c3 Support and respect for symbolic links and executable flag, with /bin/ls backed implementation to discover these
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 405
diff changeset
575 if (repoWalker.supportsExecFlag()) {
7f27122011c3 Support and respect for symbolic links and executable flag, with /bin/ls backed implementation to discover these
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 405
diff changeset
576 if (originalManifestFlags == HgManifest.Flags.Exec) {
7f27122011c3 Support and respect for symbolic links and executable flag, with /bin/ls backed implementation to discover these
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 405
diff changeset
577 return f.isExecutable();
7f27122011c3 Support and respect for symbolic links and executable flag, with /bin/ls backed implementation to discover these
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 405
diff changeset
578 }
7f27122011c3 Support and respect for symbolic links and executable flag, with /bin/ls backed implementation to discover these
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 405
diff changeset
579 // original flag has no executable attribute, hence file shall not be executable, too
7f27122011c3 Support and respect for symbolic links and executable flag, with /bin/ls backed implementation to discover these
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 405
diff changeset
580 same = same || !f.isExecutable();
7f27122011c3 Support and respect for symbolic links and executable flag, with /bin/ls backed implementation to discover these
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 405
diff changeset
581 }
7f27122011c3 Support and respect for symbolic links and executable flag, with /bin/ls backed implementation to discover these
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 405
diff changeset
582 return same;
7f27122011c3 Support and respect for symbolic links and executable flag, with /bin/ls backed implementation to discover these
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 405
diff changeset
583 }
7f27122011c3 Support and respect for symbolic links and executable flag, with /bin/ls backed implementation to discover these
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 405
diff changeset
584
7f27122011c3 Support and respect for symbolic links and executable flag, with /bin/ls backed implementation to discover these
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 405
diff changeset
585 private boolean checkFlagsEqual(FileInfo f, int dirstateFileMode) {
7f27122011c3 Support and respect for symbolic links and executable flag, with /bin/ls backed implementation to discover these
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 405
diff changeset
586 // source/include/linux/stat.h
7f27122011c3 Support and respect for symbolic links and executable flag, with /bin/ls backed implementation to discover these
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 405
diff changeset
587 final int S_IFLNK = 0120000, S_IXUSR = 00100;
7f27122011c3 Support and respect for symbolic links and executable flag, with /bin/ls backed implementation to discover these
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 405
diff changeset
588 // TODO post-1.0 HgManifest.Flags.parse(int)
7f27122011c3 Support and respect for symbolic links and executable flag, with /bin/ls backed implementation to discover these
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 405
diff changeset
589 if ((dirstateFileMode & S_IFLNK) == S_IFLNK) {
7f27122011c3 Support and respect for symbolic links and executable flag, with /bin/ls backed implementation to discover these
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 405
diff changeset
590 return checkFlagsEqual(f, HgManifest.Flags.Link);
7f27122011c3 Support and respect for symbolic links and executable flag, with /bin/ls backed implementation to discover these
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 405
diff changeset
591 }
7f27122011c3 Support and respect for symbolic links and executable flag, with /bin/ls backed implementation to discover these
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 405
diff changeset
592 if ((dirstateFileMode & S_IXUSR) == S_IXUSR) {
7f27122011c3 Support and respect for symbolic links and executable flag, with /bin/ls backed implementation to discover these
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 405
diff changeset
593 return checkFlagsEqual(f, HgManifest.Flags.Exec);
7f27122011c3 Support and respect for symbolic links and executable flag, with /bin/ls backed implementation to discover these
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 405
diff changeset
594 }
415
ee8264d80747 Explicit constant for regular file flags, access to flags for a given file revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 413
diff changeset
595 return checkFlagsEqual(f, HgManifest.Flags.RegularFile); // no flags
58
4cfc47bc14cc Status against local working dir extracted into distinct class. Iterating over local files extracted for ease of os-dependant patching
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
596 }
4cfc47bc14cc Status against local working dir extracted into distinct class. Iterating over local files extracted for ease of os-dependant patching
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
597
229
1ec6b327a6ac Scope for status reworked: explicit files or a general matcher
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 226
diff changeset
598 /**
1ec6b327a6ac Scope for status reworked: explicit files or a general matcher
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 226
diff changeset
599 * Configure status collector to consider only subset of a working copy tree. Tries to be as effective as possible, and to
1ec6b327a6ac Scope for status reworked: explicit files or a general matcher
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 226
diff changeset
600 * traverse only relevant part of working copy on the filesystem.
1ec6b327a6ac Scope for status reworked: explicit files or a general matcher
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 226
diff changeset
601 *
1ec6b327a6ac Scope for status reworked: explicit files or a general matcher
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 226
diff changeset
602 * @param hgRepo repository
1ec6b327a6ac Scope for status reworked: explicit files or a general matcher
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 226
diff changeset
603 * @param paths repository-relative files and/or directories. Directories are processed recursively.
1ec6b327a6ac Scope for status reworked: explicit files or a general matcher
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 226
diff changeset
604 *
1ec6b327a6ac Scope for status reworked: explicit files or a general matcher
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 226
diff changeset
605 * @return new instance of {@link HgWorkingCopyStatusCollector}, ready to {@link #walk(int, HgStatusInspector) walk} associated working copy
1ec6b327a6ac Scope for status reworked: explicit files or a general matcher
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 226
diff changeset
606 */
1ec6b327a6ac Scope for status reworked: explicit files or a general matcher
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 226
diff changeset
607 @Experimental(reason="Provisional API")
1ec6b327a6ac Scope for status reworked: explicit files or a general matcher
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 226
diff changeset
608 public static HgWorkingCopyStatusCollector create(HgRepository hgRepo, Path... paths) {
1ec6b327a6ac Scope for status reworked: explicit files or a general matcher
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 226
diff changeset
609 ArrayList<Path> f = new ArrayList<Path>(5);
1ec6b327a6ac Scope for status reworked: explicit files or a general matcher
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 226
diff changeset
610 ArrayList<Path> d = new ArrayList<Path>(5);
1ec6b327a6ac Scope for status reworked: explicit files or a general matcher
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 226
diff changeset
611 for (Path p : paths) {
1ec6b327a6ac Scope for status reworked: explicit files or a general matcher
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 226
diff changeset
612 if (p.isDirectory()) {
1ec6b327a6ac Scope for status reworked: explicit files or a general matcher
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 226
diff changeset
613 d.add(p);
1ec6b327a6ac Scope for status reworked: explicit files or a general matcher
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 226
diff changeset
614 } else {
1ec6b327a6ac Scope for status reworked: explicit files or a general matcher
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 226
diff changeset
615 f.add(p);
1ec6b327a6ac Scope for status reworked: explicit files or a general matcher
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 226
diff changeset
616 }
1ec6b327a6ac Scope for status reworked: explicit files or a general matcher
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 226
diff changeset
617 }
1ec6b327a6ac Scope for status reworked: explicit files or a general matcher
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 226
diff changeset
618 // final Path[] dirs = f.toArray(new Path[d.size()]);
1ec6b327a6ac Scope for status reworked: explicit files or a general matcher
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 226
diff changeset
619 if (d.isEmpty()) {
1ec6b327a6ac Scope for status reworked: explicit files or a general matcher
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 226
diff changeset
620 final Path[] files = f.toArray(new Path[f.size()]);
425
48f993aa2f41 FIXMEs: exceptions, javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 423
diff changeset
621 FileIterator fi = new FileListIterator(hgRepo.getContext(), hgRepo.getWorkingDir(), files);
229
1ec6b327a6ac Scope for status reworked: explicit files or a general matcher
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 226
diff changeset
622 return new HgWorkingCopyStatusCollector(hgRepo, fi);
1ec6b327a6ac Scope for status reworked: explicit files or a general matcher
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 226
diff changeset
623 }
1ec6b327a6ac Scope for status reworked: explicit files or a general matcher
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 226
diff changeset
624 //
1ec6b327a6ac Scope for status reworked: explicit files or a general matcher
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 226
diff changeset
625
1ec6b327a6ac Scope for status reworked: explicit files or a general matcher
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 226
diff changeset
626 //FileIterator fi = file.isDirectory() ? new DirFileIterator(hgRepo, file) : new FileListIterator(, file);
1ec6b327a6ac Scope for status reworked: explicit files or a general matcher
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 226
diff changeset
627 FileIterator fi = new HgInternals(hgRepo).createWorkingDirWalker(new PathScope(true, paths));
226
26ad7827a62d Support status query for a single file or a subdirectory of a repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 219
diff changeset
628 return new HgWorkingCopyStatusCollector(hgRepo, fi);
26ad7827a62d Support status query for a single file or a subdirectory of a repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 219
diff changeset
629 }
229
1ec6b327a6ac Scope for status reworked: explicit files or a general matcher
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 226
diff changeset
630
1ec6b327a6ac Scope for status reworked: explicit files or a general matcher
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 226
diff changeset
631 /**
1ec6b327a6ac Scope for status reworked: explicit files or a general matcher
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 226
diff changeset
632 * Configure collector object to calculate status for matching files only.
1ec6b327a6ac Scope for status reworked: explicit files or a general matcher
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 226
diff changeset
633 * This method may be less effective than explicit list of files as it iterates over whole repository
1ec6b327a6ac Scope for status reworked: explicit files or a general matcher
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 226
diff changeset
634 * (thus supplied matcher doesn't need to care if directories to files in question are also in scope,
1ec6b327a6ac Scope for status reworked: explicit files or a general matcher
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 226
diff changeset
635 * see {@link FileWalker#FileWalker(File, Path.Source, Path.Matcher)})
1ec6b327a6ac Scope for status reworked: explicit files or a general matcher
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 226
diff changeset
636 *
1ec6b327a6ac Scope for status reworked: explicit files or a general matcher
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 226
diff changeset
637 * @return new instance of {@link HgWorkingCopyStatusCollector}, ready to {@link #walk(int, HgStatusInspector) walk} associated working copy
1ec6b327a6ac Scope for status reworked: explicit files or a general matcher
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 226
diff changeset
638 */
1ec6b327a6ac Scope for status reworked: explicit files or a general matcher
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 226
diff changeset
639 @Experimental(reason="Provisional API. May add boolean strict argument for those who write smart matchers that can be used in FileWalker")
1ec6b327a6ac Scope for status reworked: explicit files or a general matcher
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 226
diff changeset
640 public static HgWorkingCopyStatusCollector create(HgRepository hgRepo, Path.Matcher scope) {
1ec6b327a6ac Scope for status reworked: explicit files or a general matcher
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 226
diff changeset
641 FileIterator w = new HgInternals(hgRepo).createWorkingDirWalker(null);
1ec6b327a6ac Scope for status reworked: explicit files or a general matcher
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 226
diff changeset
642 FileIterator wf = (scope == null || scope instanceof Path.Matcher.Any) ? w : new FileIteratorFilter(w, scope);
1ec6b327a6ac Scope for status reworked: explicit files or a general matcher
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 226
diff changeset
643 // the reason I need to iterate over full repo and apply filter is that I have no idea whatsoever about
1ec6b327a6ac Scope for status reworked: explicit files or a general matcher
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 226
diff changeset
644 // patterns in the scope. I.e. if scope lists a file (PathGlobMatcher("a/b/c.txt")), FileWalker won't get deep
1ec6b327a6ac Scope for status reworked: explicit files or a general matcher
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 226
diff changeset
645 // to the file unless matcher would also explicitly include "a/", "a/b/" in scope. Since I can't rely
1ec6b327a6ac Scope for status reworked: explicit files or a general matcher
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 226
diff changeset
646 // users would write robust matchers, and I don't see a decent way to enforce that (i.e. factory to produce
1ec6b327a6ac Scope for status reworked: explicit files or a general matcher
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 226
diff changeset
647 // correct matcher from Path is much like what PathScope does, and can be accessed directly with #create(repo, Path...)
1ec6b327a6ac Scope for status reworked: explicit files or a general matcher
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 226
diff changeset
648 // method above/
1ec6b327a6ac Scope for status reworked: explicit files or a general matcher
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 226
diff changeset
649 return new HgWorkingCopyStatusCollector(hgRepo, wf);
1ec6b327a6ac Scope for status reworked: explicit files or a general matcher
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 226
diff changeset
650 }
226
26ad7827a62d Support status query for a single file or a subdirectory of a repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 219
diff changeset
651
26ad7827a62d Support status query for a single file or a subdirectory of a repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 219
diff changeset
652 private static class FileListIterator implements FileIterator {
26ad7827a62d Support status query for a single file or a subdirectory of a repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 219
diff changeset
653 private final File dir;
26ad7827a62d Support status query for a single file or a subdirectory of a repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 219
diff changeset
654 private final Path[] paths;
26ad7827a62d Support status query for a single file or a subdirectory of a repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 219
diff changeset
655 private int index;
287
ed6b74a58c66 Use FileInfo abstraction with necessary subset of File functionality instead of File to facilitate other effective file system iterators
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 285
diff changeset
656 private RegularFileInfo nextFile;
413
7f27122011c3 Support and respect for symbolic links and executable flag, with /bin/ls backed implementation to discover these
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 405
diff changeset
657 private final boolean execCap, linkCap;
425
48f993aa2f41 FIXMEs: exceptions, javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 423
diff changeset
658 private final SessionContext sessionContext;
226
26ad7827a62d Support status query for a single file or a subdirectory of a repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 219
diff changeset
659
425
48f993aa2f41 FIXMEs: exceptions, javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 423
diff changeset
660 public FileListIterator(SessionContext ctx, File startDir, Path... files) {
48f993aa2f41 FIXMEs: exceptions, javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 423
diff changeset
661 sessionContext = ctx;
226
26ad7827a62d Support status query for a single file or a subdirectory of a repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 219
diff changeset
662 dir = startDir;
26ad7827a62d Support status query for a single file or a subdirectory of a repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 219
diff changeset
663 paths = files;
26ad7827a62d Support status query for a single file or a subdirectory of a repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 219
diff changeset
664 reset();
413
7f27122011c3 Support and respect for symbolic links and executable flag, with /bin/ls backed implementation to discover these
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 405
diff changeset
665 execCap = Internals.checkSupportsExecutables(startDir);
7f27122011c3 Support and respect for symbolic links and executable flag, with /bin/ls backed implementation to discover these
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 405
diff changeset
666 linkCap = Internals.checkSupportsSymlinks(startDir);
226
26ad7827a62d Support status query for a single file or a subdirectory of a repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 219
diff changeset
667 }
26ad7827a62d Support status query for a single file or a subdirectory of a repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 219
diff changeset
668
26ad7827a62d Support status query for a single file or a subdirectory of a repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 219
diff changeset
669 public void reset() {
26ad7827a62d Support status query for a single file or a subdirectory of a repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 219
diff changeset
670 index = -1;
425
48f993aa2f41 FIXMEs: exceptions, javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 423
diff changeset
671 nextFile = new RegularFileInfo(sessionContext, execCap, linkCap);
226
26ad7827a62d Support status query for a single file or a subdirectory of a repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 219
diff changeset
672 }
26ad7827a62d Support status query for a single file or a subdirectory of a repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 219
diff changeset
673
26ad7827a62d Support status query for a single file or a subdirectory of a repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 219
diff changeset
674 public boolean hasNext() {
26ad7827a62d Support status query for a single file or a subdirectory of a repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 219
diff changeset
675 return paths.length > 0 && index < paths.length-1;
26ad7827a62d Support status query for a single file or a subdirectory of a repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 219
diff changeset
676 }
26ad7827a62d Support status query for a single file or a subdirectory of a repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 219
diff changeset
677
26ad7827a62d Support status query for a single file or a subdirectory of a repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 219
diff changeset
678 public void next() {
26ad7827a62d Support status query for a single file or a subdirectory of a repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 219
diff changeset
679 index++;
26ad7827a62d Support status query for a single file or a subdirectory of a repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 219
diff changeset
680 if (index == paths.length) {
26ad7827a62d Support status query for a single file or a subdirectory of a repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 219
diff changeset
681 throw new NoSuchElementException();
26ad7827a62d Support status query for a single file or a subdirectory of a repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 219
diff changeset
682 }
287
ed6b74a58c66 Use FileInfo abstraction with necessary subset of File functionality instead of File to facilitate other effective file system iterators
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 285
diff changeset
683 nextFile.init(new File(dir, paths[index].toString()));
226
26ad7827a62d Support status query for a single file or a subdirectory of a repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 219
diff changeset
684 }
26ad7827a62d Support status query for a single file or a subdirectory of a repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 219
diff changeset
685
26ad7827a62d Support status query for a single file or a subdirectory of a repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 219
diff changeset
686 public Path name() {
26ad7827a62d Support status query for a single file or a subdirectory of a repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 219
diff changeset
687 return paths[index];
26ad7827a62d Support status query for a single file or a subdirectory of a repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 219
diff changeset
688 }
26ad7827a62d Support status query for a single file or a subdirectory of a repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 219
diff changeset
689
287
ed6b74a58c66 Use FileInfo abstraction with necessary subset of File functionality instead of File to facilitate other effective file system iterators
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 285
diff changeset
690 public FileInfo file() {
226
26ad7827a62d Support status query for a single file or a subdirectory of a repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 219
diff changeset
691 return nextFile;
26ad7827a62d Support status query for a single file or a subdirectory of a repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 219
diff changeset
692 }
26ad7827a62d Support status query for a single file or a subdirectory of a repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 219
diff changeset
693
26ad7827a62d Support status query for a single file or a subdirectory of a repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 219
diff changeset
694 public boolean inScope(Path file) {
26ad7827a62d Support status query for a single file or a subdirectory of a repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 219
diff changeset
695 for (int i = 0; i < paths.length; i++) {
26ad7827a62d Support status query for a single file or a subdirectory of a repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 219
diff changeset
696 if (paths[i].equals(file)) {
26ad7827a62d Support status query for a single file or a subdirectory of a repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 219
diff changeset
697 return true;
26ad7827a62d Support status query for a single file or a subdirectory of a repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 219
diff changeset
698 }
26ad7827a62d Support status query for a single file or a subdirectory of a repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 219
diff changeset
699 }
26ad7827a62d Support status query for a single file or a subdirectory of a repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 219
diff changeset
700 return false;
26ad7827a62d Support status query for a single file or a subdirectory of a repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 219
diff changeset
701 }
413
7f27122011c3 Support and respect for symbolic links and executable flag, with /bin/ls backed implementation to discover these
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 405
diff changeset
702
7f27122011c3 Support and respect for symbolic links and executable flag, with /bin/ls backed implementation to discover these
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 405
diff changeset
703 public boolean supportsExecFlag() {
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: 415
diff changeset
704 return execCap;
413
7f27122011c3 Support and respect for symbolic links and executable flag, with /bin/ls backed implementation to discover these
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 405
diff changeset
705 }
7f27122011c3 Support and respect for symbolic links and executable flag, with /bin/ls backed implementation to discover these
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 405
diff changeset
706
7f27122011c3 Support and respect for symbolic links and executable flag, with /bin/ls backed implementation to discover these
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 405
diff changeset
707 public boolean supportsLinkFlag() {
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: 415
diff changeset
708 return linkCap;
413
7f27122011c3 Support and respect for symbolic links and executable flag, with /bin/ls backed implementation to discover these
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 405
diff changeset
709 }
226
26ad7827a62d Support status query for a single file or a subdirectory of a repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 219
diff changeset
710 }
26ad7827a62d Support status query for a single file or a subdirectory of a repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 219
diff changeset
711
229
1ec6b327a6ac Scope for status reworked: explicit files or a general matcher
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 226
diff changeset
712 private static class FileIteratorFilter implements FileIterator {
1ec6b327a6ac Scope for status reworked: explicit files or a general matcher
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 226
diff changeset
713 private final Path.Matcher filter;
1ec6b327a6ac Scope for status reworked: explicit files or a general matcher
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 226
diff changeset
714 private final FileIterator walker;
1ec6b327a6ac Scope for status reworked: explicit files or a general matcher
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 226
diff changeset
715 private boolean didNext = false;
226
26ad7827a62d Support status query for a single file or a subdirectory of a repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 219
diff changeset
716
229
1ec6b327a6ac Scope for status reworked: explicit files or a general matcher
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 226
diff changeset
717 public FileIteratorFilter(FileIterator fileWalker, Path.Matcher filterMatcher) {
1ec6b327a6ac Scope for status reworked: explicit files or a general matcher
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 226
diff changeset
718 assert fileWalker != null;
1ec6b327a6ac Scope for status reworked: explicit files or a general matcher
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 226
diff changeset
719 assert filterMatcher != null;
1ec6b327a6ac Scope for status reworked: explicit files or a general matcher
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 226
diff changeset
720 filter = filterMatcher;
1ec6b327a6ac Scope for status reworked: explicit files or a general matcher
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 226
diff changeset
721 walker = fileWalker;
226
26ad7827a62d Support status query for a single file or a subdirectory of a repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 219
diff changeset
722 }
26ad7827a62d Support status query for a single file or a subdirectory of a repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 219
diff changeset
723
350
33eaed1ad130 Allow FileIterator report any errors from the underlaying file system up to the client
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 348
diff changeset
724 public void reset() throws IOException {
226
26ad7827a62d Support status query for a single file or a subdirectory of a repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 219
diff changeset
725 walker.reset();
26ad7827a62d Support status query for a single file or a subdirectory of a repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 219
diff changeset
726 }
26ad7827a62d Support status query for a single file or a subdirectory of a repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 219
diff changeset
727
350
33eaed1ad130 Allow FileIterator report any errors from the underlaying file system up to the client
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 348
diff changeset
728 public boolean hasNext() throws IOException {
229
1ec6b327a6ac Scope for status reworked: explicit files or a general matcher
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 226
diff changeset
729 while (walker.hasNext()) {
1ec6b327a6ac Scope for status reworked: explicit files or a general matcher
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 226
diff changeset
730 walker.next();
1ec6b327a6ac Scope for status reworked: explicit files or a general matcher
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 226
diff changeset
731 if (filter.accept(walker.name())) {
1ec6b327a6ac Scope for status reworked: explicit files or a general matcher
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 226
diff changeset
732 didNext = true;
1ec6b327a6ac Scope for status reworked: explicit files or a general matcher
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 226
diff changeset
733 return true;
1ec6b327a6ac Scope for status reworked: explicit files or a general matcher
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 226
diff changeset
734 }
1ec6b327a6ac Scope for status reworked: explicit files or a general matcher
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 226
diff changeset
735 }
1ec6b327a6ac Scope for status reworked: explicit files or a general matcher
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 226
diff changeset
736 return false;
226
26ad7827a62d Support status query for a single file or a subdirectory of a repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 219
diff changeset
737 }
26ad7827a62d Support status query for a single file or a subdirectory of a repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 219
diff changeset
738
350
33eaed1ad130 Allow FileIterator report any errors from the underlaying file system up to the client
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 348
diff changeset
739 public void next() throws IOException {
229
1ec6b327a6ac Scope for status reworked: explicit files or a general matcher
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 226
diff changeset
740 if (didNext) {
1ec6b327a6ac Scope for status reworked: explicit files or a general matcher
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 226
diff changeset
741 didNext = false;
1ec6b327a6ac Scope for status reworked: explicit files or a general matcher
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 226
diff changeset
742 } else {
1ec6b327a6ac Scope for status reworked: explicit files or a general matcher
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 226
diff changeset
743 if (!hasNext()) {
1ec6b327a6ac Scope for status reworked: explicit files or a general matcher
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 226
diff changeset
744 throw new NoSuchElementException();
1ec6b327a6ac Scope for status reworked: explicit files or a general matcher
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 226
diff changeset
745 }
1ec6b327a6ac Scope for status reworked: explicit files or a general matcher
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 226
diff changeset
746 }
226
26ad7827a62d Support status query for a single file or a subdirectory of a repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 219
diff changeset
747 }
26ad7827a62d Support status query for a single file or a subdirectory of a repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 219
diff changeset
748
26ad7827a62d Support status query for a single file or a subdirectory of a repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 219
diff changeset
749 public Path name() {
26ad7827a62d Support status query for a single file or a subdirectory of a repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 219
diff changeset
750 return walker.name();
26ad7827a62d Support status query for a single file or a subdirectory of a repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 219
diff changeset
751 }
26ad7827a62d Support status query for a single file or a subdirectory of a repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 219
diff changeset
752
287
ed6b74a58c66 Use FileInfo abstraction with necessary subset of File functionality instead of File to facilitate other effective file system iterators
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 285
diff changeset
753 public FileInfo file() {
226
26ad7827a62d Support status query for a single file or a subdirectory of a repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 219
diff changeset
754 return walker.file();
26ad7827a62d Support status query for a single file or a subdirectory of a repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 219
diff changeset
755 }
26ad7827a62d Support status query for a single file or a subdirectory of a repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 219
diff changeset
756
26ad7827a62d Support status query for a single file or a subdirectory of a repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 219
diff changeset
757 public boolean inScope(Path file) {
229
1ec6b327a6ac Scope for status reworked: explicit files or a general matcher
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 226
diff changeset
758 return filter.accept(file);
226
26ad7827a62d Support status query for a single file or a subdirectory of a repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 219
diff changeset
759 }
413
7f27122011c3 Support and respect for symbolic links and executable flag, with /bin/ls backed implementation to discover these
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 405
diff changeset
760
7f27122011c3 Support and respect for symbolic links and executable flag, with /bin/ls backed implementation to discover these
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 405
diff changeset
761 public boolean supportsExecFlag() {
7f27122011c3 Support and respect for symbolic links and executable flag, with /bin/ls backed implementation to discover these
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 405
diff changeset
762 return walker.supportsExecFlag();
7f27122011c3 Support and respect for symbolic links and executable flag, with /bin/ls backed implementation to discover these
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 405
diff changeset
763 }
7f27122011c3 Support and respect for symbolic links and executable flag, with /bin/ls backed implementation to discover these
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 405
diff changeset
764
7f27122011c3 Support and respect for symbolic links and executable flag, with /bin/ls backed implementation to discover these
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 405
diff changeset
765 public boolean supportsLinkFlag() {
7f27122011c3 Support and respect for symbolic links and executable flag, with /bin/ls backed implementation to discover these
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 405
diff changeset
766 return walker.supportsLinkFlag();
7f27122011c3 Support and respect for symbolic links and executable flag, with /bin/ls backed implementation to discover these
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 405
diff changeset
767 }
226
26ad7827a62d Support status query for a single file or a subdirectory of a repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 219
diff changeset
768 }
58
4cfc47bc14cc Status against local working dir extracted into distinct class. Iterating over local files extracted for ease of os-dependant patching
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
769 }