changeset 36207:cc46e68f050f

cmdutil: build "%m" (desc|firstline) in makefilename()
author Yuya Nishihara <yuya@tcha.org>
date Sat, 06 Jan 2018 17:44:57 +0900
parents 9ddc884e9a32
children c407ccd06abd
files mercurial/cmdutil.py
diffstat 1 files changed, 6 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/cmdutil.py	Thu Apr 02 23:37:07 2015 +0900
+++ b/mercurial/cmdutil.py	Sat Jan 06 17:44:57 2018 +0900
@@ -891,13 +891,14 @@
     else:
         return commiteditor
 
-def makefilename(ctx, pat, desc=None,
+def makefilename(ctx, pat,
                   total=None, seqno=None, revwidth=None, pathname=None):
     expander = {
         'H': lambda: ctx.hex(),
         'R': lambda: '%d' % ctx.rev(),
         'h': lambda: short(ctx.node()),
-        'm': lambda: re.sub('[^\w]', '_', desc or ''),
+        'm': lambda: re.sub('[^\w]', '_',
+                            ctx.description().rstrip().splitlines()[0]),
         'r': lambda: ('%d' % ctx.rev()).zfill(revwidth or 0),
         '%': lambda: '%',
         'b': lambda: os.path.basename(ctx.repo().root),
@@ -954,7 +955,7 @@
     def __exit__(self, exc_type, exc_value, exc_tb):
         pass
 
-def makefileobj(ctx, pat, desc=None, total=None,
+def makefileobj(ctx, pat, total=None,
                 seqno=None, revwidth=None, mode='wb', modemap=None,
                 pathname=None):
 
@@ -967,7 +968,7 @@
         else:
             fp = repo.ui.fin
         return _unclosablefile(fp)
-    fn = makefilename(ctx, pat, desc, total, seqno, revwidth, pathname)
+    fn = makefilename(ctx, pat, total, seqno, revwidth, pathname)
     if modemap is not None:
         mode = modemap.get(fn, mode)
         if mode == 'wb':
@@ -1542,9 +1543,7 @@
         ctx = repo[rev]
         fo = None
         if not fp and fntemplate:
-            desc_lines = ctx.description().rstrip().split('\n')
-            desc = desc_lines[0]    #Commit always has a first line.
-            fo = makefileobj(ctx, fntemplate, desc=desc,
+            fo = makefileobj(ctx, fntemplate,
                              total=total, seqno=seqno, revwidth=revwidth,
                              mode='wb', modemap=filemode)
             dest = fo.name