[PATCH 7 of 9] histedit: add tostate method to histedit action

Mateusz Kwapich mitrandir at fb.com
Wed Dec 2 14:22:59 CST 2015


# HG changeset patch
# User Mateusz Kwapich <mitrandir at fb.com>
# Date 1449087541 28800
#      Wed Dec 02 12:19:01 2015 -0800
# Node ID ff948bfcd6d3b9aa7c8b15148f0180bc790efba6
# Parent  b546c0415d7fb6df9d1824f160be90378d51dce8
histedit: add tostate method to histedit action

the format of rules that we store in state file format is different from the rule
format that we present to users. We need a way of dumping action to state file.

diff --git a/hgext/histedit.py b/hgext/histedit.py
--- a/hgext/histedit.py
+++ b/hgext/histedit.py
@@ -376,6 +376,12 @@
         maxlen = max(maxlen, 22) # avoid truncating hash
         return util.ellipsis(line, maxlen)
 
+    def tostate(self):
+        """Print an action in format used by histedit state files
+           (the first line is a verb, the remainder is the second)
+        """
+        return "%s\n%s" % (self.verb, node.hex(self.node))
+
     def constraints(self):
         """Return a set of constrains that this action should be verified for
         """


More information about the Mercurial-devel mailing list