changeset 22982:52f10a4d13dd

histedit: pass state to action functions
author David Soria Parra <davidsp@fb.com>
date Wed, 15 Oct 2014 08:18:26 -0700
parents aa1ad9594dde
children a3a981563ce8
files hgext/histedit.py
diffstat 1 files changed, 14 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/histedit.py	Thu Oct 16 10:06:49 2014 -0700
+++ b/hgext/histedit.py	Wed Oct 15 08:18:26 2014 -0700
@@ -326,7 +326,8 @@
                          editor=editor)
     return repo.commitctx(new)
 
-def pick(ui, repo, ctx, ha, opts):
+def pick(ui, state, ha, opts):
+    repo, ctx = state.repo, state.parentctx
     oldctx = repo[ha]
     if oldctx.parents()[0] == ctx:
         ui.debug('node %s unchanged\n' % ha)
@@ -348,7 +349,8 @@
     return new, [(oldctx.node(), (n,))]
 
 
-def edit(ui, repo, ctx, ha, opts):
+def edit(ui, state, ha, opts):
+    repo, ctx = state.repo, state.parentctx
     oldctx = repo[ha]
     hg.update(repo, ctx.node())
     applychanges(ui, repo, oldctx, opts)
@@ -356,12 +358,14 @@
         _('Make changes as needed, you may commit or record as needed now.\n'
           'When you are finished, run hg histedit --continue to resume.'))
 
-def rollup(ui, repo, ctx, ha, opts):
+def rollup(ui, state, ha, opts):
+    ctx = state.parentctx
     rollupopts = opts.copy()
     rollupopts['rollup'] = True
-    return fold(ui, repo, ctx, ha, rollupopts)
+    return fold(ui, state, ha, rollupopts)
 
-def fold(ui, repo, ctx, ha, opts):
+def fold(ui, state, ha, opts):
+    repo, ctx = state.repo, state.parentctx
     oldctx = repo[ha]
     hg.update(repo, ctx.node())
     stats = applychanges(ui, repo, oldctx, opts)
@@ -417,11 +421,13 @@
         replacements.append((ich, (n,)))
     return repo[n], replacements
 
-def drop(ui, repo, ctx, ha, opts):
+def drop(ui, state, ha, opts):
+    repo, ctx = state.repo, state.parentctx
     return ctx, [(repo[ha].node(), ())]
 
 
-def message(ui, repo, ctx, ha, opts):
+def message(ui, state, ha, opts):
+    repo, ctx = state.repo, state.parentctx
     oldctx = repo[ha]
     hg.update(repo, ctx.node())
     stats = applychanges(ui, repo, oldctx, opts)
@@ -642,8 +648,7 @@
         action, ha = state.rules.pop(0)
         ui.debug('histedit: processing %s %s\n' % (action, ha))
         actfunc = actiontable[action]
-        state.parentctx, replacement_ = actfunc(ui, repo, state.parentctx,
-                ha, opts)
+        state.parentctx, replacement_ = actfunc(ui, state, ha, opts)
         state.replacements.extend(replacement_)
 
     hg.update(repo, state.parentctx.node())