[PATCH 1 of 9] histedit: add histedit state class

David Soria Parra davidsp at fb.com
Thu Oct 16 17:34:37 UTC 2014


# HG changeset patch
# User David Soria Parra <davidsp at fb.com>
# Date 1413418632 25200
#      Wed Oct 15 17:17:12 2014 -0700
# Node ID edad9c65c45a5ba8094321d8fc69705fb98bbfa1
# Parent  75d0edb68b417964110e3fcd69187c867f31a119
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.

diff --git a/hgext/histedit.py b/hgext/histedit.py
--- a/hgext/histedit.py
+++ b/hgext/histedit.py
@@ -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>
 


More information about the Mercurial-devel mailing list