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

login
register
mail settings
Submitter Yuya Nishihara
Date Feb. 18, 2018, 5:17 a.m.
Message ID <44e712e75c4046df45ad.1518931079@mimosa>
Download mbox | patch
Permalink /patch/28036/
State Accepted
Headers show

Comments

Yuya Nishihara - Feb. 18, 2018, 5:17 a.m.
# HG changeset patch
# User Yuya Nishihara <yuya@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}.

Patch

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: