[PATCH 1 of 6] histedit: convert message action into a class

Durham Goode durham at fb.com
Wed Apr 15 22:55:51 UTC 2015


# HG changeset patch
# User Durham Goode <durham at fb.com>
# Date 1428133352 25200
#      Sat Apr 04 00:42:32 2015 -0700
# Node ID 795264e586902a1a0b7cf41246d8ee749725f03d
# Parent  329572a4f5f2ec55d592a6db3ea1ac2606bfdc91
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
@@ -506,25 +506,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
@@ -839,8 +823,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)


More information about the Mercurial-devel mailing list