# HG changeset patch # User Kostia Balytskyi # Date 2016-02-01 14:12:38 # Node ID 5a2fb2680a39605eb8bdce3121d5b302d16583a7 # Parent 47317570ab8c1c50cc9aa1dfe530be49b51dbed2 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. diff --git a/hgext/histedit.py b/hgext/histedit.py --- a/hgext/histedit.py +++ b/hgext/histedit.py @@ -1044,24 +1044,7 @@ def _histedit(ui, repo, state, *freeargs 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 @@ def _abortaction(ui, repo, state): 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: