// Register new/changed
FNCacheFile.Mediator fncache = new FNCacheFile.Mediator(repo, transaction);
ArrayList<Path> touchInDirstate = new ArrayList<Path>();
for (Pair<HgDataFile, DataSource> e : files.values()) {
HgDataFile df = e.first();
DataSource bds = e.second();
Pair<Integer, Integer> fp = fileParents.get(df.getPath());
if (fp == null) {
// NEW FILE, either just added or resurrected from p2
Nodeid fileRevInP2;
if ((fileRevInP2 = c2Manifest.nodeid(df.getPath())) != null) {
fp = new Pair<Integer, Integer>(df.getRevisionIndex(fileRevInP2), NO_REVISION);
} else {
// brand new
fp = new Pair<Integer, Integer>(NO_REVISION, NO_REVISION);
}
}
// TODO if fp.first() != NO_REVISION and fp.second() != NO_REVISION check if one
// revision is ancestor of another and use the latest as p1, then
Nodeid fileRev = null;
final boolean isNewFile = !df.exists();
if (fp.first() != NO_REVISION && fp.second() == NO_REVISION && !isNewFile) {
// compare file contents to see if anything has changed, and reuse old revision, if unchanged.
// XXX ineffective, need better access to revision conten
ByteArraySerializer bas = new ByteArraySerializer();
bds.serialize(bas);
final byte[] newContent = bas.toByteArray();
// unless there's a way to reset DataSource, replace it with the content just read
bds = new DataSerializer.ByteArrayDataSource(newContent);
if (new ComparatorChannel(newContent).same(df, fp.first())) {
fileRev = df.getRevision(fp.first());