# HG changeset patch # User timeless # Date 2015-12-28 22:53:22 # Node ID bf0900d3819c5d7605357d803f80b58394956def # Parent 69df2081aeb5dfde782ab7faa81c28baff367027 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 @@ class edit(histeditaction): @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 @@ Attempting to fold a change into a publi > 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 @@ Attempting to fold a change into a publi # 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