# HG changeset patch # User Pierre-Yves David # Date 1500853517 -7200 # Node ID 554c069cdc85fb1ad99ce6088bd9f23b06f9f89b # Parent ebca049e8ca9668188d332c79000e197a7366f08 uncommit: use precheck to validate revision This gives us standard check and standard error message. diff -r ebca049e8ca9 -r 554c069cdc85 hgext3rd/evolve/cmdrewrite.py --- a/hgext3rd/evolve/cmdrewrite.py Sun Jul 23 21:20:46 2017 +0200 +++ b/hgext3rd/evolve/cmdrewrite.py Mon Jul 24 01:45:17 2017 +0200 @@ -266,8 +266,7 @@ if len(wctx.parents()) > 1: raise error.Abort(_("cannot uncommit while merging")) old = repo['.'] - if old.phase() == phases.public: - raise error.Abort(_("cannot rewrite immutable changeset")) + rewriteutil.precheck(repo, [repo['.'].rev()], action='uncommit') if len(old.parents()) > 1: raise error.Abort(_("cannot uncommit merge changeset")) oldphase = old.phase() diff -r ebca049e8ca9 -r 554c069cdc85 tests/test-evolve.t --- a/tests/test-evolve.t Sun Jul 23 21:20:46 2017 +0200 +++ b/tests/test-evolve.t Mon Jul 24 01:45:17 2017 +0200 @@ -1280,7 +1280,8 @@ $ hg up 8dc373be86d9^ 0 files updated, 0 files merged, 2 files removed, 0 files unresolved $ hg uncommit --all - abort: cannot uncommit in the middle of a stack + abort: uncommit will orphan 4 descendants + (see 'hg help evolution.instability') [255] $ hg up 8dc373be86d9 2 files updated, 0 files merged, 0 files removed, 0 files unresolved diff -r ebca049e8ca9 -r 554c069cdc85 tests/test-uncommit.t --- a/tests/test-uncommit.t Sun Jul 23 21:20:46 2017 +0200 +++ b/tests/test-uncommit.t Mon Jul 24 01:45:17 2017 +0200 @@ -13,7 +13,8 @@ Cannot uncommit null changeset $ hg uncommit - abort: cannot rewrite immutable changeset + abort: cannot uncommit the null revision + (no changeset checked out) [255] Cannot uncommit public changeset @@ -22,7 +23,8 @@ $ hg ci -Am adda a $ hg phase --public . $ hg uncommit - abort: cannot rewrite immutable changeset + abort: cannot uncommit public changesets: 07f494440405 + (see 'hg help phases' for details) [255] $ hg phase --force --draft .