# HG changeset patch # User Durham Goode # Date 2015-04-04 18:39:08 # Node ID 477e76936b1d3ed58f8a56ed402533aa50a35b13 # Parent cfb8f5e3ca497298d0ef62565955dcdb968c2d51 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. diff --git a/hgext/histedit.py b/hgext/histedit.py --- a/hgext/histedit.py +++ b/hgext/histedit.py @@ -487,28 +487,14 @@ def collapse(repo, first, last, commitop 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 @@ def bootstrapcontinue(ui, state, opts): 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) diff --git a/tests/test-histedit-fold-non-commute.t b/tests/test-histedit-fold-non-commute.t --- a/tests/test-histedit-fold-non-commute.t +++ b/tests/test-histedit-fold-non-commute.t @@ -132,6 +132,7 @@ just continue this time $ hg resolve --mark e (no more unresolved files) $ hg histedit --continue 2>&1 | fixbundle + 7b4e2f4b7bcd: empty changeset 0 files updated, 0 files merged, 0 files removed, 0 files unresolved 0 files updated, 0 files merged, 0 files removed, 0 files unresolved @@ -274,6 +275,7 @@ just continue this time $ hg resolve --mark e (no more unresolved files) $ hg histedit --continue 2>&1 | fixbundle + 7b4e2f4b7bcd: empty changeset 0 files updated, 0 files merged, 0 files removed, 0 files unresolved 0 files updated, 0 files merged, 0 files removed, 0 files unresolved diff --git a/tests/test-histedit-non-commute.t b/tests/test-histedit-non-commute.t --- a/tests/test-histedit-non-commute.t +++ b/tests/test-histedit-non-commute.t @@ -170,6 +170,7 @@ just continue this time $ hg resolve --mark e (no more unresolved files) $ hg histedit --continue 2>&1 | fixbundle + 7b4e2f4b7bcd: empty changeset 0 files updated, 0 files merged, 0 files removed, 0 files unresolved 0 files updated, 0 files merged, 0 files removed, 0 files unresolved @@ -253,6 +254,7 @@ second edit also fails, but just continu $ hg resolve --mark e (no more unresolved files) $ hg histedit --continue 2>&1 | fixbundle + 7b4e2f4b7bcd: empty changeset 0 files updated, 0 files merged, 0 files removed, 0 files unresolved 0 files updated, 0 files merged, 0 files removed, 0 files unresolved