diff --git a/mercurial/filemerge.py b/mercurial/filemerge.py --- a/mercurial/filemerge.py +++ b/mercurial/filemerge.py @@ -138,9 +138,6 @@ def filemerge(repo, mynode, orig, fcd, f if not fco.cmp(fcd.data()): # files identical? return None - if fca == fco: # backwards, use working dir parent as ancestor - fca = fcd.parents()[0] - ui = repo.ui fd = fcd.path() binary = isbin(fcd) or isbin(fco) or isbin(fca) diff --git a/mercurial/merge.py b/mercurial/merge.py --- a/mercurial/merge.py +++ b/mercurial/merge.py @@ -270,7 +270,12 @@ def applyupdates(repo, action, wctx, mct repo.ui.debug("preserving %s for resolve of %s\n" % (f, fd)) fcl = wctx[f] fco = mctx[f2] - fca = fcl.ancestor(fco, actx) or repo.filectx(f, fileid=nullrev) + if mctx == actx: # backwards, use working dir parent as ancestor + fca = fcl.parents()[0] + else: + fca = fcl.ancestor(fco, actx) + if not fca: + fca = repo.filectx(f, fileid=nullrev) ms.add(fcl, fco, fca, fd, flags) if f != fd and move: moves.append(f)