histedit: add histedit state class
authorDavid Soria Parra <davidsp@fb.com>
Wed, 15 Oct 2014 17:17:12 -0700
changeset 22976 886711722db6
parent 22975 461342e1c8aa
child 22977 29ae3b190ec5
histedit: add histedit state class Add an histeditstate class that is intended to hold the current state. This allows us encapsulate the state and avoids passing around a tuple which is based on the serialization format. In particular this will give actions more control over the state and allow external sources to have more control of histedits behavior, e.g. an external implementation of x/exec.
hgext/histedit.py
--- a/hgext/histedit.py	Fri Oct 17 02:07:05 2014 +0900
+++ b/hgext/histedit.py	Wed Oct 15 17:17:12 2014 -0700
@@ -188,6 +188,25 @@
 #
 """)
 
+class histeditstate(object):
+    def __init__(self, repo, parentctxnode=None, rules=None, keep=None,
+            topmost=None, replacements=None):
+        self.repo = repo
+        self.parentctxnode = parentctxnode
+        self.rules = rules
+        self.keep = keep
+        self.topmost = topmost
+        if replacements is None:
+            self.replacements = []
+        else:
+            self.replacements = replacements
+
+    def write(self):
+        fp = self.repo.vfs('histedit-state', 'w')
+        pickle.dump((self.parentctxnode, self.rules, self.keep,
+            self.topmost, self.replacements), fp)
+        fp.close()
+
 def commitfuncfor(repo, src):
     """Build a commit function for the replacement of <src>