Mercurial > public > mercurial-scm > hg
diff hgext/histedit.py @ 24767:477e76936b1d
histedit: convert pick action into a class
This converts the pick action into a histeditclass instance, as part of an
ongoing effort to refactor histedit for maintainability and robustness.
The test output changed because previously pick would only report the commit
disappearing if there were no merge conflicts. Now that we've unified the normal
and the --continue flows, they act the same and we get the warning even after
--continue.
author | Durham Goode <durham@fb.com> |
---|---|
date | Sat, 04 Apr 2015 11:39:08 -0700 |
parents | cfb8f5e3ca49 |
children | 342671704344 |
line wrap: on
line diff
--- a/hgext/histedit.py Sat Apr 04 11:37:08 2015 -0700 +++ b/hgext/histedit.py Sat Apr 04 11:39:08 2015 -0700 @@ -487,28 +487,14 @@ editor=editor) return repo.commitctx(new) -def pick(ui, state, ha, opts): - repo, ctxnode = state.repo, state.parentctxnode - ctx = repo[ctxnode] - oldctx = repo[ha] - if oldctx.parents()[0] == ctx: - ui.debug('node %s unchanged\n' % ha[:12]) - return oldctx, [] - hg.update(repo, ctx.node()) - stats = applychanges(ui, repo, oldctx, opts) - if stats and stats[3] > 0: - raise error.InterventionRequired(_('Fix up the change and run ' - 'hg histedit --continue')) - # drop the second merge parent - commit = commitfuncfor(repo, oldctx) - n = commit(text=oldctx.description(), user=oldctx.user(), - date=oldctx.date(), extra=oldctx.extra()) - if n is None: - ui.warn(_('%s: empty changeset\n') % ha[:12]) - return ctx, [] - new = repo[n] - return new, [(oldctx.node(), (n,))] +class pick(histeditaction): + def run(self): + rulectx = self.repo[self.node] + if rulectx.parents()[0].node() == self.state.parentctxnode: + self.repo.ui.debug('node %s unchanged\n' % node.short(self.node)) + return rulectx, [] + return super(pick, self).run() def edit(ui, state, ha, opts): repo, ctxnode = state.repo, state.parentctxnode @@ -939,7 +925,7 @@ else: message = ctx.description() editopt = action in ('e', 'edit', 'm', 'mess') - canonaction = {'e': 'edit', 'm': 'mess', 'p': 'pick'} + canonaction = {'e': 'edit', 'm': 'mess'} editform = 'histedit.%s' % canonaction.get(action, action) editor = cmdutil.getcommiteditor(edit=editopt, editform=editform) commit = commitfuncfor(repo, ctx)