histedit: check fold of public change during verify
authortimeless <timeless@mozdev.org>
Mon, 28 Dec 2015 22:53:22 +0000
changeset 27542 bf0900d3819c
parent 27541 69df2081aeb5
child 27543 ff0e4c8e642d
histedit: check fold of public change during verify
hgext/histedit.py
tests/test-histedit-edit.t
--- a/hgext/histedit.py	Mon Dec 28 22:52:48 2015 +0000
+++ b/hgext/histedit.py	Mon Dec 28 22:53:22 2015 +0000
@@ -621,6 +621,22 @@
 
 @addhisteditaction(['fold', 'f'])
 class fold(histeditaction):
+    def verify(self, prev):
+        """ Verifies semantic correctness of the fold rule"""
+        super(fold, self).verify(prev)
+        repo = self.repo
+        state = self.state
+        if not prev:
+            c = repo[self.node].parents()[0]
+        elif not prev.verb in ('pick', 'base'):
+            return
+        else:
+            c = repo[prev.node]
+        if not c.mutable():
+            raise error.Abort(
+                _("cannot fold into public change %s") % node.short(c.node()))
+
+
     def continuedirty(self):
         repo = self.repo
         rulectx = repo[self.node]
--- a/tests/test-histedit-edit.t	Mon Dec 28 22:52:48 2015 +0000
+++ b/tests/test-histedit-edit.t	Mon Dec 28 22:53:22 2015 +0000
@@ -451,9 +451,6 @@
   > mv tmp "\$1"
   > EOF
   $ HGEDITOR="sh ../edit.sh" hg histedit 2
-  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
-  reverting a
-  1 files updated, 0 files merged, 1 files removed, 0 files unresolved
   warning: histedit rules saved to: .hg/histedit-last-edit.txt
   abort: cannot fold into public change 18aa70c8ad22
   [255]
@@ -472,6 +469,3 @@
   #  d, drop = remove commit from history
   #  m, mess = edit commit message without changing commit content
   #
-TODO: this abort shouldn't be required, but it is for now to leave the repo in
-a clean state.
-  $ hg histedit --abort