dirstateBuilder.parents(headCset1, clog.getRevision(secondCset));
//
MergeStateBuilder mergeStateBuilder = new MergeStateBuilder(implRepo);
mergeStateBuilder.prepare(headCset1);
ManifestRevision m1, m2, ma;
m1 = new ManifestRevision(cacheRevs, cacheFiles).init(repo, firstCset);
m2 = new ManifestRevision(cacheRevs, cacheFiles).init(repo, secondCset);
ma = new ManifestRevision(cacheRevs, cacheFiles).init(repo, ancestorCset);
Transaction transaction = implRepo.getTransactionFactory().create(repo);
ResolverImpl resolver = new ResolverImpl(implRepo, dirstateBuilder, mergeStateBuilder);
try {
for (Path f : m1.files()) {
Nodeid fileRevBase, fileRevA, fileRevB;
if (m2.contains(f)) {
fileRevA = m1.nodeid(f);
fileRevB = m2.nodeid(f);
fileRevBase = ma.contains(f) ? ma.nodeid(f) : null;
if (fileRevA.equals(fileRevB)) {
HgFileRevision fr = new HgFileRevision(repo, fileRevA, m1.flags(f), f);
resolver.presentState(f, fr, fr, null);
mediator.same(fr, resolver);
} else if (fileRevBase == fileRevA) {
assert fileRevBase != null;
HgFileRevision frBase = new HgFileRevision(repo, fileRevBase, ma.flags(f), f);
HgFileRevision frSecond= new HgFileRevision(repo, fileRevB, m2.flags(f), f);
resolver.presentState(f, frBase, frSecond, frBase);
mediator.fastForwardB(frBase, frSecond, resolver);
} else if (fileRevBase == fileRevB) {
assert fileRevBase != null;
HgFileRevision frBase = new HgFileRevision(repo, fileRevBase, ma.flags(f), f);
HgFileRevision frFirst = new HgFileRevision(repo, fileRevA, m1.flags(f), f);
resolver.presentState(f, frFirst, frBase, frBase);
mediator.fastForwardA(frBase, frFirst, resolver);
} else {
HgFileRevision frBase = fileRevBase == null ? null : new HgFileRevision(repo, fileRevBase, ma.flags(f), f);
HgFileRevision frFirst = new HgFileRevision(repo, fileRevA, m1.flags(f), f);
HgFileRevision frSecond= new HgFileRevision(repo, fileRevB, m2.flags(f), f);
resolver.presentState(f, frFirst, frSecond, frBase);
mediator.resolve(frBase, frFirst, frSecond, resolver);
}
} else {
// m2 doesn't contain the file, either new in m1, or deleted in m2
HgFileRevision frFirst = new HgFileRevision(repo, m1.nodeid(f), m1.flags(f), f);
if (ma.contains(f)) {
// deleted in m2
HgFileRevision frBase = new HgFileRevision(repo, ma.nodeid(f), ma.flags(f), f);
resolver.presentState(f, frFirst, null, frBase);
mediator.onlyA(frBase, frFirst, resolver);
} else {
// new in m1
resolver.presentState(f, frFirst, null, null);
mediator.newInA(frFirst, resolver);
}
}
resolver.apply();
} // for m1 files
for (Path f : m2.files()) {
if (m1.contains(f)) {
continue;
}
HgFileRevision frSecond= new HgFileRevision(repo, m2.nodeid(f), m2.flags(f), f);
// file in m2 is either new or deleted in m1
if (ma.contains(f)) {