changeset 22976:886711722db6

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.
author David Soria Parra <davidsp@fb.com>
date Wed, 15 Oct 2014 17:17:12 -0700
parents 461342e1c8aa
children 29ae3b190ec5
files hgext/histedit.py
diffstat 1 files changed, 19 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- 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>