Patchwork D3863: histedit: factor out logic of processing state data in separate fn

login
register
mail settings
Submitter phabricator
Date July 1, 2018, 12:37 p.m.
Message ID <0693379474a3630dc5a6d739a77a6955@localhost.localdomain>
Download mbox | patch
Permalink /patch/32545/
State Not Applicable
Headers show

Comments

phabricator - July 1, 2018, 12:37 p.m.
This revision was automatically updated to reflect the committed changes.
Closed by commit rHGc6a2ce82e60b: histedit: factor out logic of processing state data in separate fn (authored by pulkit, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D3863?vs=9375&id=9389

REVISION DETAIL
  https://phab.mercurial-scm.org/D3863

AFFECTED FILES
  hgext/histedit.py

CHANGE DETAILS




To: pulkit, durin42, #hg-reviewers
Cc: mercurial-devel

Patch

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