[PATCH 1 of 9] histedit: add actions property to histedit state

Mateusz Kwapich mitrandir at fb.com
Wed Dec 2 20:22:53 UTC 2015


# HG changeset patch
# User Mateusz Kwapich <mitrandir at fb.com>
# Date 1449087541 28800
#      Wed Dec 02 12:19:01 2015 -0800
# Node ID 3a18e4a826d770a29724ac8de8f04f3f89465628
# Parent  91905c0c47377520eebdedcfa6bcb73b77e24e0c
histedit: add actions property to histedit state

I want to refactor histedit to use action objects instead of (verb, rest)
pairs whenever possible. At the end of this series I want the rules to
be translated into action objects when reading state and translated back
when writing state. All histedit internals should use action objects instead
of state rules.

To migrate histedti internals sequentially I'm introducing the state.actions
property to translate rules on the fly so we can use both state.actions and
state.rules until refactoring is done.

diff --git a/hgext/histedit.py b/hgext/histedit.py
--- a/hgext/histedit.py
+++ b/hgext/histedit.py
@@ -328,6 +328,14 @@
     def inprogress(self):
         return self.repo.vfs.exists('histedit-state')
 
+    @property
+    def actions(self):
+        actions = []
+        for (act, rest) in self.rules:
+            actions.append(actiontable[act].fromrule(self, rest))
+        return actions
+
+
 class histeditaction(object):
     def __init__(self, state, node):
         self.state = state


More information about the Mercurial-devel mailing list