Mercurial > hg4j
annotate src/org/tmatesoft/hg/repo/HgWorkingCopyStatusCollector.java @ 713:661e77dc88ba tip
Mac support: respect Mac alternatives of command-line arguments for common unix tools
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Sun, 03 Aug 2014 18:09:00 +0200 |
parents | cf200271439a |
children |
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 /* |
537
5a455624be4f
Update javadoc for HgManifest.Inspector and fix erroneous internal API
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
506
diff
changeset
|
2 * Copyright (c) 2011-2013 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.*; |
456
909306e412e2
Refactor LogFacility and SessionContext, better API for both
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
431
diff
changeset
|
22 import static org.tmatesoft.hg.util.LogFacility.Severity.*; |
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
|
23 |
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.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
|
25 import java.io.IOException; |
117
6c0be854d149
Enable filters for status operation (ToRepo case)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
26 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
|
27 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
|
28 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
|
29 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
|
30 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
|
31 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
|
32 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
|
33 |
74
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
68
diff
changeset
|
34 import org.tmatesoft.hg.core.Nodeid; |
425
48f993aa2f41
FIXMEs: exceptions, javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
423
diff
changeset
|
35 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
|
36 import org.tmatesoft.hg.internal.ByteArrayChannel; |
628
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
613
diff
changeset
|
37 import org.tmatesoft.hg.internal.FileUtils; |
117
6c0be854d149
Enable filters for status operation (ToRepo case)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
38 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
|
39 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
|
40 import org.tmatesoft.hg.internal.ManifestRevision; |
431
12f668401613
FIXMEs: awkward API refactored, what need to be internal got hidden; public aspects got captured in slim interfaces
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
429
diff
changeset
|
41 import org.tmatesoft.hg.internal.PathPool; |
229
1ec6b327a6ac
Scope for status reworked: explicit files or a general matcher
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
226
diff
changeset
|
42 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
|
43 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
|
44 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
|
45 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
|
46 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
|
47 import org.tmatesoft.hg.util.CancelledException; |
431
12f668401613
FIXMEs: awkward API refactored, what need to be internal got hidden; public aspects got captured in slim interfaces
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
429
diff
changeset
|
48 import org.tmatesoft.hg.util.Convertor; |
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
|
49 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
|
50 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
|
51 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
|
52 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
|
53 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
|
54 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
|
55 |
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
|
56 /** |
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
|
57 * |
74
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
68
diff
changeset
|
58 * @author Artem Tikhomirov |
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
68
diff
changeset
|
59 * @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
|
60 */ |
94
af1f3b78b918
*StatusCollector renamed to Hg*StatusCollector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
93
diff
changeset
|
61 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
|
62 |
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
|
63 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
|
64 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
|
65 private HgDirstate dirstate; |
94
af1f3b78b918
*StatusCollector renamed to Hg*StatusCollector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
93
diff
changeset
|
66 private HgStatusCollector baseRevisionCollector; |
431
12f668401613
FIXMEs: awkward API refactored, what need to be internal got hidden; public aspects got captured in slim interfaces
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
429
diff
changeset
|
67 private Convertor<Path> 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
|
68 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
|
69 |
362
4937e35b805b
Report dirstate access error with Exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
360
diff
changeset
|
70 /** |
4937e35b805b
Report dirstate access error with Exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
360
diff
changeset
|
71 * Collector that iterates over complete working copy |
4937e35b805b
Report dirstate access error with Exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
360
diff
changeset
|
72 */ |
94
af1f3b78b918
*StatusCollector renamed to Hg*StatusCollector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
93
diff
changeset
|
73 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
|
74 this(hgRepo, new HgInternals(hgRepo).createWorkingDirWalker(null)); |
74
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
68
diff
changeset
|
75 } |
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
68
diff
changeset
|
76 |
362
4937e35b805b
Report dirstate access error with Exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
360
diff
changeset
|
77 /** |
4937e35b805b
Report dirstate access error with Exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
360
diff
changeset
|
78 * 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
|
79 * 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
|
80 * |
4937e35b805b
Report dirstate access error with Exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
360
diff
changeset
|
81 * @param hgRepo status target repository |
4937e35b805b
Report dirstate access error with Exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
360
diff
changeset
|
82 * @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
|
83 */ |
4937e35b805b
Report dirstate access error with Exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
360
diff
changeset
|
84 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
|
85 repo = hgRepo; |
362
4937e35b805b
Report dirstate access error with Exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
360
diff
changeset
|
86 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
|
87 } |
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
|
88 |
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 /** |
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 * 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
|
91 * @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
|
92 */ |
94
af1f3b78b918
*StatusCollector renamed to Hg*StatusCollector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
93
diff
changeset
|
93 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
|
94 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
|
95 } |
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
|
96 |
431
12f668401613
FIXMEs: awkward API refactored, what need to be internal got hidden; public aspects got captured in slim interfaces
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
429
diff
changeset
|
97 /*package-local*/ Convertor<Path> getPathPool() { |
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
|
98 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
|
99 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
|
100 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
|
101 } 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
|
102 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
|
103 } |
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 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
|
106 } |
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 |
431
12f668401613
FIXMEs: awkward API refactored, what need to be internal got hidden; public aspects got captured in slim interfaces
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
429
diff
changeset
|
108 public void setPathPool(Convertor<Path> pathConvertor) { |
12f668401613
FIXMEs: awkward API refactored, what need to be internal got hidden; public aspects got captured in slim interfaces
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
429
diff
changeset
|
109 pathPool = pathConvertor; |
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
|
110 } |
d55d4eedfc57
Switch to Path instead of String in filenames returned by various status operations
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
91
diff
changeset
|
111 |
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
|
112 /** |
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 * 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
|
114 * @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
|
115 */ |
348
a0864b2892cd
Expose errors reading mercurial control files with exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
337
diff
changeset
|
116 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
|
117 if (dirstate == null) { |
431
12f668401613
FIXMEs: awkward API refactored, what need to be internal got hidden; public aspects got captured in slim interfaces
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
429
diff
changeset
|
118 Convertor<Path> pp = getPathPool(); |
12f668401613
FIXMEs: awkward API refactored, what need to be internal got hidden; public aspects got captured in slim interfaces
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
429
diff
changeset
|
119 Path.Source ps; |
12f668401613
FIXMEs: awkward API refactored, what need to be internal got hidden; public aspects got captured in slim interfaces
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
429
diff
changeset
|
120 if (pp instanceof Path.Source) { |
12f668401613
FIXMEs: awkward API refactored, what need to be internal got hidden; public aspects got captured in slim interfaces
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
429
diff
changeset
|
121 ps = (Path.Source) pp; |
12f668401613
FIXMEs: awkward API refactored, what need to be internal got hidden; public aspects got captured in slim interfaces
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
429
diff
changeset
|
122 } else { |
12f668401613
FIXMEs: awkward API refactored, what need to be internal got hidden; public aspects got captured in slim interfaces
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
429
diff
changeset
|
123 ps = new Path.SimpleSource(new PathRewrite.Empty(), pp); |
12f668401613
FIXMEs: awkward API refactored, what need to be internal got hidden; public aspects got captured in slim interfaces
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
429
diff
changeset
|
124 } |
12f668401613
FIXMEs: awkward API refactored, what need to be internal got hidden; public aspects got captured in slim interfaces
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
429
diff
changeset
|
125 dirstate = repo.loadDirstate(ps); |
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
|
126 } |
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
|
127 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
|
128 } |
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
|
129 |
348
a0864b2892cd
Expose errors reading mercurial control files with exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
337
diff
changeset
|
130 private HgDirstate getDirstateImpl() { |
a0864b2892cd
Expose errors reading mercurial control files with exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
337
diff
changeset
|
131 return dirstate; |
a0864b2892cd
Expose errors reading mercurial control files with exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
337
diff
changeset
|
132 } |
a0864b2892cd
Expose errors reading mercurial control files with exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
337
diff
changeset
|
133 |
628
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
613
diff
changeset
|
134 private ManifestRevision getManifest(int changelogLocalRev) throws HgRuntimeException { |
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
|
135 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
|
136 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
|
137 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
|
138 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
|
139 } 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
|
140 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
|
141 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
|
142 } |
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
|
143 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
|
144 } |
354
5f9073eabf06
Propagate errors with exceptions up to a end client
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
350
diff
changeset
|
145 |
628
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
613
diff
changeset
|
146 private void initDirstateParentManifest() throws HgRuntimeException { |
354
5f9073eabf06
Propagate errors with exceptions up to a end client
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
350
diff
changeset
|
147 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
|
148 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
|
149 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
|
150 } 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
|
151 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
|
152 dirstateParentManifest = getManifest(changeloRevIndex); |
354
5f9073eabf06
Propagate errors with exceptions up to a end client
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
350
diff
changeset
|
153 } |
5f9073eabf06
Propagate errors with exceptions up to a end client
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
350
diff
changeset
|
154 } |
5f9073eabf06
Propagate errors with exceptions up to a end client
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
350
diff
changeset
|
155 |
5f9073eabf06
Propagate errors with exceptions up to a end client
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
350
diff
changeset
|
156 // 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
|
157 // 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
|
158 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
|
159 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
|
160 } |
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
|
161 |
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
|
162 /** |
429
cd658b24a620
FIXMEs: javadoc, proper use of constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
425
diff
changeset
|
163 * 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
|
164 * 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
|
165 * |
506
27398bbfd543
Experiment to add a facility to check working files for actual changes
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
496
diff
changeset
|
166 * <p>There's no dedicated constant for working copy parent, at least now. |
429
cd658b24a620
FIXMEs: javadoc, proper use of constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
425
diff
changeset
|
167 * 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
|
168 * 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
|
169 * justify a dedicated constant. |
cd658b24a620
FIXMEs: javadoc, proper use of constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
425
diff
changeset
|
170 * |
cd658b24a620
FIXMEs: javadoc, proper use of constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
425
diff
changeset
|
171 * @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
|
172 * @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
|
173 * @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
|
174 * @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
|
175 * @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
|
176 */ |
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
|
177 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
|
178 if (HgInternals.wrongRevisionIndex(baseRevision) || baseRevision == BAD_REVISION) { |
425
48f993aa2f41
FIXMEs: exceptions, javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
423
diff
changeset
|
179 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
|
180 } |
362
4937e35b805b
Report dirstate access error with Exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
360
diff
changeset
|
181 if (getDirstateImpl() == null) { |
4937e35b805b
Report dirstate access error with Exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
360
diff
changeset
|
182 getDirstate(); |
4937e35b805b
Report dirstate access error with Exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
360
diff
changeset
|
183 } |
4937e35b805b
Report dirstate access error with Exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
360
diff
changeset
|
184 if (getDirstateParentManifest() == null) { |
4937e35b805b
Report dirstate access error with Exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
360
diff
changeset
|
185 initDirstateParentManifest(); |
348
a0864b2892cd
Expose errors reading mercurial control files with exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
337
diff
changeset
|
186 } |
429
cd658b24a620
FIXMEs: javadoc, proper use of constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
425
diff
changeset
|
187 // 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
|
188 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
|
189 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
|
190 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
|
191 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
|
192 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
|
193 } |
94
af1f3b78b918
*StatusCollector renamed to Hg*StatusCollector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
93
diff
changeset
|
194 if (inspector instanceof HgStatusCollector.Record) { |
af1f3b78b918
*StatusCollector renamed to Hg*StatusCollector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
93
diff
changeset
|
195 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
|
196 // 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
|
197 // 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
|
198 // 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
|
199 // 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
|
200 // is done mostly not to leave stale initialization in the Record) |
537
5a455624be4f
Update javadoc for HgManifest.Inspector and fix erroneous internal API
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
506
diff
changeset
|
201 int rev1,rev2 = getDirstateParentManifest().changesetRevisionIndex(); |
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
|
202 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
|
203 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
|
204 } 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
|
205 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
|
206 } |
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
|
207 ((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
|
208 } |
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
|
209 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
|
210 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
|
211 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
|
212 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
|
213 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
|
214 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
|
215 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
|
216 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
|
217 repoWalker.next(); |
431
12f668401613
FIXMEs: awkward API refactored, what need to be internal got hidden; public aspects got captured in slim interfaces
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
429
diff
changeset
|
218 final Path fname = getPathPool().mangle(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
|
219 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
|
220 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
|
221 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
|
222 // 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
|
223 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
|
224 // 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
|
225 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
|
226 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
|
227 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
|
228 } 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
|
229 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
|
230 } |
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 // 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
|
232 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
|
233 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
|
234 } |
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 } 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
|
236 // 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
|
237 // 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
|
238 // 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
|
239 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
|
240 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
|
241 } 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
|
242 // 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
|
243 // 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
|
244 // 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
|
245 // 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
|
246 // 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
|
247 // 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
|
248 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
|
249 } |
26ad7827a62d
Support status query for a single file or a subdirectory of a repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
219
diff
changeset
|
250 } |
26ad7827a62d
Support status query for a single file or a subdirectory of a repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
219
diff
changeset
|
251 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
|
252 } |
293
9774f47d904d
Issue 13: Status reports filenames with case other than in dirstate incorrectly
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
290
diff
changeset
|
253 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
|
254 // 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
|
255 // 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
|
256 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
|
257 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
|
258 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
|
259 } 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
|
260 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
|
261 } |
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 } 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
|
263 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
|
264 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
|
265 } 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
|
266 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
|
267 } |
26ad7827a62d
Support status query for a single file or a subdirectory of a repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
219
diff
changeset
|
268 // 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
|
269 // 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
|
270 // 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
|
271 } |
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
|
272 } |
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
|
273 if (collect != null) { |
473
5c09a9f2e073
Issue 34: incorrect status for a file copy in wc against base rev
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
471
diff
changeset
|
274 // perhaps, this code shall go after processing leftovers of knownEntries, below |
5c09a9f2e073
Issue 34: incorrect status for a file copy in wc against base rev
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
471
diff
changeset
|
275 // as it's sort of last resort - what to do with otherwise unprocessed base revision files |
285
6dbbc53fc46d
Use Path instead of plain String for manifest file names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
284
diff
changeset
|
276 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
|
277 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
|
278 inspector.removed(fromBase); |
473
5c09a9f2e073
Issue 34: incorrect status for a file copy in wc against base rev
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
471
diff
changeset
|
279 processed.add(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
|
280 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
|
281 } |
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
|
282 } |
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
|
283 } |
293
9774f47d904d
Issue 13: Status reports filenames with case other than in dirstate incorrectly
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
290
diff
changeset
|
284 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
|
285 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
|
286 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
|
287 // 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
|
288 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
|
289 } |
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
|
290 cs.checkCancelled(); |
74
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
68
diff
changeset
|
291 // 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
|
292 if (ds.checkRemoved(m) == null) { |
74
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
68
diff
changeset
|
293 // 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
|
294 inspector.missing(m); |
74
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
68
diff
changeset
|
295 } else { |
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
68
diff
changeset
|
296 // 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
|
297 // 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
|
298 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
|
299 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
|
300 } |
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
|
301 } |
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
|
302 } |
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
|
303 } |
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
|
304 |
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
|
305 /** |
429
cd658b24a620
FIXMEs: javadoc, proper use of constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
425
diff
changeset
|
306 * 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
|
307 * |
429
cd658b24a620
FIXMEs: javadoc, proper use of constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
425
diff
changeset
|
308 * @see #walk(int, HgStatusInspector) |
cd658b24a620
FIXMEs: javadoc, proper use of constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
425
diff
changeset
|
309 * @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
|
310 * @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
|
311 * @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
|
312 * @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
|
313 */ |
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
|
314 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
|
315 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
|
316 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
|
317 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
|
318 } 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
|
319 // 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
|
320 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
|
321 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
|
322 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
|
323 } |
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
|
324 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
|
325 } |
506
27398bbfd543
Experiment to add a facility to check working files for actual changes
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
496
diff
changeset
|
326 |
27398bbfd543
Experiment to add a facility to check working files for actual changes
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
496
diff
changeset
|
327 /** |
27398bbfd543
Experiment to add a facility to check working files for actual changes
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
496
diff
changeset
|
328 * Compares file state from working directory against parent recorded in dirstate. |
27398bbfd543
Experiment to add a facility to check working files for actual changes
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
496
diff
changeset
|
329 * Might be handy for merged files, always reported as 'modified' or files deemed modified |
27398bbfd543
Experiment to add a facility to check working files for actual changes
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
496
diff
changeset
|
330 * based on their flags change. |
27398bbfd543
Experiment to add a facility to check working files for actual changes
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
496
diff
changeset
|
331 * |
27398bbfd543
Experiment to add a facility to check working files for actual changes
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
496
diff
changeset
|
332 * @param fname repository-relative path to the file in question |
27398bbfd543
Experiment to add a facility to check working files for actual changes
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
496
diff
changeset
|
333 * @param fileInfo file content mediator |
27398bbfd543
Experiment to add a facility to check working files for actual changes
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
496
diff
changeset
|
334 * @return <code>true</code> when content in working dir differs from that of manifest-recorded revision |
27398bbfd543
Experiment to add a facility to check working files for actual changes
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
496
diff
changeset
|
335 */ |
27398bbfd543
Experiment to add a facility to check working files for actual changes
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
496
diff
changeset
|
336 public boolean hasTangibleChanges(Path fname, FileInfo fileInfo) throws HgRuntimeException { |
27398bbfd543
Experiment to add a facility to check working files for actual changes
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
496
diff
changeset
|
337 // see #checkLocalStatusAgainstFile() below for the origin of changed file check |
27398bbfd543
Experiment to add a facility to check working files for actual changes
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
496
diff
changeset
|
338 HgDataFile df = repo.getFileNode(fname); |
27398bbfd543
Experiment to add a facility to check working files for actual changes
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
496
diff
changeset
|
339 if (!df.exists()) { |
27398bbfd543
Experiment to add a facility to check working files for actual changes
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
496
diff
changeset
|
340 throw new HgInvalidFileException("File not found", null).setFileName(fname); |
27398bbfd543
Experiment to add a facility to check working files for actual changes
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
496
diff
changeset
|
341 } |
27398bbfd543
Experiment to add a facility to check working files for actual changes
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
496
diff
changeset
|
342 Nodeid rev = getDirstateParentManifest().nodeid(fname); |
27398bbfd543
Experiment to add a facility to check working files for actual changes
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
496
diff
changeset
|
343 return rev == null || !areTheSame(fileInfo, df, rev); |
27398bbfd543
Experiment to add a facility to check working files for actual changes
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
496
diff
changeset
|
344 } |
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
|
345 |
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
|
346 //******************************************** |
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
|
347 |
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
|
348 |
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
|
349 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
|
350 HgDirstate.Record r; |
348
a0864b2892cd
Expose errors reading mercurial control files with exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
337
diff
changeset
|
351 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
|
352 // 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
|
353 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
|
354 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
|
355 // 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
|
356 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
|
357 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
|
358 } 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
|
359 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
|
360 } |
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
|
361 } 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
|
362 inspector.modified(fname); |
496
c1c8f6859d3f
Recognize 'merged from parent' metastate in dirstate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
493
diff
changeset
|
363 } else if (r.size() == -2) { |
c1c8f6859d3f
Recognize 'merged from parent' metastate in dirstate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
493
diff
changeset
|
364 // DirState wiki calls this np2 metastate: |
c1c8f6859d3f
Recognize 'merged from parent' metastate in dirstate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
493
diff
changeset
|
365 // 'np2': merged from other parent (status == 'n', size == -2) |
c1c8f6859d3f
Recognize 'merged from parent' metastate in dirstate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
493
diff
changeset
|
366 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
|
367 } 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
|
368 // 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
|
369 // 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
|
370 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
|
371 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
|
372 // 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
|
373 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
|
374 } 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
|
375 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
|
376 if (!df.exists()) { |
608
e1b29756f901
Clean, organize and resolve some TODOs and FIXMEs: minor refactorings and comments
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
537
diff
changeset
|
377 Internals implRepo = repo.getImplHelper(); |
493
ba36f66c32b4
Refactor to keep knowledge about repository control files and their location in respect to .hg/ in a single place (facilitate future adoption of shared repositories)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
490
diff
changeset
|
378 String msg = String.format("File %s known as normal in dirstate (%d, %d), doesn't exist at %s", fname, r.modificationTime(), r.size(), implRepo.getStoragePath(df)); |
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
|
379 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
|
380 } |
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
|
381 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
|
382 // 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
|
383 // 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
|
384 // 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
|
385 // 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
|
386 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
|
387 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
|
388 } 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
|
389 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
|
390 } |
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
|
391 } |
425
48f993aa2f41
FIXMEs: exceptions, javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
423
diff
changeset
|
392 } catch (HgRuntimeException ex) { |
490
b3c16d1aede0
Refactoring: move HgRepository's implementation aspects to Internals (which is now its imlementation counterpart and primary repository class to be used by other parts of the library)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
473
diff
changeset
|
393 repo.getSessionContext().getLog().dump(getClass(), Warn, ex, 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
|
394 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
|
395 } |
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
|
396 } |
348
a0864b2892cd
Expose errors reading mercurial control files with exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
337
diff
changeset
|
397 } 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
|
398 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
|
399 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
|
400 } 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
|
401 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
|
402 } |
348
a0864b2892cd
Expose errors reading mercurial control files with exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
337
diff
changeset
|
403 } 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
|
404 inspector.removed(fname); |
348
a0864b2892cd
Expose errors reading mercurial control files with exception
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
337
diff
changeset
|
405 } 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
|
406 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
|
407 } |
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 } |
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
|
409 |
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
|
410 // XXX refactor checkLocalStatus methods in more OO way |
628
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
613
diff
changeset
|
411 private void checkLocalStatusAgainstBaseRevision(Set<Path> baseRevNames, ManifestRevision collect, int baseRevision, Path fname, FileInfo f, HgStatusInspector inspector) throws HgRuntimeException { |
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
|
412 // 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
|
413 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
|
414 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
|
415 HgDirstate.Record r; |
471
7bcfbc255f48
Merge changes from smartgit3 branch into 1.1 stream
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
456
diff
changeset
|
416 final HgDirstate ds = getDirstateImpl(); |
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
|
417 if (nid1 == null) { |
471
7bcfbc255f48
Merge changes from smartgit3 branch into 1.1 stream
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
456
diff
changeset
|
418 // not known at the time of baseRevision: |
7bcfbc255f48
Merge changes from smartgit3 branch into 1.1 stream
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
456
diff
changeset
|
419 // normal, added, merged: either added or copied since base revision. |
7bcfbc255f48
Merge changes from smartgit3 branch into 1.1 stream
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
456
diff
changeset
|
420 // removed: nothing to report, |
7bcfbc255f48
Merge changes from smartgit3 branch into 1.1 stream
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
456
diff
changeset
|
421 if (ds.checkNormal(fname) != null || ds.checkMerged(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
|
422 try { |
694
7efabe0cddcf
Speed up (a) file rename history to minimize file reads; (b) file.isCopy(int) to read metadata for few revisions at once (use pattern assumes earlier revisions are likely to be queried, too); (c) HgIgnore.isIgnored by caching matched initial fragments (to substitute more expensive Matcher.matches with cheaper HashMap.contains)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
690
diff
changeset
|
423 // XXX perhaps, shall take second parent into account if not null, too? |
7efabe0cddcf
Speed up (a) file rename history to minimize file reads; (b) file.isCopy(int) to read metadata for few revisions at once (use pattern assumes earlier revisions are likely to be queried, too); (c) HgIgnore.isIgnored by caching matched initial fragments (to substitute more expensive Matcher.matches with cheaper HashMap.contains)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
690
diff
changeset
|
424 Nodeid nidFromDirstate = getDirstateParentManifest().nodeid(fname); |
7efabe0cddcf
Speed up (a) file rename history to minimize file reads; (b) file.isCopy(int) to read metadata for few revisions at once (use pattern assumes earlier revisions are likely to be queried, too); (c) HgIgnore.isIgnored by caching matched initial fragments (to substitute more expensive Matcher.matches with cheaper HashMap.contains)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
690
diff
changeset
|
425 if (nidFromDirstate != null) { |
689
5050ee565bd1
Issue 44: Renames/copies other than for the very first revision of a file are not recognized
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
654
diff
changeset
|
426 // see if file revision known in this parent got copied from one of baseRevNames |
694
7efabe0cddcf
Speed up (a) file rename history to minimize file reads; (b) file.isCopy(int) to read metadata for few revisions at once (use pattern assumes earlier revisions are likely to be queried, too); (c) HgIgnore.isIgnored by caching matched initial fragments (to substitute more expensive Matcher.matches with cheaper HashMap.contains)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
690
diff
changeset
|
427 Path origin = HgStatusCollector.getOriginIfCopy(repo, fname, nidFromDirstate, collect.files(), baseRevision); |
689
5050ee565bd1
Issue 44: Renames/copies other than for the very first revision of a file are not recognized
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
654
diff
changeset
|
428 if (origin != null) { |
5050ee565bd1
Issue 44: Renames/copies other than for the very first revision of a file are not recognized
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
654
diff
changeset
|
429 inspector.copied(getPathPool().mangle(origin), fname); |
5050ee565bd1
Issue 44: Renames/copies other than for the very first revision of a file are not recognized
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
654
diff
changeset
|
430 return; |
5050ee565bd1
Issue 44: Renames/copies other than for the very first revision of a file are not recognized
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
654
diff
changeset
|
431 } |
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
|
432 } |
471
7bcfbc255f48
Merge changes from smartgit3 branch into 1.1 stream
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
456
diff
changeset
|
433 // fall-through, report as added |
425
48f993aa2f41
FIXMEs: exceptions, javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
423
diff
changeset
|
434 } 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
|
435 // 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
|
436 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
|
437 } |
471
7bcfbc255f48
Merge changes from smartgit3 branch into 1.1 stream
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
456
diff
changeset
|
438 } else if ((r = ds.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
|
439 if (r.copySource() != null && baseRevNames.contains(r.copySource())) { |
473
5c09a9f2e073
Issue 34: incorrect status for a file copy in wc against base rev
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
471
diff
changeset
|
440 // shall not remove rename source from baseRevNames, as the source |
5c09a9f2e073
Issue 34: incorrect status for a file copy in wc against base rev
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
471
diff
changeset
|
441 // likely needs to be reported as Removed as well |
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
|
442 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
|
443 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
|
444 } |
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
|
445 // fall-through, report as added |
471
7bcfbc255f48
Merge changes from smartgit3 branch into 1.1 stream
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
456
diff
changeset
|
446 } else if (ds.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
|
447 // 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
|
448 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
|
449 } |
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
|
450 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
|
451 } 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
|
452 // 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
|
453 Nodeid nidFromDirstate = getDirstateParentManifest().nodeid(fname); |
471
7bcfbc255f48
Merge changes from smartgit3 branch into 1.1 stream
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
456
diff
changeset
|
454 if ((r = ds.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
|
455 // 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
|
456 // 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
|
457 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
|
458 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
|
459 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
|
460 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
|
461 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
|
462 } 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
|
463 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
|
464 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
|
465 } 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
|
466 // 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
|
467 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
|
468 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
|
469 } |
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
|
470 if (handled) { |
285
6dbbc53fc46d
Use Path instead of plain String for manifest file names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
284
diff
changeset
|
471 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
|
472 return; |
35125450c804
Erroneous and slow status for working copies based on non-tip revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
275
diff
changeset
|
473 } |
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
|
474 // 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
|
475 // 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
|
476 // 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
|
477 } |
471
7bcfbc255f48
Merge changes from smartgit3 branch into 1.1 stream
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
456
diff
changeset
|
478 if (r != null || (r = ds.checkMerged(fname)) != null || (r = ds.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
|
479 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
|
480 // 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
|
481 // 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
|
482 // 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
|
483 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
|
484 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
|
485 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
|
486 } 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
|
487 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
|
488 } |
425
48f993aa2f41
FIXMEs: exceptions, javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
423
diff
changeset
|
489 } catch (HgRuntimeException ex) { |
490
b3c16d1aede0
Refactoring: move HgRepository's implementation aspects to Internals (which is now its imlementation counterpart and primary repository class to be used by other parts of the library)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
473
diff
changeset
|
490 repo.getSessionContext().getLog().dump(getClass(), Warn, ex, 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
|
491 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
|
492 } |
285
6dbbc53fc46d
Use Path instead of plain String for manifest file names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
284
diff
changeset
|
493 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
|
494 } 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
|
495 // 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
|
496 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
|
497 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
|
498 } |
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
|
499 // 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
|
500 } |
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
|
501 |
608
e1b29756f901
Clean, organize and resolve some TODOs and FIXMEs: minor refactorings and comments
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
537
diff
changeset
|
502 // TODO [post-1.1] 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 |
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
|
503 // 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
|
504 // 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
|
505 // 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
|
506 // 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
|
507 // 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
|
508 } |
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
|
509 |
628
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
613
diff
changeset
|
510 private boolean areTheSame(FileInfo f, HgDataFile dataFile, Nodeid revision) throws HgRuntimeException { |
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
|
511 // 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
|
512 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
|
513 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
|
514 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
|
515 // 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
|
516 // 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
|
517 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
|
518 } 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
|
519 // 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
|
520 } |
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
|
521 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
|
522 } |
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
|
523 |
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
|
524 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
|
525 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
|
526 class Check implements ByteChannel { |
490
b3c16d1aede0
Refactoring: move HgRepository's implementation aspects to Internals (which is now its imlementation counterpart and primary repository class to be used by other parts of the library)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
473
diff
changeset
|
527 final boolean debug = repo.getSessionContext().getLog().isDebug(); |
295
981f9f50bb6c
Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
294
diff
changeset
|
528 boolean sameSoFar = true; |
981f9f50bb6c
Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
294
diff
changeset
|
529 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
|
530 |
295
981f9f50bb6c
Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
294
diff
changeset
|
531 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
|
532 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
|
533 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
|
534 if (debug) { |
981f9f50bb6c
Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
294
diff
changeset
|
535 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
|
536 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
|
537 buffer.position(buffer.position() - 5); |
117
6c0be854d149
Enable filters for status operation (ToRepo case)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
538 } |
334
15e1961719f2
Investigate sporadic BufferUnderflowException
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
323
diff
changeset
|
539 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
|
540 String exp; |
15e1961719f2
Investigate sporadic BufferUnderflowException
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
323
diff
changeset
|
541 if (x < data.length) { |
15e1961719f2
Investigate sporadic BufferUnderflowException
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
323
diff
changeset
|
542 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
|
543 } else { |
15e1961719f2
Investigate sporadic BufferUnderflowException
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
323
diff
changeset
|
544 int offset = max(0, x - 4); |
15e1961719f2
Investigate sporadic BufferUnderflowException
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
323
diff
changeset
|
545 exp = new String(data, offset, min(data.length - offset, 20)); |
15e1961719f2
Investigate sporadic BufferUnderflowException
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
323
diff
changeset
|
546 } |
490
b3c16d1aede0
Refactoring: move HgRepository's implementation aspects to Internals (which is now its imlementation counterpart and primary repository class to be used by other parts of the library)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
473
diff
changeset
|
547 repo.getSessionContext().getLog().dump(getClass(), Debug, "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
|
548 } |
295
981f9f50bb6c
Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
294
diff
changeset
|
549 sameSoFar = false; |
981f9f50bb6c
Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
294
diff
changeset
|
550 break; |
219
d63583b47bfa
ArrayIndexOutOfBoundsException when file appended. Erroneous 'areTheSame' when trailing were deleted.
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
218
diff
changeset
|
551 } |
117
6c0be854d149
Enable filters for status operation (ToRepo case)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
552 } |
295
981f9f50bb6c
Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
294
diff
changeset
|
553 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
|
554 return buffer.limit(); |
981f9f50bb6c
Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
294
diff
changeset
|
555 } |
981f9f50bb6c
Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
294
diff
changeset
|
556 |
981f9f50bb6c
Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
294
diff
changeset
|
557 public boolean sameSoFar() { |
981f9f50bb6c
Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
294
diff
changeset
|
558 return sameSoFar; |
981f9f50bb6c
Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
294
diff
changeset
|
559 } |
981f9f50bb6c
Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
294
diff
changeset
|
560 public boolean ultimatelyTheSame() { |
981f9f50bb6c
Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
294
diff
changeset
|
561 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
|
562 } |
981f9f50bb6c
Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
294
diff
changeset
|
563 }; |
981f9f50bb6c
Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
294
diff
changeset
|
564 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
|
565 try { |
981f9f50bb6c
Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
294
diff
changeset
|
566 is = f.newInputChannel(); |
710
cf200271439a
KeywordFilter: 'IllegalStateException: need buffer of at least...' during status op for a small file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
694
diff
changeset
|
567 // ByteBuffer fb = ByteBuffer.allocate(min(1 + data.length * 2 /*to fit couple of lines appended; never zero*/, 8192)); |
cf200271439a
KeywordFilter: 'IllegalStateException: need buffer of at least...' during status op for a small file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
694
diff
changeset
|
568 ByteBuffer fb = ByteBuffer.allocate(8192); // FIXME temp fix to ensure big enough buffer for KeywordFilter |
295
981f9f50bb6c
Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
294
diff
changeset
|
569 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
|
570 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
|
571 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
|
572 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
|
573 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
|
574 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
|
575 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
|
576 } |
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
|
577 // 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
|
578 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
|
579 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
|
580 } catch (IOException ex) { |
490
b3c16d1aede0
Refactoring: move HgRepository's implementation aspects to Internals (which is now its imlementation counterpart and primary repository class to be used by other parts of the library)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
473
diff
changeset
|
581 repo.getSessionContext().getLog().dump(getClass(), Info, ex, 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
|
582 } |
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
|
583 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
|
584 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
|
585 } |
295
981f9f50bb6c
Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
294
diff
changeset
|
586 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
|
587 fb.flip(); |
981f9f50bb6c
Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
294
diff
changeset
|
588 filters.write(fb); |
981f9f50bb6c
Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
294
diff
changeset
|
589 fb.compact(); |
981f9f50bb6c
Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
294
diff
changeset
|
590 } |
981f9f50bb6c
Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
294
diff
changeset
|
591 return check.ultimatelyTheSame(); |
981f9f50bb6c
Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
294
diff
changeset
|
592 } catch (CancelledException ex) { |
490
b3c16d1aede0
Refactoring: move HgRepository's implementation aspects to Internals (which is now its imlementation counterpart and primary repository class to be used by other parts of the library)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
473
diff
changeset
|
593 repo.getSessionContext().getLog().dump(getClass(), Warn, ex, "Unexpected cancellation"); |
295
981f9f50bb6c
Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
294
diff
changeset
|
594 return check.ultimatelyTheSame(); |
981f9f50bb6c
Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
294
diff
changeset
|
595 } 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
|
596 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
|
597 } finally { |
654
12a4f60ea972
1) Console push tool. 2) Pass class to blame into FileUtils
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
628
diff
changeset
|
598 new FileUtils(repo.getSessionContext().getLog(), this).closeQuietly(is); |
117
6c0be854d149
Enable filters for status operation (ToRepo case)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
599 } |
6c0be854d149
Enable filters for status operation (ToRepo case)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
600 } |
6c0be854d149
Enable filters for status operation (ToRepo case)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
601 |
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
|
602 /** |
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
|
603 * @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
|
604 */ |
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
|
605 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
|
606 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
|
607 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
|
608 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
|
609 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
|
610 } |
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
|
611 // 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
|
612 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
|
613 } // 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
|
614 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
|
615 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
|
616 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
|
617 } |
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
|
618 // 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
|
619 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
|
620 } |
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
|
621 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
|
622 } |
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
|
623 |
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
|
624 private boolean checkFlagsEqual(FileInfo f, int dirstateFileMode) { |
608
e1b29756f901
Clean, organize and resolve some TODOs and FIXMEs: minor refactorings and comments
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
537
diff
changeset
|
625 return checkFlagsEqual(f, HgManifest.Flags.parse(dirstateFileMode)); |
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
|
626 } |
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
|
627 |
229
1ec6b327a6ac
Scope for status reworked: explicit files or a general matcher
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
226
diff
changeset
|
628 /** |
1ec6b327a6ac
Scope for status reworked: explicit files or a general matcher
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
226
diff
changeset
|
629 * 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
|
630 * 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
|
631 * |
1ec6b327a6ac
Scope for status reworked: explicit files or a general matcher
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
226
diff
changeset
|
632 * @param hgRepo repository |
1ec6b327a6ac
Scope for status reworked: explicit files or a general matcher
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
226
diff
changeset
|
633 * @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
|
634 * |
1ec6b327a6ac
Scope for status reworked: explicit files or a general matcher
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
226
diff
changeset
|
635 * @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
|
636 */ |
1ec6b327a6ac
Scope for status reworked: explicit files or a general matcher
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
226
diff
changeset
|
637 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
|
638 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
|
639 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
|
640 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
|
641 if (p.isDirectory()) { |
1ec6b327a6ac
Scope for status reworked: explicit files or a general matcher
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
226
diff
changeset
|
642 d.add(p); |
1ec6b327a6ac
Scope for status reworked: explicit files or a general matcher
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
226
diff
changeset
|
643 } else { |
1ec6b327a6ac
Scope for status reworked: explicit files or a general matcher
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
226
diff
changeset
|
644 f.add(p); |
1ec6b327a6ac
Scope for status reworked: explicit files or a general matcher
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
226
diff
changeset
|
645 } |
1ec6b327a6ac
Scope for status reworked: explicit files or a general matcher
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
226
diff
changeset
|
646 } |
1ec6b327a6ac
Scope for status reworked: explicit files or a general matcher
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
226
diff
changeset
|
647 // 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
|
648 if (d.isEmpty()) { |
1ec6b327a6ac
Scope for status reworked: explicit files or a general matcher
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
226
diff
changeset
|
649 final Path[] files = f.toArray(new Path[f.size()]); |
490
b3c16d1aede0
Refactoring: move HgRepository's implementation aspects to Internals (which is now its imlementation counterpart and primary repository class to be used by other parts of the library)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
473
diff
changeset
|
650 FileIterator fi = new FileListIterator(hgRepo.getSessionContext(), 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
|
651 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
|
652 } |
1ec6b327a6ac
Scope for status reworked: explicit files or a general matcher
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
226
diff
changeset
|
653 // |
1ec6b327a6ac
Scope for status reworked: explicit files or a general matcher
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
226
diff
changeset
|
654 |
1ec6b327a6ac
Scope for status reworked: explicit files or a general matcher
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
226
diff
changeset
|
655 //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
|
656 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
|
657 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
|
658 } |
229
1ec6b327a6ac
Scope for status reworked: explicit files or a general matcher
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
226
diff
changeset
|
659 |
1ec6b327a6ac
Scope for status reworked: explicit files or a general matcher
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
226
diff
changeset
|
660 /** |
1ec6b327a6ac
Scope for status reworked: explicit files or a general matcher
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
226
diff
changeset
|
661 * 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
|
662 * 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
|
663 * (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
|
664 * 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
|
665 * |
1ec6b327a6ac
Scope for status reworked: explicit files or a general matcher
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
226
diff
changeset
|
666 * @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
|
667 */ |
1ec6b327a6ac
Scope for status reworked: explicit files or a general matcher
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
226
diff
changeset
|
668 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
|
669 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
|
670 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
|
671 // 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
|
672 // 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
|
673 // 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
|
674 // 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
|
675 // 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
|
676 // method above/ |
1ec6b327a6ac
Scope for status reworked: explicit files or a general matcher
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
226
diff
changeset
|
677 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
|
678 } |
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
|
679 |
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 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
|
681 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
|
682 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
|
683 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
|
684 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
|
685 private final boolean execCap, linkCap; |
425
48f993aa2f41
FIXMEs: exceptions, javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
423
diff
changeset
|
686 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
|
687 |
425
48f993aa2f41
FIXMEs: exceptions, javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
423
diff
changeset
|
688 public FileListIterator(SessionContext ctx, File startDir, Path... files) { |
48f993aa2f41
FIXMEs: exceptions, javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
423
diff
changeset
|
689 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
|
690 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
|
691 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
|
692 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
|
693 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
|
694 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
|
695 } |
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 |
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 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
|
698 index = -1; |
425
48f993aa2f41
FIXMEs: exceptions, javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
423
diff
changeset
|
699 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
|
700 } |
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 |
26ad7827a62d
Support status query for a single file or a subdirectory of a repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
219
diff
changeset
|
702 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
|
703 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
|
704 } |
26ad7827a62d
Support status query for a single file or a subdirectory of a repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
219
diff
changeset
|
705 |
26ad7827a62d
Support status query for a single file or a subdirectory of a repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
219
diff
changeset
|
706 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
|
707 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
|
708 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
|
709 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
|
710 } |
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
|
711 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
|
712 } |
26ad7827a62d
Support status query for a single file or a subdirectory of a repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
219
diff
changeset
|
713 |
26ad7827a62d
Support status query for a single file or a subdirectory of a repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
219
diff
changeset
|
714 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
|
715 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
|
716 } |
26ad7827a62d
Support status query for a single file or a subdirectory of a repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
219
diff
changeset
|
717 |
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
|
718 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
|
719 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
|
720 } |
26ad7827a62d
Support status query for a single file or a subdirectory of a repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
219
diff
changeset
|
721 |
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 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
|
723 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
|
724 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
|
725 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
|
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 } |
26ad7827a62d
Support status query for a single file or a subdirectory of a repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
219
diff
changeset
|
728 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
|
729 } |
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
|
730 |
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
|
731 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
|
732 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
|
733 } |
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
|
734 |
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
|
735 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
|
736 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
|
737 } |
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
|
738 } |
26ad7827a62d
Support status query for a single file or a subdirectory of a repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
219
diff
changeset
|
739 |
229
1ec6b327a6ac
Scope for status reworked: explicit files or a general matcher
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
226
diff
changeset
|
740 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
|
741 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
|
742 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
|
743 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
|
744 |
229
1ec6b327a6ac
Scope for status reworked: explicit files or a general matcher
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
226
diff
changeset
|
745 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
|
746 assert fileWalker != null; |
1ec6b327a6ac
Scope for status reworked: explicit files or a general matcher
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
226
diff
changeset
|
747 assert filterMatcher != null; |
1ec6b327a6ac
Scope for status reworked: explicit files or a general matcher
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
226
diff
changeset
|
748 filter = filterMatcher; |
1ec6b327a6ac
Scope for status reworked: explicit files or a general matcher
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
226
diff
changeset
|
749 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
|
750 } |
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 |
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
|
752 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
|
753 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
|
754 } |
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 |
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
|
756 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
|
757 while (walker.hasNext()) { |
1ec6b327a6ac
Scope for status reworked: explicit files or a general matcher
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
226
diff
changeset
|
758 walker.next(); |
1ec6b327a6ac
Scope for status reworked: explicit files or a general matcher
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
226
diff
changeset
|
759 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
|
760 didNext = true; |
1ec6b327a6ac
Scope for status reworked: explicit files or a general matcher
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
226
diff
changeset
|
761 return true; |
1ec6b327a6ac
Scope for status reworked: explicit files or a general matcher
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
226
diff
changeset
|
762 } |
1ec6b327a6ac
Scope for status reworked: explicit files or a general matcher
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
226
diff
changeset
|
763 } |
1ec6b327a6ac
Scope for status reworked: explicit files or a general matcher
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
226
diff
changeset
|
764 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
|
765 } |
26ad7827a62d
Support status query for a single file or a subdirectory of a repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
219
diff
changeset
|
766 |
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
|
767 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
|
768 if (didNext) { |
1ec6b327a6ac
Scope for status reworked: explicit files or a general matcher
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
226
diff
changeset
|
769 didNext = false; |
1ec6b327a6ac
Scope for status reworked: explicit files or a general matcher
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
226
diff
changeset
|
770 } else { |
1ec6b327a6ac
Scope for status reworked: explicit files or a general matcher
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
226
diff
changeset
|
771 if (!hasNext()) { |
1ec6b327a6ac
Scope for status reworked: explicit files or a general matcher
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
226
diff
changeset
|
772 throw new NoSuchElementException(); |
1ec6b327a6ac
Scope for status reworked: explicit files or a general matcher
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
226
diff
changeset
|
773 } |
1ec6b327a6ac
Scope for status reworked: explicit files or a general matcher
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
226
diff
changeset
|
774 } |
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
|
775 } |
26ad7827a62d
Support status query for a single file or a subdirectory of a repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
219
diff
changeset
|
776 |
26ad7827a62d
Support status query for a single file or a subdirectory of a repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
219
diff
changeset
|
777 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
|
778 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
|
779 } |
26ad7827a62d
Support status query for a single file or a subdirectory of a repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
219
diff
changeset
|
780 |
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
|
781 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
|
782 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
|
783 } |
26ad7827a62d
Support status query for a single file or a subdirectory of a repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
219
diff
changeset
|
784 |
26ad7827a62d
Support status query for a single file or a subdirectory of a repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
219
diff
changeset
|
785 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
|
786 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
|
787 } |
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
|
788 |
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
|
789 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
|
790 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
|
791 } |
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
|
792 |
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
|
793 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
|
794 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
|
795 } |
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
|
796 } |
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
|
797 } |