[PATCH 4 of 5] histedit: break _histedit function into smaller pieces (add _newaction)
Kostia Balytskyi
ikostia at fb.com
Mon Feb 1 17:54:03 UTC 2016
# HG changeset patch
# User Kostia Balytskyi <ikostia at fb.com>
# Date 1454347251 0
# Mon Feb 01 17:20:51 2016 +0000
# Branch stable
# Node ID 55512493bd388e75f3d6187a9562330ddc3474e9
# Parent 4118b5fdc4a1fc9acc4a8f6580edb7ea6dd2adcf
histedit: break _histedit function into smaller pieces (add _newaction)
diff --git a/hgext/histedit.py b/hgext/histedit.py
--- a/hgext/histedit.py
+++ b/hgext/histedit.py
@@ -1072,56 +1072,7 @@
_abortaction(ui, repo, state)
return
else:
- cmdutil.checkunfinished(repo)
- cmdutil.bailifchanged(repo)
-
- topmost, empty = repo.dirstate.parents()
- if outg:
- if freeargs:
- remote = freeargs[0]
- else:
- remote = None
- root = findoutgoing(ui, repo, remote, force, opts)
- else:
- rr = list(repo.set('roots(%ld)', scmutil.revrange(repo, revs)))
- if len(rr) != 1:
- raise error.Abort(_('The specified revisions must have '
- 'exactly one common root'))
- root = rr[0].node()
-
- revs = between(repo, root, topmost, state.keep)
- if not revs:
- raise error.Abort(_('%s is not an ancestor of working directory') %
- node.short(root))
-
- ctxs = [repo[r] for r in revs]
- if not rules:
- comment = geteditcomment(node.short(root), node.short(topmost))
- actions = [pick(state, r) for r in revs]
- rules = ruleeditor(repo, ui, actions, comment)
- else:
- if rules == '-':
- f = sys.stdin
- else:
- f = open(rules)
- rules = f.read()
- f.close()
- actions = parserules(rules, state)
- warnverifyactions(ui, repo, actions, state, ctxs)
-
- parentctxnode = repo[root].parents()[0].node()
-
- state.parentctxnode = parentctxnode
- state.actions = actions
- state.topmost = topmost
- state.replacements = replacements
-
- # Create a backup so we can always abort completely.
- backupfile = None
- if not obsolete.isenabled(repo, obsolete.createmarkersopt):
- backupfile = repair._bundle(repo, [parentctxnode], [topmost], root,
- 'histedit')
- state.backupfile = backupfile
+ _newaction(ui, repo, state, revs, freeargs, opts)
# preprocess rules so that we can hide inner folds from the user
# and only show one editor
@@ -1248,6 +1199,62 @@
state.actions = actions
state.write()
+def _newaction(ui, repo, state, revs, freeargs, opts):
+ outg = opts.get('outgoing')
+ rules = opts.get('commands', '')
+ force = opts.get('force')
+
+ cmdutil.checkunfinished(repo)
+ cmdutil.bailifchanged(repo)
+
+ topmost, empty = repo.dirstate.parents()
+ if outg:
+ if freeargs:
+ remote = freeargs[0]
+ else:
+ remote = None
+ root = findoutgoing(ui, repo, remote, force, opts)
+ else:
+ rr = list(repo.set('roots(%ld)', scmutil.revrange(repo, revs)))
+ if len(rr) != 1:
+ raise error.Abort(_('The specified revisions must have '
+ 'exactly one common root'))
+ root = rr[0].node()
+
+ revs = between(repo, root, topmost, state.keep)
+ if not revs:
+ raise error.Abort(_('%s is not an ancestor of working directory') %
+ node.short(root))
+
+ ctxs = [repo[r] for r in revs]
+ if not rules:
+ comment = geteditcomment(node.short(root), node.short(topmost))
+ actions = [pick(state, r) for r in revs]
+ rules = ruleeditor(repo, ui, actions, comment)
+ else:
+ if rules == '-':
+ f = sys.stdin
+ else:
+ f = open(rules)
+ rules = f.read()
+ f.close()
+ actions = parserules(rules, state)
+ warnverifyactions(ui, repo, actions, state, ctxs)
+
+ parentctxnode = repo[root].parents()[0].node()
+
+ state.parentctxnode = parentctxnode
+ state.actions = actions
+ state.topmost = topmost
+ state.replacements = []
+
+ # Create a backup so we can always abort completely.
+ backupfile = None
+ if not obsolete.isenabled(repo, obsolete.createmarkersopt):
+ backupfile = repair._bundle(repo, [parentctxnode], [topmost], root,
+ 'histedit')
+ state.backupfile = backupfile
+
def bootstrapcontinue(ui, state, opts):
repo = state.repo
if state.actions:
More information about the Mercurial-devel
mailing list