Patchwork [evolve-ext,v2] uncommit: abort when rev specifies the current changeset

login
register
mail settings
Submitter Nathan Goldbaum
Date Nov. 1, 2014, 4:36 p.m.
Message ID <da3e952af9963e6050d0.1414859810@ROUS>
Download mbox | patch
Permalink /patch/6504/
State Not Applicable
Headers show

Comments

Nathan Goldbaum - Nov. 1, 2014, 4:36 p.m.
# HG changeset patch
# User Nathan Goldbaum <ngoldbau@ucsc.edu>
# Date 1414544788 25200
#      Tue Oct 28 18:06:28 2014 -0700
# Node ID da3e952af9963e6050d05ad0eb0f7387d24e7efb
# Parent  b7d85cd8ec7bd5a4ba5a61d156745269a999450b
uncommit: abort when rev specifies the current changeset

The uncommit command now fails when the rev argument indicates the current
changeset. Previously this aborted in the changeset obsolescence machinery when
the current commit tries to obsolete itself.

Using the rev argument like this indicates a misunderstanding, so printing an
uncommit-specific error should make it easier to understand what went wrong.
Pierre-Yves David - Nov. 1, 2014, 5:11 p.m.
On 11/01/2014 04:36 PM, Nathan Goldbaum wrote:
> # HG changeset patch
> # User Nathan Goldbaum <ngoldbau@ucsc.edu>
> # Date 1414544788 25200
> #      Tue Oct 28 18:06:28 2014 -0700
> # Node ID da3e952af9963e6050d05ad0eb0f7387d24e7efb
> # Parent  b7d85cd8ec7bd5a4ba5a61d156745269a999450b
> uncommit: abort when rev specifies the current changeset

perfect, pushed to main. Thanks a lot.

Patch

diff -r b7d85cd8ec7b -r da3e952af996 hgext/evolve.py
--- a/hgext/evolve.py	Sat Oct 25 22:25:42 2014 -0400
+++ b/hgext/evolve.py	Tue Oct 28 18:06:28 2014 -0700
@@ -1979,6 +1979,9 @@ 
         rev = None
         if opts.get('rev'):
             rev = scmutil.revsingle(repo, opts.get('rev'))
+            ctx = repo[None]
+            if ctx.p1() == rev or ctx.p2() == rev:
+                raise util.Abort(_("cannot uncommit to parent changeset"))
 
         # Recommit the filtered changeset
         tr = repo.transaction('uncommit')
diff -r b7d85cd8ec7b -r da3e952af996 tests/test-uncommit.t
--- a/tests/test-uncommit.t	Sat Oct 25 22:25:42 2014 -0400
+++ b/tests/test-uncommit.t	Tue Oct 28 18:06:28 2014 -0700
@@ -347,6 +347,9 @@ 
   $ hg cat b --rev 0
   b: no such file in rev 07f494440405
   [1]
+  $ hg uncommit --rev . b
+  abort: cannot uncommit to parent changeset
+  [255]
   $ hg uncommit --rev 0 b
   $ hg cat b --rev .
   b: no such file in rev 5b27f6b17da2