diff hgext/histedit.py @ 27542:bf0900d3819c

histedit: check fold of public change during verify
author timeless <timeless@mozdev.org>
date Mon, 28 Dec 2015 22:53:22 +0000
parents 69df2081aeb5
children ff0e4c8e642d
line wrap: on
line diff
--- 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]