Mercurial > hg-stable
diff mercurial/cmdutil.py @ 14986:70e11de6964d
export: add %m to file format string (first line of the commit message)
$ hg commit -m "Initial commit"
$ hg export -o %m.patch tip #It creates Initial_commit.patch file.
author | Andrzej Bieniek <andyhelp@gmail.com> |
---|---|
date | Sat, 30 Jul 2011 11:08:45 +0100 |
parents | 32302480b402 |
children | 231aac5280ba |
line wrap: on
line diff
--- a/mercurial/cmdutil.py Fri Jul 29 00:39:27 2011 +0200 +++ b/mercurial/cmdutil.py Sat Jul 30 11:08:45 2011 +0100 @@ -109,12 +109,13 @@ limit = None return limit -def makefilename(repo, pat, node, +def makefilename(repo, pat, node, desc=None, total=None, seqno=None, revwidth=None, pathname=None): node_expander = { 'H': lambda: hex(node), 'R': lambda: str(repo.changelog.rev(node)), 'h': lambda: short(node), + 'm': lambda: re.sub('[^\w]', '_', str(desc)) } expander = { '%': lambda: '%', @@ -154,7 +155,7 @@ raise util.Abort(_("invalid format spec '%%%s' in output filename") % inst.args[0]) -def makefileobj(repo, pat, node=None, total=None, +def makefileobj(repo, pat, node=None, desc=None, total=None, seqno=None, revwidth=None, mode='wb', pathname=None): writable = mode not in ('r', 'rb') @@ -181,7 +182,7 @@ return pat if util.safehasattr(pat, 'read') and 'r' in mode: return pat - return open(makefilename(repo, pat, node, total, seqno, revwidth, + return open(makefilename(repo, pat, node, desc, total, seqno, revwidth, pathname), mode) @@ -516,8 +517,10 @@ shouldclose = False if not fp: - fp = makefileobj(repo, template, node, total=total, seqno=seqno, - revwidth=revwidth, mode='ab') + desc_lines = ctx.description().rstrip().split('\n') + desc = desc_lines[0] #Commit always has a first line. + fp = makefileobj(repo, template, node, desc=desc, total=total, + seqno=seqno, revwidth=revwidth, mode='ab') if fp != template: shouldclose = True if fp != sys.stdout and util.safehasattr(fp, 'name'):