# HG changeset patch # User David Soria Parra # Date 1413386306 25200 # Node ID 52f10a4d13dd502a073f1bcf6e05676905927b6e # Parent aa1ad9594dde49cbdae99a566831bb126598d1df histedit: pass state to action functions diff -r aa1ad9594dde -r 52f10a4d13dd hgext/histedit.py --- 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())