diff --git a/hgext3rd/uncommit.py b/hgext3rd/uncommit.py --- a/hgext3rd/uncommit.py +++ b/hgext3rd/uncommit.py @@ -161,9 +161,13 @@ if newid is None: raise error.Abort(_('nothing to uncommit')) - # Move local changes on filtered changeset - obsolete.createmarkers(repo, [(old, (repo[newid],))]) - phases.retractboundary(repo, tr, oldphase, [newid]) + if newid != old.p1().node(): + # Move local changes on filtered changeset + obsolete.createmarkers(repo, [(old, (repo[newid],))]) + phases.retractboundary(repo, tr, oldphase, [newid]) + else: + # Fully removed the old commit + obsolete.createmarkers(repo, [(old, ())]) with repo.dirstate.parentchange(): repo.dirstate.setparents(newid, node.nullid) diff --git a/tests/test-uncommit.t b/tests/test-uncommit.t --- a/tests/test-uncommit.t +++ b/tests/test-uncommit.t @@ -174,4 +174,29 @@ |/ o 0:3004d2d9b50883c1538fc754a3aeb55f1b4084f6 added file-a +Uncommit with draft parent + $ hg uncommit + $ hg phase -r . + 10: draft + $ hg commit -m 'update ab again' + +Uncommit with public parent + + $ hg phase -p "::.^" + $ hg uncommit + $ hg phase -r . + 10: public + +Partial uncommit with public parent + + $ echo xyz > xyz + $ hg add xyz + $ hg commit -m "update ab and add xyz" + $ hg uncommit xyz + $ hg status + A xyz + $ hg phase -r . + 14: draft + $ hg phase -r ".^" + 10: public