histedit: convert message action into a class
authorDurham Goode <durham@fb.com>
Sat, 04 Apr 2015 00:42:32 -0700
changeset 24769 e875b94dc94c
parent 24768 342671704344
child 24770 facdb20e60e9
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.
hgext/histedit.py
--- a/hgext/histedit.py	Sat Apr 04 00:30:01 2015 -0700
+++ b/hgext/histedit.py	Sat Apr 04 00:42:32 2015 -0700
@@ -573,25 +573,9 @@
         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 @@
                 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)