Patchwork [2,of,2] commit: fix unmodified message detection for the "--- >8 ----" magic

login
register
mail settings
Submitter Yuya Nishihara
Date Jan. 6, 2017, 2:30 p.m.
Message ID <d19726fc559971501161.1483713025@mimosa>
Download mbox | patch
Permalink /patch/18113/
State Accepted
Headers show

Comments

Yuya Nishihara - Jan. 6, 2017, 2:30 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1483710604 -32400
#      Fri Jan 06 22:50:04 2017 +0900
# Node ID d19726fc559971501161eba3552f96a93a3a5c25
# Parent  b5247f031aed69bb2f7c6a3a8d1c9b076a7384d5
commit: fix unmodified message detection for the "--- >8 ----" magic

We need the raw editortext to be compared with the templatetext.
Sean Farley - Jan. 6, 2017, 6:30 p.m.
Yuya Nishihara <yuya@tcha.org> writes:

> # HG changeset patch
> # User Yuya Nishihara <yuya@tcha.org>
> # Date 1483710604 -32400
> #      Fri Jan 06 22:50:04 2017 +0900
> # Node ID d19726fc559971501161eba3552f96a93a3a5c25
> # Parent  b5247f031aed69bb2f7c6a3a8d1c9b076a7384d5
> commit: fix unmodified message detection for the "--- >8 ----" magic
>
> We need the raw editortext to be compared with the templatetext.

Ah, really good catch. Thanks, Yuya!
Augie Fackler - Jan. 7, 2017, 5:57 p.m.
On Fri, Jan 06, 2017 at 10:30:47AM -0800, Sean Farley wrote:
> Yuya Nishihara <yuya@tcha.org> writes:
>
> > # HG changeset patch
> > # User Yuya Nishihara <yuya@tcha.org>
> > # Date 1483710604 -32400
> > #      Fri Jan 06 22:50:04 2017 +0900
> > # Node ID d19726fc559971501161eba3552f96a93a3a5c25
> > # Parent  b5247f031aed69bb2f7c6a3a8d1c9b076a7384d5
> > commit: fix unmodified message detection for the "--- >8 ----" magic
> >
> > We need the raw editortext to be compared with the templatetext.
>
> Ah, really good catch. Thanks, Yuya!
>
Queued, thanks.

> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Patch

diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -2771,14 +2771,15 @@  def commitforceeditor(repo, ctx, subs, f
 
     editortext = repo.ui.edit(committext, ctx.user(), ctx.extra(),
                         editform=editform, pending=pending)
+    text = editortext
 
     # strip away anything below this special string (used for editors that want
     # to display the diff)
-    stripbelow = re.search(_linebelow, editortext, flags=re.MULTILINE)
+    stripbelow = re.search(_linebelow, text, flags=re.MULTILINE)
     if stripbelow:
-        editortext = editortext[:stripbelow.start()]
-
-    text = re.sub("(?m)^HG:.*(\n|$)", "", editortext)
+        text = text[:stripbelow.start()]
+
+    text = re.sub("(?m)^HG:.*(\n|$)", "", text)
     os.chdir(olddir)
 
     if finishdesc:
diff --git a/tests/test-commit.t b/tests/test-commit.t
--- a/tests/test-commit.t
+++ b/tests/test-commit.t
@@ -712,6 +712,9 @@  test that text below the --- >8 --- spec
   > EOF
   $ echo foo2 > foo2
   $ hg add foo2
+  $ HGEDITOR="sh $TESTTMP/notouching.sh" hg ci
+  abort: commit message unchanged
+  [255]
   $ HGEDITOR="sh $TESTTMP/lowercaseline.sh" hg ci
   first line
   HG: this is customized commit template