Patchwork [2,of,6] histedit: convert edit action into a class

login
register
mail settings
Submitter Durham Goode
Date April 15, 2015, 10:55 p.m.
Message ID <5724dc0f9a89155c71d7.1429138552@dev2000.prn2.facebook.com>
Download mbox | patch
Permalink /patch/8697/
State Accepted
Headers show

Comments

Durham Goode - April 15, 2015, 10:55 p.m.
# HG changeset patch
# User Durham Goode <durham@fb.com>
# Date 1428134451 25200
#      Sat Apr 04 01:00:51 2015 -0700
# Node ID 5724dc0f9a89155c71d71b54a8341789f5ced390
# Parent  795264e586902a1a0b7cf41246d8ee749725f03d
histedit: convert edit action into a class

This converts the edit action into a histeditclass instance, as part of an
ongoing effort to refactor histedit for maintainability and robustness.

Patch

diff --git a/hgext/histedit.py b/hgext/histedit.py
--- a/hgext/histedit.py
+++ b/hgext/histedit.py
@@ -429,15 +429,19 @@  class pick(histeditaction):
 
         return super(pick, self).run()
 
-def edit(ui, state, ha, opts):
-    repo, ctxnode = state.repo, state.parentctxnode
-    ctx = repo[ctxnode]
-    oldctx = repo[ha]
-    hg.update(repo, ctx.node())
-    applychanges(ui, repo, oldctx, opts)
-    raise error.InterventionRequired(
-        _('Make changes as needed, you may commit or record as needed now.\n'
-          'When you are finished, run hg histedit --continue to resume.'))
+class edit(histeditaction):
+    def run(self):
+        repo = self.repo
+        rulectx = repo[self.node]
+        hg.update(repo, self.state.parentctxnode)
+        applychanges(repo.ui, repo, rulectx, {})
+        raise error.InterventionRequired(
+            _('Make changes as needed, you may commit or record as needed '
+              'now.\nWhen you are finished, run hg histedit --continue to '
+              'resume.'))
+
+    def commiteditor(self):
+        return cmdutil.getcommiteditor(edit=True, editform='histedit.edit')
 
 def rollup(ui, state, ha, opts):
     rollupopts = opts.copy()
@@ -823,10 +827,7 @@  def bootstrapcontinue(ui, state, opts):
                 message = 'fold-temp-revision %s' % currentnode[:12]
             else:
                 message = ctx.description()
-            editopt = action in ('e', 'edit')
-            canonaction = {'e': 'edit'}
-            editform = 'histedit.%s' % canonaction.get(action, action)
-            editor = cmdutil.getcommiteditor(edit=editopt, editform=editform)
+            editor = cmdutil.getcommiteditor()
             commit = commitfuncfor(repo, ctx)
             new = commit(text=message, user=ctx.user(), date=ctx.date(),
                          extra=ctx.extra(), editor=editor)