# HG changeset patch # User Matt Mackall # Date 2010-10-09 19:50:20 # Node ID 545ec17750210b31b51261092c0f010fc9376e32 # Parent 8269af351a64b186a575fdd492e19e28e9575397 merge: handle no file parent in backwards merge (issue2364) diff --git a/mercurial/merge.py b/mercurial/merge.py --- a/mercurial/merge.py +++ b/mercurial/merge.py @@ -276,7 +276,10 @@ def applyupdates(repo, action, wctx, mct fcl = wctx[f] fco = mctx[f2] if mctx == actx: # backwards, use working dir parent as ancestor - fca = fcl.parents()[0] + if fcl.parents(): + fca = fcl.parents()[0] + else: + fca = repo.filectx(f, fileid=nullrev) else: fca = fcl.ancestor(fco, actx) if not fca: diff --git a/tests/test-merge1.t b/tests/test-merge1.t --- a/tests/test-merge1.t +++ b/tests/test-merge1.t @@ -166,3 +166,11 @@ merge of b expected +This is file b33 $ hg status M b + +Test for issue2364 + + $ hg up -qC . + $ hg rm b + $ hg ci -md + $ hg revert -r -2 b + $ hg up -q -- -2