# HG changeset patch # User David Soria Parra # Date 2014-10-16 00:17:12 # Node ID 886711722db671d7bdd4ba3f5a04da88ec06b8b2 # Parent 461342e1c8aa2d7a0602bbbb0868c704513a8c38 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 @@ editcomment = _("""# Edit history betwee # """) +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