Mercurial > hg4j
annotate src/org/tmatesoft/hg/repo/HgWorkingCopyStatusCollector.java @ 247:f052f40839ec
Issue 9: NPE in getModificationDate for files with status 'Unknown'
| author | Artem Tikhomirov <tikhomirov.artem@gmail.com> | 
|---|---|
| date | Fri, 12 Aug 2011 17:17:37 +0200 | 
| parents | ff4fdbab4e2d | 
| children | 3fbfce107f94 | 
| 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 /* | 
| 74 
6f1b88693d48
Complete refactoring to org.tmatesoft
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
68diff
changeset | 2 * Copyright (c) 2011 TMate Software Ltd | 
| 
6f1b88693d48
Complete refactoring to org.tmatesoft
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
68diff
changeset | 3 * | 
| 
6f1b88693d48
Complete refactoring to org.tmatesoft
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
68diff
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: 
68diff
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: 
68diff
changeset | 6 * the Free Software Foundation; version 2 of the License. | 
| 
6f1b88693d48
Complete refactoring to org.tmatesoft
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
68diff
changeset | 7 * | 
| 
6f1b88693d48
Complete refactoring to org.tmatesoft
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
68diff
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: 
68diff
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: 
68diff
changeset | 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 
| 
6f1b88693d48
Complete refactoring to org.tmatesoft
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
68diff
changeset | 11 * GNU General Public License for more details. | 
| 
6f1b88693d48
Complete refactoring to org.tmatesoft
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
68diff
changeset | 12 * | 
| 
6f1b88693d48
Complete refactoring to org.tmatesoft
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
68diff
changeset | 13 * For information on how to redistribute this software under | 
| 
6f1b88693d48
Complete refactoring to org.tmatesoft
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
68diff
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: 
94diff
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: 
68diff
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: 
117diff
changeset | 19 import static java.lang.Math.max; | 
| 117 
6c0be854d149
Enable filters for status operation (ToRepo case)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
102diff
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: 
195diff
changeset | 21 import static org.tmatesoft.hg.repo.HgRepository.*; | 
| 58 
4cfc47bc14cc
Status against local working dir extracted into distinct class. Iterating over local files extracted for ease of os-dependant patching
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 22 | 
| 
4cfc47bc14cc
Status against local working dir extracted into distinct class. Iterating over local files extracted for ease of os-dependant patching
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 23 import java.io.File; | 
| 
4cfc47bc14cc
Status against local working dir extracted into distinct class. Iterating over local files extracted for ease of os-dependant patching
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 24 import java.io.FileInputStream; | 
| 
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: 
102diff
changeset | 26 import java.nio.ByteBuffer; | 
| 
6c0be854d149
Enable filters for status operation (ToRepo case)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
102diff
changeset | 27 import java.nio.channels.FileChannel; | 
| 229 
1ec6b327a6ac
Scope for status reworked: explicit files or a general matcher
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
226diff
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: 
219diff
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 | 
| 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: 
148diff
changeset | 34 import org.tmatesoft.hg.core.HgDataStreamException; | 
| 
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: 
148diff
changeset | 35 import org.tmatesoft.hg.core.HgException; | 
| 74 
6f1b88693d48
Complete refactoring to org.tmatesoft
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
68diff
changeset | 36 import org.tmatesoft.hg.core.Nodeid; | 
| 157 
d5268ca7715b
Merged branch wrap-data-access into default for resource-friendly data access. Updated API to promote that friendliness to clients (channels, not byte[]). More exceptions
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
148diff
changeset | 37 import org.tmatesoft.hg.internal.ByteArrayChannel; | 
| 226 
26ad7827a62d
Support status query for a single file or a subdirectory of a repository
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
219diff
changeset | 38 import org.tmatesoft.hg.internal.Experimental; | 
| 117 
6c0be854d149
Enable filters for status operation (ToRepo case)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
102diff
changeset | 39 import org.tmatesoft.hg.internal.FilterByteChannel; | 
| 229 
1ec6b327a6ac
Scope for status reworked: explicit files or a general matcher
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
226diff
changeset | 40 import org.tmatesoft.hg.internal.PathScope; | 
| 94 
af1f3b78b918
*StatusCollector renamed to Hg*StatusCollector
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
93diff
changeset | 41 import org.tmatesoft.hg.repo.HgStatusCollector.ManifestRevisionInspector; | 
| 117 
6c0be854d149
Enable filters for status operation (ToRepo case)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
102diff
changeset | 42 import org.tmatesoft.hg.util.ByteChannel; | 
| 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: 
148diff
changeset | 43 import org.tmatesoft.hg.util.CancelledException; | 
| 141 
8248aae33f7d
Adopt FileIterator moving towards WCStatusCollector parameterizing. Improved path handling, move 'em around
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
133diff
changeset | 44 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: 
219diff
changeset | 45 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: 
120diff
changeset | 46 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: 
91diff
changeset | 47 import org.tmatesoft.hg.util.PathPool; | 
| 
d55d4eedfc57
Switch to Path instead of String in filenames returned by various status operations
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
91diff
changeset | 48 import org.tmatesoft.hg.util.PathRewrite; | 
| 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 | 49 | 
| 
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 | 50 /** | 
| 
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 | 51 * | 
| 74 
6f1b88693d48
Complete refactoring to org.tmatesoft
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
68diff
changeset | 52 * @author Artem Tikhomirov | 
| 
6f1b88693d48
Complete refactoring to org.tmatesoft
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
68diff
changeset | 53 * @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 | 54 */ | 
| 94 
af1f3b78b918
*StatusCollector renamed to Hg*StatusCollector
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
93diff
changeset | 55 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 | 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 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: 
133diff
changeset | 58 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: 
58diff
changeset | 59 private HgDirstate dirstate; | 
| 94 
af1f3b78b918
*StatusCollector renamed to Hg*StatusCollector
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
93diff
changeset | 60 private HgStatusCollector baseRevisionCollector; | 
| 93 
d55d4eedfc57
Switch to Path instead of String in filenames returned by various status operations
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
91diff
changeset | 61 private PathPool pathPool; | 
| 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 | 
| 94 
af1f3b78b918
*StatusCollector renamed to Hg*StatusCollector
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
93diff
changeset | 63 public HgWorkingCopyStatusCollector(HgRepository hgRepo) { | 
| 229 
1ec6b327a6ac
Scope for status reworked: explicit files or a general matcher
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
226diff
changeset | 64 this(hgRepo, new HgInternals(hgRepo).createWorkingDirWalker(null)); | 
| 74 
6f1b88693d48
Complete refactoring to org.tmatesoft
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
68diff
changeset | 65 } | 
| 
6f1b88693d48
Complete refactoring to org.tmatesoft
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
68diff
changeset | 66 | 
| 229 
1ec6b327a6ac
Scope for status reworked: explicit files or a general matcher
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
226diff
changeset | 67 // FIXME document cons | 
| 
1ec6b327a6ac
Scope for status reworked: explicit files or a general matcher
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
226diff
changeset | 68 public HgWorkingCopyStatusCollector(HgRepository hgRepo, FileIterator hgRepoWalker) { | 
| 218 
047b1dec7a04
Issue 7: Correctly handle manifest and changelog with different number of (or non-matching) revisions
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
195diff
changeset | 69 repo = hgRepo; | 
| 
047b1dec7a04
Issue 7: Correctly handle manifest and changelog with different number of (or non-matching) revisions
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
195diff
changeset | 70 repoWalker = hgRepoWalker; | 
| 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 | 71 } | 
| 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: 
58diff
changeset | 72 | 
| 
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: 
58diff
changeset | 73 /** | 
| 
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: 
58diff
changeset | 74 * 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: 
58diff
changeset | 75 * @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: 
58diff
changeset | 76 */ | 
| 94 
af1f3b78b918
*StatusCollector renamed to Hg*StatusCollector
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
93diff
changeset | 77 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: 
58diff
changeset | 78 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: 
58diff
changeset | 79 } | 
| 93 
d55d4eedfc57
Switch to Path instead of String in filenames returned by various status operations
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
91diff
changeset | 80 | 
| 
d55d4eedfc57
Switch to Path instead of String in filenames returned by various status operations
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
91diff
changeset | 81 /*package-local*/ PathPool getPathPool() { | 
| 
d55d4eedfc57
Switch to Path instead of String in filenames returned by various status operations
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
91diff
changeset | 82 if (pathPool == null) { | 
| 
d55d4eedfc57
Switch to Path instead of String in filenames returned by various status operations
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
91diff
changeset | 83 if (baseRevisionCollector == null) { | 
| 
d55d4eedfc57
Switch to Path instead of String in filenames returned by various status operations
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
91diff
changeset | 84 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: 
91diff
changeset | 85 } else { | 
| 
d55d4eedfc57
Switch to Path instead of String in filenames returned by various status operations
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
91diff
changeset | 86 return baseRevisionCollector.getPathPool(); | 
| 
d55d4eedfc57
Switch to Path instead of String in filenames returned by various status operations
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
91diff
changeset | 87 } | 
| 
d55d4eedfc57
Switch to Path instead of String in filenames returned by various status operations
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
91diff
changeset | 88 } | 
| 
d55d4eedfc57
Switch to Path instead of String in filenames returned by various status operations
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
91diff
changeset | 89 return pathPool; | 
| 
d55d4eedfc57
Switch to Path instead of String in filenames returned by various status operations
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
91diff
changeset | 90 } | 
| 
d55d4eedfc57
Switch to Path instead of String in filenames returned by various status operations
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
91diff
changeset | 91 | 
| 
d55d4eedfc57
Switch to Path instead of String in filenames returned by various status operations
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
91diff
changeset | 92 public void setPathPool(PathPool pathPool) { | 
| 
d55d4eedfc57
Switch to Path instead of String in filenames returned by various status operations
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
91diff
changeset | 93 this.pathPool = pathPool; | 
| 
d55d4eedfc57
Switch to Path instead of String in filenames returned by various status operations
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
91diff
changeset | 94 } | 
| 
d55d4eedfc57
Switch to Path instead of String in filenames returned by various status operations
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
91diff
changeset | 95 | 
| 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: 
58diff
changeset | 96 | 
| 
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: 
58diff
changeset | 97 private HgDirstate getDirstate() { | 
| 
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: 
58diff
changeset | 98 if (dirstate == null) { | 
| 74 
6f1b88693d48
Complete refactoring to org.tmatesoft
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
68diff
changeset | 99 dirstate = repo.loadDirstate(); | 
| 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: 
58diff
changeset | 100 } | 
| 
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: 
58diff
changeset | 101 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: 
58diff
changeset | 102 } | 
| 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 | 103 | 
| 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: 
58diff
changeset | 104 // may be invoked few times | 
| 93 
d55d4eedfc57
Switch to Path instead of String in filenames returned by various status operations
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
91diff
changeset | 105 public void walk(int baseRevision, HgStatusInspector inspector) { | 
| 218 
047b1dec7a04
Issue 7: Correctly handle manifest and changelog with different number of (or non-matching) revisions
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
195diff
changeset | 106 if (HgInternals.wrongLocalRevision(baseRevision) || baseRevision == BAD_REVISION || baseRevision == WORKING_COPY) { | 
| 
047b1dec7a04
Issue 7: Correctly handle manifest and changelog with different number of (or non-matching) revisions
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
195diff
changeset | 107 throw new IllegalArgumentException(String.valueOf(baseRevision)); | 
| 
047b1dec7a04
Issue 7: Correctly handle manifest and changelog with different number of (or non-matching) revisions
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
195diff
changeset | 108 } | 
| 91 
c2ce1cfaeb9e
ignore file with regex and 'honest' glob support
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
90diff
changeset | 109 final HgIgnore hgIgnore = repo.getIgnore(); | 
| 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: 
58diff
changeset | 110 TreeSet<String> knownEntries = getDirstate().all(); | 
| 68 
0e499fed9b3d
StatusCommand with tests. Extra constants to indicate common revision cases
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
63diff
changeset | 111 final boolean isTipBase; | 
| 
0e499fed9b3d
StatusCommand with tests. Extra constants to indicate common revision cases
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
63diff
changeset | 112 if (baseRevision == TIP) { | 
| 218 
047b1dec7a04
Issue 7: Correctly handle manifest and changelog with different number of (or non-matching) revisions
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
195diff
changeset | 113 baseRevision = repo.getChangelog().getLastRevision(); | 
| 68 
0e499fed9b3d
StatusCommand with tests. Extra constants to indicate common revision cases
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
63diff
changeset | 114 isTipBase = true; | 
| 
0e499fed9b3d
StatusCommand with tests. Extra constants to indicate common revision cases
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
63diff
changeset | 115 } else { | 
| 218 
047b1dec7a04
Issue 7: Correctly handle manifest and changelog with different number of (or non-matching) revisions
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
195diff
changeset | 116 isTipBase = baseRevision == repo.getChangelog().getLastRevision(); | 
| 68 
0e499fed9b3d
StatusCommand with tests. Extra constants to indicate common revision cases
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
63diff
changeset | 117 } | 
| 94 
af1f3b78b918
*StatusCollector renamed to Hg*StatusCollector
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
93diff
changeset | 118 HgStatusCollector.ManifestRevisionInspector collect = null; | 
| 226 
26ad7827a62d
Support status query for a single file or a subdirectory of a repository
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
219diff
changeset | 119 Set<String> baseRevFiles = Collections.emptySet(); // files from base revision not affected by status calculation | 
| 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 | 120 if (!isTipBase) { | 
| 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: 
58diff
changeset | 121 if (baseRevisionCollector != 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: 
58diff
changeset | 122 collect = baseRevisionCollector.raw(baseRevision); | 
| 
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: 
58diff
changeset | 123 } else { | 
| 195 
c9b305df0b89
Optimization: use ParentWalker to get changeset's parents, if possible. Do not keep duplicating nodeids and strings in manifest revisions
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
180diff
changeset | 124 collect = new HgStatusCollector.ManifestRevisionInspector(null, null); | 
| 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: 
58diff
changeset | 125 repo.getManifest().walk(baseRevision, baseRevision, collect); | 
| 
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: 
58diff
changeset | 126 } | 
| 89 
42bcb4bffd17
Refactored to simplify manifest collector
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
76diff
changeset | 127 baseRevFiles = new TreeSet<String>(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 | 128 } | 
| 94 
af1f3b78b918
*StatusCollector renamed to Hg*StatusCollector
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
93diff
changeset | 129 if (inspector instanceof HgStatusCollector.Record) { | 
| 
af1f3b78b918
*StatusCollector renamed to Hg*StatusCollector
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
93diff
changeset | 130 HgStatusCollector sc = baseRevisionCollector == null ? new HgStatusCollector(repo) : baseRevisionCollector; | 
| 
af1f3b78b918
*StatusCollector renamed to Hg*StatusCollector
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
93diff
changeset | 131 ((HgStatusCollector.Record) inspector).init(baseRevision, BAD_REVISION, sc); | 
| 68 
0e499fed9b3d
StatusCommand with tests. Extra constants to indicate common revision cases
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
63diff
changeset | 132 } | 
| 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 | 133 repoWalker.reset(); | 
| 93 
d55d4eedfc57
Switch to Path instead of String in filenames returned by various status operations
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
91diff
changeset | 134 final PathPool pp = getPathPool(); | 
| 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 | 135 while (repoWalker.hasNext()) { | 
| 
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 | 136 repoWalker.next(); | 
| 226 
26ad7827a62d
Support status query for a single file or a subdirectory of a repository
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
219diff
changeset | 137 Path fname = pp.path(repoWalker.name()); | 
| 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 | 138 File f = repoWalker.file(); | 
| 226 
26ad7827a62d
Support status query for a single file or a subdirectory of a repository
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
219diff
changeset | 139 if (!f.exists()) { | 
| 
26ad7827a62d
Support status query for a single file or a subdirectory of a repository
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
219diff
changeset | 140 // file coming from iterator doesn't exist. | 
| 
26ad7827a62d
Support status query for a single file or a subdirectory of a repository
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
219diff
changeset | 141 if (knownEntries.remove(fname.toString())) { | 
| 
26ad7827a62d
Support status query for a single file or a subdirectory of a repository
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
219diff
changeset | 142 if (getDirstate().checkRemoved(fname) == null) { | 
| 
26ad7827a62d
Support status query for a single file or a subdirectory of a repository
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
219diff
changeset | 143 inspector.missing(fname); | 
| 
26ad7827a62d
Support status query for a single file or a subdirectory of a repository
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
219diff
changeset | 144 } else { | 
| 
26ad7827a62d
Support status query for a single file or a subdirectory of a repository
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
219diff
changeset | 145 inspector.removed(fname); | 
| 
26ad7827a62d
Support status query for a single file or a subdirectory of a repository
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
219diff
changeset | 146 } | 
| 
26ad7827a62d
Support status query for a single file or a subdirectory of a repository
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
219diff
changeset | 147 // 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: 
219diff
changeset | 148 if (collect != null) { | 
| 
26ad7827a62d
Support status query for a single file or a subdirectory of a repository
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
219diff
changeset | 149 baseRevFiles.remove(fname.toString()); | 
| 
26ad7827a62d
Support status query for a single file or a subdirectory of a repository
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
219diff
changeset | 150 } | 
| 
26ad7827a62d
Support status query for a single file or a subdirectory of a repository
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
219diff
changeset | 151 } else { | 
| 
26ad7827a62d
Support status query for a single file or a subdirectory of a repository
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
219diff
changeset | 152 // 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: 
219diff
changeset | 153 // 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: 
219diff
changeset | 154 // but it doesn't hurt to be explicit (provided we know fname *is* inScope of the FileIterator | 
| 
26ad7827a62d
Support status query for a single file or a subdirectory of a repository
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
219diff
changeset | 155 if (collect != null && baseRevFiles.remove(fname.toString())) { | 
| 
26ad7827a62d
Support status query for a single file or a subdirectory of a repository
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
219diff
changeset | 156 inspector.removed(fname); | 
| 
26ad7827a62d
Support status query for a single file or a subdirectory of a repository
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
219diff
changeset | 157 } else { | 
| 
26ad7827a62d
Support status query for a single file or a subdirectory of a repository
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
219diff
changeset | 158 // 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: 
219diff
changeset | 159 // 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: 
219diff
changeset | 160 // 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: 
219diff
changeset | 161 // 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: 
219diff
changeset | 162 // 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: 
219diff
changeset | 163 // 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: 
219diff
changeset | 164 inspector.unknown(fname); | 
| 
26ad7827a62d
Support status query for a single file or a subdirectory of a repository
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
219diff
changeset | 165 } | 
| 
26ad7827a62d
Support status query for a single file or a subdirectory of a repository
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
219diff
changeset | 166 } | 
| 
26ad7827a62d
Support status query for a single file or a subdirectory of a repository
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
219diff
changeset | 167 continue; | 
| 
26ad7827a62d
Support status query for a single file or a subdirectory of a repository
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
219diff
changeset | 168 } | 
| 229 
1ec6b327a6ac
Scope for status reworked: explicit files or a general matcher
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
226diff
changeset | 169 assert f.isFile(); | 
| 226 
26ad7827a62d
Support status query for a single file or a subdirectory of a repository
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
219diff
changeset | 170 if (knownEntries.remove(fname.toString())) { | 
| 
26ad7827a62d
Support status query for a single file or a subdirectory of a repository
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
219diff
changeset | 171 // 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 | 172 // modified, added, removed, 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 | 173 if (collect != null) { // need to check against base revision, not FS file | 
| 90 
a95c700408a9
Correctly report copy/rename events for rev..working copy case
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
89diff
changeset | 174 checkLocalStatusAgainstBaseRevision(baseRevFiles, collect, baseRevision, fname, 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 | 175 } else { | 
| 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: 
58diff
changeset | 176 checkLocalStatusAgainstFile(fname, 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 | 177 } | 
| 
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 | 178 } else { | 
| 226 
26ad7827a62d
Support status query for a single file or a subdirectory of a repository
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
219diff
changeset | 179 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: 
219diff
changeset | 180 inspector.ignored(fname); | 
| 
26ad7827a62d
Support status query for a single file or a subdirectory of a repository
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
219diff
changeset | 181 } else { | 
| 
26ad7827a62d
Support status query for a single file or a subdirectory of a repository
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
219diff
changeset | 182 inspector.unknown(fname); | 
| 
26ad7827a62d
Support status query for a single file or a subdirectory of a repository
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
219diff
changeset | 183 } | 
| 
26ad7827a62d
Support status query for a single file or a subdirectory of a repository
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
219diff
changeset | 184 // 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: 
219diff
changeset | 185 // 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: 
219diff
changeset | 186 // 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 | 187 } | 
| 
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 | 188 } | 
| 
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 | 189 if (collect != null) { | 
| 
4cfc47bc14cc
Status against local working dir extracted into distinct class. Iterating over local files extracted for ease of os-dependant patching
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 190 for (String r : baseRevFiles) { | 
| 226 
26ad7827a62d
Support status query for a single file or a subdirectory of a repository
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
219diff
changeset | 191 final Path fromBase = pp.path(r); | 
| 
26ad7827a62d
Support status query for a single file or a subdirectory of a repository
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
219diff
changeset | 192 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: 
219diff
changeset | 193 inspector.removed(fromBase); | 
| 
26ad7827a62d
Support status query for a single file or a subdirectory of a repository
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
219diff
changeset | 194 } | 
| 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 | 195 } | 
| 
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 | 196 } | 
| 
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 | 197 for (String m : knownEntries) { | 
| 226 
26ad7827a62d
Support status query for a single file or a subdirectory of a repository
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
219diff
changeset | 198 if (!repoWalker.inScope(pp.path(m))) { | 
| 
26ad7827a62d
Support status query for a single file or a subdirectory of a repository
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
219diff
changeset | 199 // 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: 
219diff
changeset | 200 continue; | 
| 
26ad7827a62d
Support status query for a single file or a subdirectory of a repository
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
219diff
changeset | 201 } | 
| 74 
6f1b88693d48
Complete refactoring to org.tmatesoft
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
68diff
changeset | 202 // missing known file from a working dir | 
| 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: 
58diff
changeset | 203 if (getDirstate().checkRemoved(m) == null) { | 
| 74 
6f1b88693d48
Complete refactoring to org.tmatesoft
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
68diff
changeset | 204 // not removed from the repository = 'deleted' | 
| 93 
d55d4eedfc57
Switch to Path instead of String in filenames returned by various status operations
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
91diff
changeset | 205 inspector.missing(pp.path(m)); | 
| 74 
6f1b88693d48
Complete refactoring to org.tmatesoft
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
68diff
changeset | 206 } else { | 
| 
6f1b88693d48
Complete refactoring to org.tmatesoft
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
68diff
changeset | 207 // 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: 
74diff
changeset | 208 // if we check against non-tip revision, do not report files that were added past that revision and now removed. | 
| 
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: 
74diff
changeset | 209 if (collect == null || baseRevFiles.contains(m)) { | 
| 93 
d55d4eedfc57
Switch to Path instead of String in filenames returned by various status operations
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
91diff
changeset | 210 inspector.removed(pp.path(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: 
74diff
changeset | 211 } | 
| 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 | 212 } | 
| 
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 | 213 } | 
| 
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 | 214 } | 
| 
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 | 
| 94 
af1f3b78b918
*StatusCollector renamed to Hg*StatusCollector
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
93diff
changeset | 216 public HgStatusCollector.Record status(int baseRevision) { | 
| 
af1f3b78b918
*StatusCollector renamed to Hg*StatusCollector
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
93diff
changeset | 217 HgStatusCollector.Record rv = new HgStatusCollector.Record(); | 
| 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 | 218 walk(baseRevision, 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 | 219 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 | 220 } | 
| 
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 | 221 | 
| 
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 | 222 //******************************************** | 
| 
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 | 223 | 
| 
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 | 224 | 
| 141 
8248aae33f7d
Adopt FileIterator moving towards WCStatusCollector parameterizing. Improved path handling, move 'em around
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
133diff
changeset | 225 private void checkLocalStatusAgainstFile(Path fname, File 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 | 226 HgDirstate.Record r; | 
| 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: 
58diff
changeset | 227 if ((r = getDirstate().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 | 228 // either clean or modified | 
| 
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 | 229 if (f.lastModified() / 1000 == r.time && r.size == f.length()) { | 
| 93 
d55d4eedfc57
Switch to Path instead of String in filenames returned by various status operations
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
91diff
changeset | 230 inspector.clean(getPathPool().path(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 | 231 } else { | 
| 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: 
117diff
changeset | 232 // check actual content to avoid false modified files | 
| 
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: 
117diff
changeset | 233 HgDataFile df = repo.getFileNode(fname); | 
| 157 
d5268ca7715b
Merged branch wrap-data-access into default for resource-friendly data access. Updated API to promote that friendliness to clients (channels, not byte[]). More exceptions
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
148diff
changeset | 234 if (!areTheSame(f, df, HgRepository.TIP)) { | 
| 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: 
117diff
changeset | 235 inspector.modified(df.getPath()); | 
| 180 
42fe9a94b9d0
Report files as clean when no difference but timestamp found
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
157diff
changeset | 236 } else { | 
| 
42fe9a94b9d0
Report files as clean when no difference but timestamp found
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
157diff
changeset | 237 inspector.clean(df.getPath()); | 
| 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: 
117diff
changeset | 238 } | 
| 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 | 239 } | 
| 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: 
58diff
changeset | 240 } else if ((r = getDirstate().checkAdded(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 | 241 if (r.name2 == null) { | 
| 93 
d55d4eedfc57
Switch to Path instead of String in filenames returned by various status operations
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
91diff
changeset | 242 inspector.added(getPathPool().path(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 | 243 } else { | 
| 93 
d55d4eedfc57
Switch to Path instead of String in filenames returned by various status operations
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
91diff
changeset | 244 inspector.copied(getPathPool().path(r.name2), getPathPool().path(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 | 245 } | 
| 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: 
58diff
changeset | 246 } else if ((r = getDirstate().checkRemoved(fname)) != null) { | 
| 93 
d55d4eedfc57
Switch to Path instead of String in filenames returned by various status operations
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
91diff
changeset | 247 inspector.removed(getPathPool().path(fname)); | 
| 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: 
58diff
changeset | 248 } else if ((r = getDirstate().checkMerged(fname)) != null) { | 
| 93 
d55d4eedfc57
Switch to Path instead of String in filenames returned by various status operations
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
91diff
changeset | 249 inspector.modified(getPathPool().path(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 | 250 } | 
| 
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 | 251 } | 
| 
4cfc47bc14cc
Status against local working dir extracted into distinct class. Iterating over local files extracted for ease of os-dependant patching
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 252 | 
| 
4cfc47bc14cc
Status against local working dir extracted into distinct class. Iterating over local files extracted for ease of os-dependant patching
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 253 // XXX refactor checkLocalStatus methods in more OO way | 
| 141 
8248aae33f7d
Adopt FileIterator moving towards WCStatusCollector parameterizing. Improved path handling, move 'em around
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
133diff
changeset | 254 private void checkLocalStatusAgainstBaseRevision(Set<String> baseRevNames, ManifestRevisionInspector collect, int baseRevision, Path fname, File 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 | 255 // fname is in the dirstate, either Normal, Added, Removed or Merged | 
| 141 
8248aae33f7d
Adopt FileIterator moving towards WCStatusCollector parameterizing. Improved path handling, move 'em around
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
133diff
changeset | 256 Nodeid nid1 = collect.nodeid(fname.toString()); | 
| 
8248aae33f7d
Adopt FileIterator moving towards WCStatusCollector parameterizing. Improved path handling, move 'em around
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
133diff
changeset | 257 String flags = collect.flags(fname.toString()); | 
| 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 | 258 HgDirstate.Record r; | 
| 
4cfc47bc14cc
Status against local working dir extracted into distinct class. Iterating over local files extracted for ease of os-dependant patching
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 259 if (nid1 == null) { | 
| 
4cfc47bc14cc
Status against local working dir extracted into distinct class. Iterating over local files extracted for ease of os-dependant patching
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 260 // normal: added? | 
| 
4cfc47bc14cc
Status against local working dir extracted into distinct class. Iterating over local files extracted for ease of os-dependant patching
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 261 // added: not known at the time of baseRevision, shall report | 
| 
4cfc47bc14cc
Status against local working dir extracted into distinct class. Iterating over local files extracted for ease of os-dependant patching
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 262 // merged: was not known, report as added? | 
| 90 
a95c700408a9
Correctly report copy/rename events for rev..working copy case
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
89diff
changeset | 263 if ((r = getDirstate().checkNormal(fname)) != null) { | 
| 157 
d5268ca7715b
Merged branch wrap-data-access into default for resource-friendly data access. Updated API to promote that friendliness to clients (channels, not byte[]). More exceptions
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
148diff
changeset | 264 try { | 
| 
d5268ca7715b
Merged branch wrap-data-access into default for resource-friendly data access. Updated API to promote that friendliness to clients (channels, not byte[]). More exceptions
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
148diff
changeset | 265 Path origin = HgStatusCollector.getOriginIfCopy(repo, fname, baseRevNames, baseRevision); | 
| 
d5268ca7715b
Merged branch wrap-data-access into default for resource-friendly data access. Updated API to promote that friendliness to clients (channels, not byte[]). More exceptions
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
148diff
changeset | 266 if (origin != null) { | 
| 226 
26ad7827a62d
Support status query for a single file or a subdirectory of a repository
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
219diff
changeset | 267 inspector.copied(getPathPool().path(origin), fname); | 
| 157 
d5268ca7715b
Merged branch wrap-data-access into default for resource-friendly data access. Updated API to promote that friendliness to clients (channels, not byte[]). More exceptions
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
148diff
changeset | 268 return; | 
| 
d5268ca7715b
Merged branch wrap-data-access into default for resource-friendly data access. Updated API to promote that friendliness to clients (channels, not byte[]). More exceptions
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
148diff
changeset | 269 } | 
| 
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: 
148diff
changeset | 270 } catch (HgDataStreamException 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: 
148diff
changeset | 271 ex.printStackTrace(); | 
| 
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: 
148diff
changeset | 272 // FIXME report to a mediator, continue status collection | 
| 90 
a95c700408a9
Correctly report copy/rename events for rev..working copy case
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
89diff
changeset | 273 } | 
| 
a95c700408a9
Correctly report copy/rename events for rev..working copy case
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
89diff
changeset | 274 } else if ((r = getDirstate().checkAdded(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 | 275 if (r.name2 != null && baseRevNames.contains(r.name2)) { | 
| 90 
a95c700408a9
Correctly report copy/rename events for rev..working copy case
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
89diff
changeset | 276 baseRevNames.remove(r.name2); // XXX surely I shall not report rename source as Removed? | 
| 226 
26ad7827a62d
Support status query for a single file or a subdirectory of a repository
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
219diff
changeset | 277 inspector.copied(getPathPool().path(r.name2), 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 | 278 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 | 279 } | 
| 
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 | 280 // fall-through, report as added | 
| 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: 
58diff
changeset | 281 } else if (getDirstate().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 | 282 // 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 | 283 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 | 284 } | 
| 226 
26ad7827a62d
Support status query for a single file or a subdirectory of a repository
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
219diff
changeset | 285 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 | 286 } 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 | 287 // was known; check whether clean or modified | 
| 
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 | 288 // when added - seems to be the case of a file added once again, hence need to check if content is different | 
| 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: 
58diff
changeset | 289 if ((r = getDirstate().checkNormal(fname)) != null || (r = getDirstate().checkMerged(fname)) != null || (r = getDirstate().checkAdded(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 | 290 // either clean or modified | 
| 
4cfc47bc14cc
Status against local working dir extracted into distinct class. Iterating over local files extracted for ease of os-dependant patching
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 291 HgDataFile fileNode = repo.getFileNode(fname); | 
| 
4cfc47bc14cc
Status against local working dir extracted into distinct class. Iterating over local files extracted for ease of os-dependant patching
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 292 final int lengthAtRevision = fileNode.length(nid1); | 
| 
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 | 293 if (r.size /* XXX File.length() ?! */ != lengthAtRevision || flags != todoGenerateFlags(fname /*java.io.File*/)) { | 
| 226 
26ad7827a62d
Support status query for a single file or a subdirectory of a repository
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
219diff
changeset | 294 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 | 295 } 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 | 296 // check actual content to see actual changes | 
| 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: 
148diff
changeset | 297 if (areTheSame(f, fileNode, fileNode.getLocalRevision(nid1))) { | 
| 226 
26ad7827a62d
Support status query for a single file or a subdirectory of a repository
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
219diff
changeset | 298 inspector.clean(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 | 299 } else { | 
| 226 
26ad7827a62d
Support status query for a single file or a subdirectory of a repository
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
219diff
changeset | 300 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 | 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 } | 
| 226 
26ad7827a62d
Support status query for a single file or a subdirectory of a repository
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
219diff
changeset | 303 baseRevNames.remove(fname.toString()); // consumed, processed, handled. | 
| 
26ad7827a62d
Support status query for a single file or a subdirectory of a repository
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
219diff
changeset | 304 } else if (getDirstate().checkRemoved(fname) != null) { | 
| 
26ad7827a62d
Support status query for a single file or a subdirectory of a repository
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
219diff
changeset | 305 // 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: 
219diff
changeset | 306 inspector.removed(fname); | 
| 
26ad7827a62d
Support status query for a single file or a subdirectory of a repository
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
219diff
changeset | 307 baseRevNames.remove(fname.toString()); // 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 | 308 } | 
| 226 
26ad7827a62d
Support status query for a single file or a subdirectory of a repository
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
219diff
changeset | 309 // 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 | 310 } | 
| 
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 | 311 | 
| 
4cfc47bc14cc
Status against local working dir extracted into distinct class. Iterating over local files extracted for ease of os-dependant patching
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 312 // TODO think over if content comparison may be done more effectively by e.g. calculating nodeid for a local file and comparing it with nodeid from manifest | 
| 
4cfc47bc14cc
Status against local working dir extracted into distinct class. Iterating over local files extracted for ease of os-dependant patching
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 313 // 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 | 314 // 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 | 315 // 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 | 316 // 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 | 317 // 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 | 318 } | 
| 
4cfc47bc14cc
Status against local working dir extracted into distinct class. Iterating over local files extracted for ease of os-dependant patching
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 319 | 
| 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: 
148diff
changeset | 320 private boolean areTheSame(File f, HgDataFile dataFile, int localRevision) { | 
| 
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: 
148diff
changeset | 321 // 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: 
148diff
changeset | 322 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: 
148diff
changeset | 323 boolean ioFailed = false; | 
| 
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: 
148diff
changeset | 324 try { | 
| 
d5268ca7715b
Merged branch wrap-data-access into default for resource-friendly data access. Updated API to promote that friendliness to clients (channels, not byte[]). More exceptions
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
148diff
changeset | 325 // 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: 
148diff
changeset | 326 // WC doesn't have it anyway | 
| 
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: 
148diff
changeset | 327 dataFile.content(localRevision, bac); | 
| 
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: 
148diff
changeset | 328 } 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: 
148diff
changeset | 329 // 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: 
148diff
changeset | 330 } catch (HgException 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: 
148diff
changeset | 331 ioFailed = true; | 
| 
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: 
148diff
changeset | 332 } | 
| 
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: 
148diff
changeset | 333 return !ioFailed && areTheSame(f, bac.toArray(), dataFile.getPath()); | 
| 
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: 
148diff
changeset | 334 } | 
| 
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: 
148diff
changeset | 335 | 
| 117 
6c0be854d149
Enable filters for status operation (ToRepo case)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
102diff
changeset | 336 private boolean areTheSame(File f, final byte[] data, Path p) { | 
| 
6c0be854d149
Enable filters for status operation (ToRepo case)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
102diff
changeset | 337 FileInputStream fis = null; | 
| 
6c0be854d149
Enable filters for status operation (ToRepo case)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
102diff
changeset | 338 try { | 
| 
6c0be854d149
Enable filters for status operation (ToRepo case)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
102diff
changeset | 339 try { | 
| 
6c0be854d149
Enable filters for status operation (ToRepo case)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
102diff
changeset | 340 fis = new FileInputStream(f); | 
| 
6c0be854d149
Enable filters for status operation (ToRepo case)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
102diff
changeset | 341 FileChannel fc = fis.getChannel(); | 
| 226 
26ad7827a62d
Support status query for a single file or a subdirectory of a repository
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
219diff
changeset | 342 ByteBuffer fb = ByteBuffer.allocate(min(1 + data.length * 2 /*to fit couple of lines appended; never zero*/, 8192)); | 
| 219 
d63583b47bfa
ArrayIndexOutOfBoundsException when file appended. Erroneous 'areTheSame' when trailing were deleted.
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
218diff
changeset | 343 class Check implements ByteChannel { | 
| 
d63583b47bfa
ArrayIndexOutOfBoundsException when file appended. Erroneous 'areTheSame' when trailing were deleted.
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
218diff
changeset | 344 final boolean debug = false; // XXX may want to add global variable to allow clients to turn | 
| 
d63583b47bfa
ArrayIndexOutOfBoundsException when file appended. Erroneous 'areTheSame' when trailing were deleted.
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
218diff
changeset | 345 boolean sameSoFar = true; | 
| 117 
6c0be854d149
Enable filters for status operation (ToRepo case)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
102diff
changeset | 346 int x = 0; | 
| 219 
d63583b47bfa
ArrayIndexOutOfBoundsException when file appended. Erroneous 'areTheSame' when trailing were deleted.
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
218diff
changeset | 347 | 
| 148 
1a7a9a20e1f9
Exceptions, javadoc. Initial cancel and progress support
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
142diff
changeset | 348 public int write(ByteBuffer buffer) { | 
| 117 
6c0be854d149
Enable filters for status operation (ToRepo case)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
102diff
changeset | 349 for (int i = buffer.remaining(); i > 0; i--, x++) { | 
| 219 
d63583b47bfa
ArrayIndexOutOfBoundsException when file appended. Erroneous 'areTheSame' when trailing were deleted.
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
218diff
changeset | 350 if (x >= data.length /*file has been appended*/ || data[x] != buffer.get()) { | 
| 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: 
117diff
changeset | 351 if (debug) { | 
| 
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: 
117diff
changeset | 352 byte[] xx = new byte[15]; | 
| 
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: 
117diff
changeset | 353 if (buffer.position() > 5) { | 
| 
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: 
117diff
changeset | 354 buffer.position(buffer.position() - 5); | 
| 
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: 
117diff
changeset | 355 } | 
| 
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: 
117diff
changeset | 356 buffer.get(xx); | 
| 
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: 
117diff
changeset | 357 System.out.print("expected >>" + new String(data, max(0, x - 4), 20) + "<< but got >>"); | 
| 
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: 
117diff
changeset | 358 System.out.println(new String(xx) + "<<"); | 
| 
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: 
117diff
changeset | 359 } | 
| 219 
d63583b47bfa
ArrayIndexOutOfBoundsException when file appended. Erroneous 'areTheSame' when trailing were deleted.
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
218diff
changeset | 360 sameSoFar = false; | 
| 117 
6c0be854d149
Enable filters for status operation (ToRepo case)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
102diff
changeset | 361 break; | 
| 
6c0be854d149
Enable filters for status operation (ToRepo case)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
102diff
changeset | 362 } | 
| 
6c0be854d149
Enable filters for status operation (ToRepo case)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
102diff
changeset | 363 } | 
| 
6c0be854d149
Enable filters for status operation (ToRepo case)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
102diff
changeset | 364 buffer.position(buffer.limit()); // mark as read | 
| 
6c0be854d149
Enable filters for status operation (ToRepo case)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
102diff
changeset | 365 return buffer.limit(); | 
| 
6c0be854d149
Enable filters for status operation (ToRepo case)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
102diff
changeset | 366 } | 
| 219 
d63583b47bfa
ArrayIndexOutOfBoundsException when file appended. Erroneous 'areTheSame' when trailing were deleted.
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
218diff
changeset | 367 | 
| 
d63583b47bfa
ArrayIndexOutOfBoundsException when file appended. Erroneous 'areTheSame' when trailing were deleted.
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
218diff
changeset | 368 public boolean sameSoFar() { | 
| 
d63583b47bfa
ArrayIndexOutOfBoundsException when file appended. Erroneous 'areTheSame' when trailing were deleted.
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
218diff
changeset | 369 return sameSoFar; | 
| 
d63583b47bfa
ArrayIndexOutOfBoundsException when file appended. Erroneous 'areTheSame' when trailing were deleted.
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
218diff
changeset | 370 } | 
| 
d63583b47bfa
ArrayIndexOutOfBoundsException when file appended. Erroneous 'areTheSame' when trailing were deleted.
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
218diff
changeset | 371 public boolean ultimatelyTheSame() { | 
| 
d63583b47bfa
ArrayIndexOutOfBoundsException when file appended. Erroneous 'areTheSame' when trailing were deleted.
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
218diff
changeset | 372 return sameSoFar && x == data.length; | 
| 
d63583b47bfa
ArrayIndexOutOfBoundsException when file appended. Erroneous 'areTheSame' when trailing were deleted.
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
218diff
changeset | 373 } | 
| 117 
6c0be854d149
Enable filters for status operation (ToRepo case)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
102diff
changeset | 374 }; | 
| 219 
d63583b47bfa
ArrayIndexOutOfBoundsException when file appended. Erroneous 'areTheSame' when trailing were deleted.
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
218diff
changeset | 375 Check check = new Check(); | 
| 117 
6c0be854d149
Enable filters for status operation (ToRepo case)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
102diff
changeset | 376 FilterByteChannel filters = new FilterByteChannel(check, repo.getFiltersFromWorkingDirToRepo(p)); | 
| 219 
d63583b47bfa
ArrayIndexOutOfBoundsException when file appended. Erroneous 'areTheSame' when trailing were deleted.
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
218diff
changeset | 377 while (fc.read(fb) != -1 && check.sameSoFar()) { | 
| 117 
6c0be854d149
Enable filters for status operation (ToRepo case)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
102diff
changeset | 378 fb.flip(); | 
| 
6c0be854d149
Enable filters for status operation (ToRepo case)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
102diff
changeset | 379 filters.write(fb); | 
| 
6c0be854d149
Enable filters for status operation (ToRepo case)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
102diff
changeset | 380 fb.compact(); | 
| 
6c0be854d149
Enable filters for status operation (ToRepo case)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
102diff
changeset | 381 } | 
| 246 
ff4fdbab4e2d
Close file streams
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
238diff
changeset | 382 fis.close(); | 
| 219 
d63583b47bfa
ArrayIndexOutOfBoundsException when file appended. Erroneous 'areTheSame' when trailing were deleted.
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
218diff
changeset | 383 return check.ultimatelyTheSame(); | 
| 117 
6c0be854d149
Enable filters for status operation (ToRepo case)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
102diff
changeset | 384 } catch (IOException ex) { | 
| 
6c0be854d149
Enable filters for status operation (ToRepo case)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
102diff
changeset | 385 if (fis != null) { | 
| 
6c0be854d149
Enable filters for status operation (ToRepo case)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
102diff
changeset | 386 fis.close(); | 
| 
6c0be854d149
Enable filters for status operation (ToRepo case)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
102diff
changeset | 387 } | 
| 
6c0be854d149
Enable filters for status operation (ToRepo case)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
102diff
changeset | 388 ex.printStackTrace(); // log warn | 
| 
6c0be854d149
Enable filters for status operation (ToRepo case)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
102diff
changeset | 389 } | 
| 
6c0be854d149
Enable filters for status operation (ToRepo case)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
102diff
changeset | 390 } catch (/*TODO typed*/Exception ex) { | 
| 
6c0be854d149
Enable filters for status operation (ToRepo case)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
102diff
changeset | 391 ex.printStackTrace(); | 
| 
6c0be854d149
Enable filters for status operation (ToRepo case)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
102diff
changeset | 392 } | 
| 
6c0be854d149
Enable filters for status operation (ToRepo case)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
102diff
changeset | 393 return false; | 
| 
6c0be854d149
Enable filters for status operation (ToRepo case)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
102diff
changeset | 394 } | 
| 
6c0be854d149
Enable filters for status operation (ToRepo case)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
102diff
changeset | 395 | 
| 141 
8248aae33f7d
Adopt FileIterator moving towards WCStatusCollector parameterizing. Improved path handling, move 'em around
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
133diff
changeset | 396 private static String todoGenerateFlags(Path 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 | 397 // FIXME implement | 
| 
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 | 398 return null; | 
| 
4cfc47bc14cc
Status against local working dir extracted into distinct class. Iterating over local files extracted for ease of os-dependant patching
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 399 } | 
| 
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 | 
| 229 
1ec6b327a6ac
Scope for status reworked: explicit files or a general matcher
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
226diff
changeset | 401 /** | 
| 
1ec6b327a6ac
Scope for status reworked: explicit files or a general matcher
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
226diff
changeset | 402 * 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: 
226diff
changeset | 403 * 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: 
226diff
changeset | 404 * | 
| 
1ec6b327a6ac
Scope for status reworked: explicit files or a general matcher
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
226diff
changeset | 405 * @param hgRepo repository | 
| 
1ec6b327a6ac
Scope for status reworked: explicit files or a general matcher
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
226diff
changeset | 406 * @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: 
226diff
changeset | 407 * | 
| 
1ec6b327a6ac
Scope for status reworked: explicit files or a general matcher
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
226diff
changeset | 408 * @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: 
226diff
changeset | 409 */ | 
| 
1ec6b327a6ac
Scope for status reworked: explicit files or a general matcher
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
226diff
changeset | 410 @Experimental(reason="Provisional API") | 
| 
1ec6b327a6ac
Scope for status reworked: explicit files or a general matcher
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
226diff
changeset | 411 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: 
226diff
changeset | 412 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: 
226diff
changeset | 413 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: 
226diff
changeset | 414 for (Path p : paths) { | 
| 
1ec6b327a6ac
Scope for status reworked: explicit files or a general matcher
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
226diff
changeset | 415 if (p.isDirectory()) { | 
| 
1ec6b327a6ac
Scope for status reworked: explicit files or a general matcher
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
226diff
changeset | 416 d.add(p); | 
| 
1ec6b327a6ac
Scope for status reworked: explicit files or a general matcher
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
226diff
changeset | 417 } else { | 
| 
1ec6b327a6ac
Scope for status reworked: explicit files or a general matcher
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
226diff
changeset | 418 f.add(p); | 
| 
1ec6b327a6ac
Scope for status reworked: explicit files or a general matcher
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
226diff
changeset | 419 } | 
| 
1ec6b327a6ac
Scope for status reworked: explicit files or a general matcher
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
226diff
changeset | 420 } | 
| 
1ec6b327a6ac
Scope for status reworked: explicit files or a general matcher
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
226diff
changeset | 421 // 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: 
226diff
changeset | 422 if (d.isEmpty()) { | 
| 
1ec6b327a6ac
Scope for status reworked: explicit files or a general matcher
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
226diff
changeset | 423 final Path[] files = f.toArray(new Path[f.size()]); | 
| 237 
6e1373b54e9b
Allow access to working copy content through HgDataFile. Give access to repository's working dir
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
229diff
changeset | 424 FileIterator fi = new FileListIterator(hgRepo.getWorkingDir(), files); | 
| 229 
1ec6b327a6ac
Scope for status reworked: explicit files or a general matcher
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
226diff
changeset | 425 return new HgWorkingCopyStatusCollector(hgRepo, fi); | 
| 
1ec6b327a6ac
Scope for status reworked: explicit files or a general matcher
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
226diff
changeset | 426 } | 
| 
1ec6b327a6ac
Scope for status reworked: explicit files or a general matcher
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
226diff
changeset | 427 // | 
| 
1ec6b327a6ac
Scope for status reworked: explicit files or a general matcher
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
226diff
changeset | 428 | 
| 
1ec6b327a6ac
Scope for status reworked: explicit files or a general matcher
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
226diff
changeset | 429 //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: 
226diff
changeset | 430 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: 
219diff
changeset | 431 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: 
219diff
changeset | 432 } | 
| 229 
1ec6b327a6ac
Scope for status reworked: explicit files or a general matcher
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
226diff
changeset | 433 | 
| 
1ec6b327a6ac
Scope for status reworked: explicit files or a general matcher
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
226diff
changeset | 434 /** | 
| 
1ec6b327a6ac
Scope for status reworked: explicit files or a general matcher
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
226diff
changeset | 435 * 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: 
226diff
changeset | 436 * 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: 
226diff
changeset | 437 * (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: 
226diff
changeset | 438 * 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: 
226diff
changeset | 439 * | 
| 
1ec6b327a6ac
Scope for status reworked: explicit files or a general matcher
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
226diff
changeset | 440 * @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: 
226diff
changeset | 441 */ | 
| 
1ec6b327a6ac
Scope for status reworked: explicit files or a general matcher
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
226diff
changeset | 442 @Experimental(reason="Provisional API. May add boolean strict argument for those who write smart matchers that can be used in FileWalker") | 
| 
1ec6b327a6ac
Scope for status reworked: explicit files or a general matcher
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
226diff
changeset | 443 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: 
226diff
changeset | 444 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: 
226diff
changeset | 445 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: 
226diff
changeset | 446 // 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: 
226diff
changeset | 447 // 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: 
226diff
changeset | 448 // 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: 
226diff
changeset | 449 // 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: 
226diff
changeset | 450 // 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: 
226diff
changeset | 451 // method above/ | 
| 
1ec6b327a6ac
Scope for status reworked: explicit files or a general matcher
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
226diff
changeset | 452 return new HgWorkingCopyStatusCollector(hgRepo, wf); | 
| 
1ec6b327a6ac
Scope for status reworked: explicit files or a general matcher
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
226diff
changeset | 453 } | 
| 226 
26ad7827a62d
Support status query for a single file or a subdirectory of a repository
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
219diff
changeset | 454 | 
| 
26ad7827a62d
Support status query for a single file or a subdirectory of a repository
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
219diff
changeset | 455 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: 
219diff
changeset | 456 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: 
219diff
changeset | 457 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: 
219diff
changeset | 458 private int index; | 
| 
26ad7827a62d
Support status query for a single file or a subdirectory of a repository
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
219diff
changeset | 459 private File nextFile; // cache file() in case it's called more than once | 
| 
26ad7827a62d
Support status query for a single file or a subdirectory of a repository
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
219diff
changeset | 460 | 
| 
26ad7827a62d
Support status query for a single file or a subdirectory of a repository
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
219diff
changeset | 461 public FileListIterator(File startDir, Path... files) { | 
| 
26ad7827a62d
Support status query for a single file or a subdirectory of a repository
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
219diff
changeset | 462 dir = startDir; | 
| 
26ad7827a62d
Support status query for a single file or a subdirectory of a repository
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
219diff
changeset | 463 paths = files; | 
| 
26ad7827a62d
Support status query for a single file or a subdirectory of a repository
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
219diff
changeset | 464 reset(); | 
| 
26ad7827a62d
Support status query for a single file or a subdirectory of a repository
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
219diff
changeset | 465 } | 
| 
26ad7827a62d
Support status query for a single file or a subdirectory of a repository
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
219diff
changeset | 466 | 
| 
26ad7827a62d
Support status query for a single file or a subdirectory of a repository
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
219diff
changeset | 467 public void reset() { | 
| 
26ad7827a62d
Support status query for a single file or a subdirectory of a repository
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
219diff
changeset | 468 index = -1; | 
| 
26ad7827a62d
Support status query for a single file or a subdirectory of a repository
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
219diff
changeset | 469 nextFile = null; | 
| 
26ad7827a62d
Support status query for a single file or a subdirectory of a repository
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
219diff
changeset | 470 } | 
| 
26ad7827a62d
Support status query for a single file or a subdirectory of a repository
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
219diff
changeset | 471 | 
| 
26ad7827a62d
Support status query for a single file or a subdirectory of a repository
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
219diff
changeset | 472 public boolean hasNext() { | 
| 
26ad7827a62d
Support status query for a single file or a subdirectory of a repository
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
219diff
changeset | 473 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: 
219diff
changeset | 474 } | 
| 
26ad7827a62d
Support status query for a single file or a subdirectory of a repository
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
219diff
changeset | 475 | 
| 
26ad7827a62d
Support status query for a single file or a subdirectory of a repository
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
219diff
changeset | 476 public void next() { | 
| 
26ad7827a62d
Support status query for a single file or a subdirectory of a repository
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
219diff
changeset | 477 index++; | 
| 
26ad7827a62d
Support status query for a single file or a subdirectory of a repository
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
219diff
changeset | 478 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: 
219diff
changeset | 479 throw new NoSuchElementException(); | 
| 
26ad7827a62d
Support status query for a single file or a subdirectory of a repository
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
219diff
changeset | 480 } | 
| 
26ad7827a62d
Support status query for a single file or a subdirectory of a repository
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
219diff
changeset | 481 nextFile = new File(dir, paths[index].toString()); | 
| 
26ad7827a62d
Support status query for a single file or a subdirectory of a repository
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
219diff
changeset | 482 } | 
| 
26ad7827a62d
Support status query for a single file or a subdirectory of a repository
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
219diff
changeset | 483 | 
| 
26ad7827a62d
Support status query for a single file or a subdirectory of a repository
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
219diff
changeset | 484 public Path name() { | 
| 
26ad7827a62d
Support status query for a single file or a subdirectory of a repository
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
219diff
changeset | 485 return paths[index]; | 
| 
26ad7827a62d
Support status query for a single file or a subdirectory of a repository
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
219diff
changeset | 486 } | 
| 
26ad7827a62d
Support status query for a single file or a subdirectory of a repository
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
219diff
changeset | 487 | 
| 
26ad7827a62d
Support status query for a single file or a subdirectory of a repository
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
219diff
changeset | 488 public File file() { | 
| 
26ad7827a62d
Support status query for a single file or a subdirectory of a repository
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
219diff
changeset | 489 return nextFile; | 
| 
26ad7827a62d
Support status query for a single file or a subdirectory of a repository
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
219diff
changeset | 490 } | 
| 
26ad7827a62d
Support status query for a single file or a subdirectory of a repository
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
219diff
changeset | 491 | 
| 
26ad7827a62d
Support status query for a single file or a subdirectory of a repository
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
219diff
changeset | 492 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: 
219diff
changeset | 493 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: 
219diff
changeset | 494 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: 
219diff
changeset | 495 return true; | 
| 
26ad7827a62d
Support status query for a single file or a subdirectory of a repository
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
219diff
changeset | 496 } | 
| 
26ad7827a62d
Support status query for a single file or a subdirectory of a repository
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
219diff
changeset | 497 } | 
| 
26ad7827a62d
Support status query for a single file or a subdirectory of a repository
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
219diff
changeset | 498 return false; | 
| 
26ad7827a62d
Support status query for a single file or a subdirectory of a repository
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
219diff
changeset | 499 } | 
| 
26ad7827a62d
Support status query for a single file or a subdirectory of a repository
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
219diff
changeset | 500 } | 
| 
26ad7827a62d
Support status query for a single file or a subdirectory of a repository
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
219diff
changeset | 501 | 
| 229 
1ec6b327a6ac
Scope for status reworked: explicit files or a general matcher
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
226diff
changeset | 502 private static class FileIteratorFilter implements FileIterator { | 
| 
1ec6b327a6ac
Scope for status reworked: explicit files or a general matcher
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
226diff
changeset | 503 private final Path.Matcher filter; | 
| 
1ec6b327a6ac
Scope for status reworked: explicit files or a general matcher
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
226diff
changeset | 504 private final FileIterator walker; | 
| 
1ec6b327a6ac
Scope for status reworked: explicit files or a general matcher
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
226diff
changeset | 505 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: 
219diff
changeset | 506 | 
| 229 
1ec6b327a6ac
Scope for status reworked: explicit files or a general matcher
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
226diff
changeset | 507 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: 
226diff
changeset | 508 assert fileWalker != null; | 
| 
1ec6b327a6ac
Scope for status reworked: explicit files or a general matcher
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
226diff
changeset | 509 assert filterMatcher != null; | 
| 
1ec6b327a6ac
Scope for status reworked: explicit files or a general matcher
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
226diff
changeset | 510 filter = filterMatcher; | 
| 
1ec6b327a6ac
Scope for status reworked: explicit files or a general matcher
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
226diff
changeset | 511 walker = fileWalker; | 
| 226 
26ad7827a62d
Support status query for a single file or a subdirectory of a repository
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
219diff
changeset | 512 } | 
| 
26ad7827a62d
Support status query for a single file or a subdirectory of a repository
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
219diff
changeset | 513 | 
| 
26ad7827a62d
Support status query for a single file or a subdirectory of a repository
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
219diff
changeset | 514 public void reset() { | 
| 
26ad7827a62d
Support status query for a single file or a subdirectory of a repository
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
219diff
changeset | 515 walker.reset(); | 
| 
26ad7827a62d
Support status query for a single file or a subdirectory of a repository
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
219diff
changeset | 516 } | 
| 
26ad7827a62d
Support status query for a single file or a subdirectory of a repository
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
219diff
changeset | 517 | 
| 
26ad7827a62d
Support status query for a single file or a subdirectory of a repository
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
219diff
changeset | 518 public boolean hasNext() { | 
| 229 
1ec6b327a6ac
Scope for status reworked: explicit files or a general matcher
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
226diff
changeset | 519 while (walker.hasNext()) { | 
| 
1ec6b327a6ac
Scope for status reworked: explicit files or a general matcher
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
226diff
changeset | 520 walker.next(); | 
| 
1ec6b327a6ac
Scope for status reworked: explicit files or a general matcher
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
226diff
changeset | 521 if (filter.accept(walker.name())) { | 
| 
1ec6b327a6ac
Scope for status reworked: explicit files or a general matcher
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
226diff
changeset | 522 didNext = true; | 
| 
1ec6b327a6ac
Scope for status reworked: explicit files or a general matcher
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
226diff
changeset | 523 return true; | 
| 
1ec6b327a6ac
Scope for status reworked: explicit files or a general matcher
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
226diff
changeset | 524 } | 
| 
1ec6b327a6ac
Scope for status reworked: explicit files or a general matcher
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
226diff
changeset | 525 } | 
| 
1ec6b327a6ac
Scope for status reworked: explicit files or a general matcher
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
226diff
changeset | 526 return false; | 
| 226 
26ad7827a62d
Support status query for a single file or a subdirectory of a repository
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
219diff
changeset | 527 } | 
| 
26ad7827a62d
Support status query for a single file or a subdirectory of a repository
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
219diff
changeset | 528 | 
| 
26ad7827a62d
Support status query for a single file or a subdirectory of a repository
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
219diff
changeset | 529 public void next() { | 
| 229 
1ec6b327a6ac
Scope for status reworked: explicit files or a general matcher
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
226diff
changeset | 530 if (didNext) { | 
| 
1ec6b327a6ac
Scope for status reworked: explicit files or a general matcher
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
226diff
changeset | 531 didNext = false; | 
| 
1ec6b327a6ac
Scope for status reworked: explicit files or a general matcher
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
226diff
changeset | 532 } else { | 
| 
1ec6b327a6ac
Scope for status reworked: explicit files or a general matcher
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
226diff
changeset | 533 if (!hasNext()) { | 
| 
1ec6b327a6ac
Scope for status reworked: explicit files or a general matcher
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
226diff
changeset | 534 throw new NoSuchElementException(); | 
| 
1ec6b327a6ac
Scope for status reworked: explicit files or a general matcher
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
226diff
changeset | 535 } | 
| 
1ec6b327a6ac
Scope for status reworked: explicit files or a general matcher
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
226diff
changeset | 536 } | 
| 226 
26ad7827a62d
Support status query for a single file or a subdirectory of a repository
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
219diff
changeset | 537 } | 
| 
26ad7827a62d
Support status query for a single file or a subdirectory of a repository
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
219diff
changeset | 538 | 
| 
26ad7827a62d
Support status query for a single file or a subdirectory of a repository
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
219diff
changeset | 539 public Path name() { | 
| 
26ad7827a62d
Support status query for a single file or a subdirectory of a repository
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
219diff
changeset | 540 return walker.name(); | 
| 
26ad7827a62d
Support status query for a single file or a subdirectory of a repository
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
219diff
changeset | 541 } | 
| 
26ad7827a62d
Support status query for a single file or a subdirectory of a repository
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
219diff
changeset | 542 | 
| 
26ad7827a62d
Support status query for a single file or a subdirectory of a repository
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
219diff
changeset | 543 public File file() { | 
| 
26ad7827a62d
Support status query for a single file or a subdirectory of a repository
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
219diff
changeset | 544 return walker.file(); | 
| 
26ad7827a62d
Support status query for a single file or a subdirectory of a repository
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
219diff
changeset | 545 } | 
| 
26ad7827a62d
Support status query for a single file or a subdirectory of a repository
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
219diff
changeset | 546 | 
| 
26ad7827a62d
Support status query for a single file or a subdirectory of a repository
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
219diff
changeset | 547 public boolean inScope(Path file) { | 
| 229 
1ec6b327a6ac
Scope for status reworked: explicit files or a general matcher
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
226diff
changeset | 548 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: 
219diff
changeset | 549 } | 
| 
26ad7827a62d
Support status query for a single file or a subdirectory of a repository
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
219diff
changeset | 550 } | 
| 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 | 551 } | 
