[PATCH 1 of 4 V2] cmdutil: strip "%m" pattern (first line of commit message) from both ends

Yuya Nishihara yuya at tcha.org
Sun Feb 18 05:17:59 UTC 2018


# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1518918864 -32400
#      Sun Feb 18 10:54:24 2018 +0900
# Node ID 44e712e75c4046df45ad5c8f6731aaa0633a6a1b
# Parent  2b00dda6dad9f775ccb0e1a537c603843bb6511c
cmdutil: strip "%m" pattern (first line of commit message) from both ends

This matches the behavior of the template keyword {desc}.

diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -898,7 +898,7 @@ def makefilename(ctx, pat,
         'R': lambda: '%d' % ctx.rev(),
         'h': lambda: short(ctx.node()),
         'm': lambda: re.sub('[^\w]', '_',
-                            ctx.description().rstrip().splitlines()[0]),
+                            ctx.description().strip().splitlines()[0]),
         'r': lambda: ('%d' % ctx.rev()).zfill(revwidth or 0),
         '%': lambda: '%',
         'b': lambda: os.path.basename(ctx.repo().root),
diff --git a/tests/test-export.t b/tests/test-export.t
--- a/tests/test-export.t
+++ b/tests/test-export.t
@@ -184,7 +184,7 @@ Checking if only alphanumeric characters
   $ hg commit -m " !\"#$%&(,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]"'^'"_\`abcdefghijklmnopqrstuvwxyz{|}~"
   $ hg export -v -o %m.patch tip
   exporting patch:
-  ____________0123456789_______ABCDEFGHIJKLMNOPQRSTUVWXYZ______abcdefghijklmnopqrstuvwxyz____.patch
+  ___________0123456789_______ABCDEFGHIJKLMNOPQRSTUVWXYZ______abcdefghijklmnopqrstuvwxyz____.patch
 
 Invalid pattern in file name:
 


More information about the Mercurial-devel mailing list