[PATCH 2 of 7] histedit: check fold of public change during verify

timeless timeless at mozdev.org
Mon Dec 28 17:29:13 CST 2015


# HG changeset patch
# User timeless <timeless at mozdev.org>
# Date 1451343202 0
#      Mon Dec 28 22:53:22 2015 +0000
# Node ID a019a4d808aaa8b517f834975ef93dc21fa021d4
# Parent  4ae45cf8a383d0a948cbccedc7e9f3c699e2fd27
histedit: check fold of public change during verify

diff --git a/hgext/histedit.py b/hgext/histedit.py
--- a/hgext/histedit.py
+++ b/hgext/histedit.py
@@ -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]
diff --git a/tests/test-histedit-edit.t b/tests/test-histedit-edit.t
--- a/tests/test-histedit-edit.t
+++ b/tests/test-histedit-edit.t
@@ -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


More information about the Mercurial-devel mailing list