histedit: break _histedit function into smaller pieces (add _editplanaction)
authorKostia Balytskyi <ikostia@fb.com>
Mon, 01 Feb 2016 14:12:38 +0000
changeset 28131 5a2fb2680a39
parent 28130 47317570ab8c
child 28132 2d09a400b495
histedit: break _histedit function into smaller pieces (add _editplanaction) This is a part of bigger effort to refactor histedit. Initial steps are to break _histedit function into smaller pieces which will supposedly be more understandable. After this is done, I will have a better understanding of how histedit works and apply that to fix issue4800.
hgext/histedit.py
--- a/hgext/histedit.py	Mon Feb 01 12:51:20 2016 +0000
+++ b/hgext/histedit.py	Mon Feb 01 14:12:38 2016 +0000
@@ -1044,24 +1044,7 @@
         state.read()
         state = bootstrapcontinue(ui, state, opts)
     elif goal == 'edit-plan':
-        state.read()
-        if not rules:
-            comment = geteditcomment(node.short(state.parentctxnode),
-                                     node.short(state.topmost))
-            rules = ruleeditor(repo, ui, state.actions, comment)
-        else:
-            if rules == '-':
-                f = sys.stdin
-            else:
-                f = open(rules)
-            rules = f.read()
-            f.close()
-        actions = parserules(rules, state)
-        ctxs = [repo[act.nodetoverify()] \
-                for act in state.actions if act.nodetoverify()]
-        warnverifyactions(ui, repo, actions, state, ctxs)
-        state.actions = actions
-        state.write()
+        _editplanaction(ui, repo, state, rules)
         return
     elif goal == 'abort':
         _abortaction(ui, repo, state)
@@ -1225,6 +1208,26 @@
     finally:
             state.clear()
 
+def _editplanaction(ui, repo, state, rules):
+    state.read()
+    if not rules:
+        comment = geteditcomment(node.short(state.parentctxnode),
+                                 node.short(state.topmost))
+        rules = ruleeditor(repo, ui, state.actions, comment)
+    else:
+        if rules == '-':
+            f = sys.stdin
+        else:
+            f = open(rules)
+        rules = f.read()
+        f.close()
+    actions = parserules(rules, state)
+    ctxs = [repo[act.nodetoverify()] \
+            for act in state.actions if act.nodetoverify()]
+    warnverifyactions(ui, repo, actions, state, ctxs)
+    state.actions = actions
+    state.write()
+
 def bootstrapcontinue(ui, state, opts):
     repo = state.repo
     if state.actions: