# HG changeset patch # User Durham Goode # Date 2015-04-04 07:42:32 # Node ID e875b94dc94c81be7425e51232a32265691195a8 # Parent 3426717043443b268b9954404d5e813f1eee0560 histedit: convert message action into a class This converts the message action into a histeditclass instance, as part of an ongoing effort to refactor histedit for maintainability and robustness. diff --git a/hgext/histedit.py b/hgext/histedit.py --- a/hgext/histedit.py +++ b/hgext/histedit.py @@ -573,25 +573,9 @@ class drop(histeditaction): parentctx = self.repo[self.state.parentctxnode] return parentctx, [(self.node, tuple())] -def message(ui, state, ha, opts): - repo, ctxnode = state.repo, state.parentctxnode - ctx = repo[ctxnode] - oldctx = repo[ha] - 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')) - message = oldctx.description() - commit = commitfuncfor(repo, oldctx) - editor = cmdutil.getcommiteditor(edit=True, editform='histedit.mess') - new = commit(text=message, user=oldctx.user(), date=oldctx.date(), - extra=oldctx.extra(), editor=editor) - newctx = repo[new] - if oldctx.node() != newctx.node(): - return newctx, [(oldctx.node(), (new,))] - # We didn't make an edit, so just indicate no replaced nodes - return newctx, [] +class message(histeditaction): + def commiteditor(self): + return cmdutil.getcommiteditor(edit=True, editform='histedit.mess') def findoutgoing(ui, repo, remote=None, force=False, opts={}): """utility function to find the first outgoing changeset @@ -923,8 +907,8 @@ def bootstrapcontinue(ui, state, opts): message = 'fold-temp-revision %s' % currentnode[:12] else: message = ctx.description() - editopt = action in ('e', 'edit', 'm', 'mess') - canonaction = {'e': 'edit', 'm': 'mess'} + editopt = action in ('e', 'edit') + canonaction = {'e': 'edit'} editform = 'histedit.%s' % canonaction.get(action, action) editor = cmdutil.getcommiteditor(edit=editopt, editform=editform) commit = commitfuncfor(repo, ctx)