mercurial/cmdutil.py
changeset 21869 e353fac7db26
parent 21832 4b93e19cd6e6
child 21872 abae1eb695c0
--- a/mercurial/cmdutil.py	Sat Jul 12 10:52:58 2014 -0700
+++ b/mercurial/cmdutil.py	Tue Jul 15 00:59:09 2014 +0900
@@ -2170,6 +2170,23 @@
     return commitforceeditor(repo, ctx, subs)
 
 def commitforceeditor(repo, ctx, subs, finishdesc=None, extramsg=None):
+    committext = buildcommittext(repo, ctx, subs, extramsg)
+
+    # run editor in the repository root
+    olddir = os.getcwd()
+    os.chdir(repo.root)
+    text = repo.ui.edit(committext, ctx.user(), ctx.extra())
+    text = re.sub("(?m)^HG:.*(\n|$)", "", text)
+    os.chdir(olddir)
+
+    if finishdesc:
+        text = finishdesc(text)
+    if not text.strip():
+        raise util.Abort(_("empty commit message"))
+
+    return text
+
+def buildcommittext(repo, ctx, subs, extramsg):
     edittext = []
     modified, added, removed = ctx.modified(), ctx.added(), ctx.removed()
     if ctx.description():
@@ -2197,19 +2214,8 @@
     if not added and not modified and not removed:
         edittext.append(_("HG: no files changed"))
     edittext.append("")
-    # run editor in the repository root
-    olddir = os.getcwd()
-    os.chdir(repo.root)
-    text = repo.ui.edit("\n".join(edittext), ctx.user(), ctx.extra())
-    text = re.sub("(?m)^HG:.*(\n|$)", "", text)
-    os.chdir(olddir)
 
-    if finishdesc:
-        text = finishdesc(text)
-    if not text.strip():
-        raise util.Abort(_("empty commit message"))
-
-    return text
+    return "\n".join(edittext)
 
 def commitstatus(repo, node, branch, bheads=None, opts={}):
     ctx = repo[node]