# HG changeset patch # User Yuya Nishihara # Date 2018-02-18 01:54:24 # Node ID 165cf86365ffa39fcfe4c83e1f6cdb690f9e179e # Parent 74c033b9d579c9f9dae0a43f46f40cd1adff0a2c 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: