diff --git a/hgext/uncommit.py b/hgext/uncommit.py --- a/hgext/uncommit.py +++ b/hgext/uncommit.py @@ -93,13 +93,13 @@ extra=ctx.extra()) return repo.commitctx(new) -def _fixdirstate(repo, oldctx, newctx, status): +def _fixdirstate(repo, oldctx, newctx, match=None): """ fix the dirstate after switching the working directory from oldctx to newctx which can be result of either unamend or uncommit. """ ds = repo.dirstate copies = dict(ds.copies()) - s = status + s = newctx.status(oldctx, match=match) for f in s.modified: if ds[f] == 'r': # modified + removed -> removed @@ -121,11 +121,7 @@ ds.remove(f) # Merge old parent and old working dir copies - oldcopies = {} - for f in (s.modified + s.added): - src = oldctx[f].renamed() - if src: - oldcopies[f] = src[0] + oldcopies = copiesmod.pathcopies(newctx, oldctx, match) oldcopies.update(copies) copies = dict((dst, oldcopies.get(src, src)) for dst, src in oldcopies.iteritems()) @@ -181,8 +177,7 @@ with repo.dirstate.parentchange(): repo.dirstate.setparents(newid, node.nullid) - s = old.p1().status(old, match=match) - _fixdirstate(repo, old, repo[newid], s) + _fixdirstate(repo, old, repo[newid], match) scmutil.cleanupnodes(repo, mapping, 'uncommit', fixphase=True) @@ -245,8 +240,7 @@ with dirstate.parentchange(): dirstate.setparents(newprednode, node.nullid) - s = repo.status(predctx, curctx) - _fixdirstate(repo, curctx, newpredctx, s) + _fixdirstate(repo, curctx, newpredctx) mapping = {curctx.node(): (newprednode,)} scmutil.cleanupnodes(repo, mapping, 'unamend', fixphase=True) diff --git a/tests/test-unamend.t b/tests/test-unamend.t --- a/tests/test-unamend.t +++ b/tests/test-unamend.t @@ -385,9 +385,9 @@ A b a R a -BROKEN: should indicate that b was renamed to c $ hg st --copies A c + b R b $ hg revert -qa $ rm c @@ -405,7 +405,7 @@ A b a R a -BROKEN: should indicate that b was renamed to d $ hg st --copies A d + b R b