Patchwork [5,of,6] backout: call cmdutil.commit directly instead of commands.commit

login
register
mail settings
Submitter Kevin Bullock
Date Feb. 13, 2013, 7:47 p.m.
Message ID <2a7b18b83de419ff4e7a.1360784867@x-128-101-230-141.uofm-secure.wireless.umn.edu>
Download mbox | patch
Permalink /patch/984/
State Accepted
Commit 12721a20ed3096ac9127fae174bf6abeae175fda
Headers show

Comments

Kevin Bullock - Feb. 13, 2013, 7:47 p.m.
# HG changeset patch
# User Kevin Bullock <kbullock@ringworld.org>
# Date 1360687004 0
# Node ID 2a7b18b83de419ff4e7a942795ef7a32c8a3e9a7
# Parent  c5b0c803433947a51e1901f627e91d685457c0cb
backout: call cmdutil.commit directly instead of commands.commit

This cleans up the messiness of having one command call another, and
makes the backout command robust against changes to the commit command.

Patch

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -456,6 +456,7 @@  def backout(ui, repo, node=None, rev=Non
     wlock = repo.wlock()
     try:
         branch = repo.dirstate.branch()
+        bheads = repo.branchheads(branch)
         hg.clean(repo, node, show_stats=False)
         repo.dirstate.setbranch(branch)
         rctx = scmutil.revsingle(repo, hex(parent))
@@ -467,11 +468,17 @@  def backout(ui, repo, node=None, rev=Non
             finally:
                 ui.setconfig('ui', 'forcemerge', '')
 
+        e = cmdutil.commiteditor
         if not opts['message'] and not opts['logfile']:
             # we don't translate commit messages
             opts['message'] = "Backed out changeset %s" % short(node)
-            opts['force_editor'] = True
-        commit(ui, repo, **opts)
+            e = cmdutil.commitforceeditor
+
+        def commitfunc(ui, repo, message, match, opts):
+            return repo.commit(message, opts.get('user'), opts.get('date'),
+                               match, editor=e)
+        newnode = cmdutil.commit(ui, repo, commitfunc, [], opts)
+        cmdutil.commitstatus(repo, newnode, branch, bheads)
 
         def nice(node):
             return '%d:%s' % (repo.changelog.rev(node), short(node))