Patchwork [8,of,9] amend: use "editor" argument for "memctx.__init__" to save commit message

login
register
mail settings
Submitter Katsunori FUJIWARA
Date May 5, 2014, 12:33 p.m.
Message ID <24416f80f94093cfb1f9.1399293188@feefifofum>
Download mbox | patch
Permalink /patch/4638/
State Accepted
Commit 1a833fcf5a14e56a5149511f65f16bd93f9e5714
Headers show

Comments

Katsunori FUJIWARA - May 5, 2014, 12:33 p.m.
# HG changeset patch
# User FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
# Date 1399292800 -32400
#      Mon May 05 21:26:40 2014 +0900
# Branch stable
# Node ID 24416f80f94093cfb1f9699dfa09d794b194db53
# Parent  66ca0c1187fd5bb4b959d38aef3b21892ebd0b15
amend: use "editor" argument for "memctx.__init__" to save commit message

This patch uses "editor" argument of "memctx.__init__" to save commit
message, instead of explicit editor invocation and saving commit
message by "localrepository.savecommitmessage()".

By passing one of "commiteditor" or "commitforceeditor" as "editor",
"memctx.__init__" saves commit message, even when editor invocation is
not needed.

Patch

diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -2045,12 +2045,12 @@ 
 
                 user = opts.get('user') or old.user()
                 date = opts.get('date') or old.date()
-            editmsg = False
+            editor = commiteditor
             if not message:
-                editmsg = True
+                editor = commitforceeditor
                 message = old.description()
             elif opts.get('edit'):
-                editmsg = True
+                editor = commitforceeditor
 
             pureextra = extra.copy()
             extra['amend_source'] = old.hex()
@@ -2062,10 +2062,8 @@ 
                                  filectxfn=filectxfn,
                                  user=user,
                                  date=date,
-                                 extra=extra)
-            if editmsg:
-                new._text = commitforceeditor(repo, new, [])
-            repo.savecommitmessage(new.description())
+                                 extra=extra,
+                                 editor=editor)
 
             newdesc =  changelog.stripdesc(new.description())
             if ((not node)