} else {
rev1 = baseRevision;
}
((HgStatusCollector.Record) inspector).init(rev1, rev2, sc);
}
final CancelSupport cs = CancelSupport.Factory.get(inspector);
final HgIgnore hgIgnore = repo.getIgnore();
repoWalker.reset();
TreeSet<Path> processed = new TreeSet<Path>(); // names of files we handled as they known to Dirstate (not FileIterator)
final HgDirstate ds = getDirstateImpl();
TreeSet<Path> knownEntries = ds.all(); // here just to get dirstate initialized
while (repoWalker.hasNext()) {
cs.checkCancelled();
repoWalker.next();
final Path fname = getPathPool().mangle(repoWalker.name());
FileInfo f = repoWalker.file();
Path knownInDirstate;
if (!f.exists()) {
// file coming from iterator doesn't exist.
if ((knownInDirstate = ds.known(fname)) != null) {
// found in dirstate
processed.add(knownInDirstate);
if (ds.checkRemoved(knownInDirstate) == null) {
inspector.missing(knownInDirstate);
} else {
inspector.removed(knownInDirstate);
}
// do not report it as removed later
if (collect != null) {
baseRevFiles.remove(knownInDirstate);
}
} else {
// chances are it was known in baseRevision. We may rely
// that later iteration over baseRevFiles leftovers would yield correct Removed,
// but it doesn't hurt to be explicit (provided we know fname *is* inScope of the FileIterator
if (collect != null && baseRevFiles.remove(fname)) {
inspector.removed(fname);
} else {
// not sure I shall report such files (i.e. arbitrary name coming from FileIterator)
// as unknown. Command-line HG aborts "system can't find the file specified"
// in similar case (against wc), or just gives nothing if --change <rev> is specified.
// however, as it's unlikely to get unexisting files from FileIterator, and
// its better to see erroneous file status rather than not to see any (which is too easy
// to overlook), I think unknown() is reasonable approach here
inspector.unknown(fname);
}
}
continue;
}
if ((knownInDirstate = ds.known(fname)) != null) {
// tracked file.
// modified, added, removed, clean
processed.add(knownInDirstate);
if (collect != null) { // need to check against base revision, not FS file
checkLocalStatusAgainstBaseRevision(baseRevFiles, collect, baseRevision, knownInDirstate, f, inspector);
} else {
checkLocalStatusAgainstFile(knownInDirstate, f, inspector);
}
} else {
if (hgIgnore.isIgnored(fname)) { // hgignore shall be consulted only for non-tracked files
inspector.ignored(fname);
} else {
inspector.unknown(fname);
}
// the file is not tracked. Even if it's known at baseRevision, we don't need to remove it
// from baseRevFiles, it might need to be reported as removed as well (cmdline client does
// yield two statuses for the same file)
}
}
if (collect != null) {
// perhaps, this code shall go after processing leftovers of knownEntries, below
// as it's sort of last resort - what to do with otherwise unprocessed base revision files
for (Path fromBase : baseRevFiles) {
if (repoWalker.inScope(fromBase)) {
inspector.removed(fromBase);
processed.add(fromBase);
cs.checkCancelled();
}
}
}
knownEntries.removeAll(processed);
for (Path m : knownEntries) {
if (!repoWalker.inScope(m)) {
// do not report as missing/removed those FileIterator doesn't care about.
continue;
}
cs.checkCancelled();
// missing known file from a working dir
if (ds.checkRemoved(m) == null) {
// not removed from the repository = 'deleted'
inspector.missing(m);
} else {