changeset 477:fded4d945f87

merge with stable improvement
author Pierre-Yves David <pierre-yves.david@logilab.fr>
date Tue, 21 Aug 2012 12:47:50 +0200
parents 1f8f8dd75d18 (current diff) f17a0f801e0b (diff)
children 13ccb68b728d
files hgext/evolve.py tests/test-evolve.t
diffstat 2 files changed, 21 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/evolve.py	Tue Aug 21 04:36:25 2012 +0200
+++ b/hgext/evolve.py	Tue Aug 21 12:47:50 2012 +0200
@@ -569,11 +569,13 @@
     try:
         wlock = repo.wlock()
         try:
+            if old.phase() == phases.public:
+                raise util.Abort(_("can not rewrite immutable changeset %s")
+                                 % old)
+            if not repo.revs('%d and (::.)', old):
+                raise error.Abort(_('cannot amend non ancestor changeset'))
             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 04:36:25 2012 +0200
+++ b/tests/test-evolve.t	Tue Aug 21 12:47:50 2012 +0200
@@ -230,6 +230,21 @@
   $ 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]
+
+
+(amend of on ancestors)
+
+  $ hg amend -c 2
+  abort: cannot amend non ancestor changeset
+  [255]
+
   $ hg amend --note 'french looks better'
   1 new unstables changesets
   $ hg log
@@ -251,7 +266,7 @@
   | |/
   | x  1:568a468b60fc@default(draft) a nifty feature
   |/
-  @  0:e55e0562ee93@default(draft) base
+  @  0:e55e0562ee93@default(public) base
   
   $ hg debugobsolete
   524e478d4811d405c8771e4c441de4483bdf8b33 f8111a076f0975cbecb336e2bd3411be22b673fb 0 {'date': '* *', 'user': 'test'} (glob)