Patchwork [1,of,9] histedit: add histedit state class

login
register
mail settings
Submitter David Soria Parra
Date Oct. 16, 2014, 5:34 p.m.
Message ID <edad9c65c45a5ba80943.1413480877@davidsp-mbp.dhcp.thefacebook.com>
Download mbox | patch
Permalink /patch/6337/
State Accepted
Headers show

Comments

David Soria Parra - Oct. 16, 2014, 5:34 p.m.
# HG changeset patch
# User David Soria Parra <davidsp@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.

Patch

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>