normal = new LinkedHashMap<Path, Record>();
added = new LinkedHashMap<Path, Record>();
removed = new LinkedHashMap<Path, Record>();
merged = new LinkedHashMap<Path, Record>();
DirstateReader dirstateReader = new DirstateReader(repo, pathPool);
dirstateReader.readInto(new Inspector() {
public boolean next(EntryKind kind, Record r) {
if (canonicalPathRewrite != null) {
Path canonicalPath = pathPool.path(canonicalPathRewrite.rewrite(r.name()));
if (canonicalPath != r.name()) { // == as they come from the same pool
assert !canonical2dirstateName.containsKey(canonicalPath); // otherwise there's already a file with same canonical name
// which can't happen for case-insensitive file system (or there's erroneous PathRewrite, perhaps doing smth else)
canonical2dirstateName.put(canonicalPath, r.name());
}
if (r.copySource() != null) {
// not sure I need copy origin in the map, I don't seem to use it anywhere,
// but I guess I'll have to use it some day.
canonicalPath = pathPool.path(canonicalPathRewrite.rewrite(r.copySource()));
if (canonicalPath != r.copySource()) {
canonical2dirstateName.put(canonicalPath, r.copySource());
}
}
}
switch (kind) {
case Normal : normal.put(r.name(), r); break;
case Added : added.put(r.name(), r); break;
case Removed : removed.put(r.name(), r); break;
case Merged : merged.put(r.name1, r); break;
default: throw new HgInvalidStateException(String.format("Unexpected entry in the dirstate: %s", kind));
}
return true;
}
});
parents = dirstateReader.parents();
}