Mercurial > hg
changeset 38505:c6a2ce82e60b
histedit: factor out logic of processing state data in separate fn
The new function will serve as the point from where we always get a dictionary
of data stored in the statefile and will be helpful in integrating
state.cmdstate.read() to write statefile in cbor.
Differential Revision: https://phab.mercurial-scm.org/D3863
author | Pulkit Goyal <7895pulkit@gmail.com> |
---|---|
date | Sat, 30 Jun 2018 07:10:49 +0530 |
parents | 3beb0ea083df |
children | 18f348e035fb |
files | hgext/histedit.py |
diffstat | 1 files changed, 17 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/histedit.py Sat Jun 30 07:05:36 2018 +0530 +++ b/hgext/histedit.py Sat Jun 30 07:10:49 2018 +0530 @@ -318,22 +318,29 @@ raise cmdutil.wrongtooltocontinue(self.repo, _('histedit')) - if state.startswith('v1\n'): + data = self._read(state) + + self.parentctxnode = data['parentctxnode'] + actions = parserules(data['rules'], self) + self.actions = actions + self.keep = data['keep'] + self.topmost = data['topmost'] + self.replacements = data['replacements'] + self.backupfile = data['backupfile'] + + def _read(self, fp): + if fp.startswith('v1\n'): data = self._load() parentctxnode, rules, keep, topmost, replacements, backupfile = data else: - data = pickle.loads(state) + data = pickle.loads(fp) parentctxnode, rules, keep, topmost, replacements = data backupfile = None + rules = "\n".join(["%s %s" % (verb, rest) for [verb, rest] in rules]) - self.parentctxnode = parentctxnode - rules = "\n".join(["%s %s" % (verb, rest) for [verb, rest] in rules]) - actions = parserules(rules, self) - self.actions = actions - self.keep = keep - self.topmost = topmost - self.replacements = replacements - self.backupfile = backupfile + return {'parentctxnode': parentctxnode, "rules": rules, "keep": keep, + "topmost": topmost, "replacements": replacements, + "backupfile": backupfile} def write(self, tr=None): if tr: