hgext/evolve.py
changeset 477 fded4d945f87
parent 470 a2dfe82f27a0
parent 476 f17a0f801e0b
child 481 4e0f1aae8d24
--- 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