Patchwork [7,of,9] histedit: pass state to action functions

login
register
mail settings
Submitter David Soria Parra
Date Oct. 16, 2014, 5:34 p.m.
Message ID <974fda127d6af8d24e81.1413480883@davidsp-mbp.dhcp.thefacebook.com>
Download mbox | patch
Permalink /patch/6340/
State Accepted
Headers show

Comments

David Soria Parra - Oct. 16, 2014, 5:34 p.m.
# HG changeset patch
# User David Soria Parra <davidsp@fb.com>
# Date 1413386306 25200
#      Wed Oct 15 08:18:26 2014 -0700
# Node ID 974fda127d6af8d24e816e1e2b647f36df28c7a8
# Parent  638453c54662a68d4243976c36712f0ac3ea272d
histedit: pass state to action functions

Patch

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