# HG changeset patch # User Yuya Nishihara # Date 2017-01-06 13:50:04 # Node ID ee47e951c6f9dbe6aceeb10d2f4acbc998a27bd3 # Parent 6ef9f32d76c63eb3a61e98f95bd733bcb21571f1 commit: fix unmodified message detection for the "--- >8 ----" magic We need the raw editortext to be compared with the templatetext. diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py --- a/mercurial/cmdutil.py +++ b/mercurial/cmdutil.py @@ -2772,14 +2772,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