[evolve] amend: check phase before starting the transition stable
authorPierre-Yves David <pierre-yves.david@logilab.fr>
Tue, 21 Aug 2012 12:42:09 +0200
branchstable
changeset 475 9f69a5e41ab0
parent 474 5c031e1c90e2
child 476 f17a0f801e0b
[evolve] amend: check phase before starting the transition We better abort before starting a useless transaction.
hgext/evolve.py
tests/test-evolve.t
--- a/hgext/evolve.py	Tue Aug 21 12:38:19 2012 +0200
+++ b/hgext/evolve.py	Tue Aug 21 12:42:09 2012 +0200
@@ -413,11 +413,11 @@
     try:
         wlock = repo.wlock()
         try:
+            if old.phase() == phases.public:
+                raise util.Abort(_("can not rewrite immutable changeset %s")
+                                 % old)
             tr = repo.transaction('amend')
             try:
-                if old.phase() == phases.public:
-                    raise util.Abort(_("can not rewrite immutable changeset %s")
-                                     % old)
                 oldphase = old.phase()
                 # commit current changes as update
                 # code copied from commands.commit to avoid noisy messages
--- a/tests/test-evolve.t	Tue Aug 21 12:38:19 2012 +0200
+++ b/tests/test-evolve.t	Tue Aug 21 12:42:09 2012 +0200
@@ -229,8 +229,15 @@
   $ hg bookmark -i feature-A
   $ sed -i'' -e s/Eins/Un/ main-file-1
 
+(amend of public changeset denied)
+
   $ hg phase --public 0 -v
   phase changed for 1 changesets
+  $ hg amend -c 2
+  abort: cannot amend non ancestor changeset
+  [255]
+
+
   $ hg amend --note 'french looks better'
   1 new unstables changesets
   $ hg log