Mercurial > public > mercurial-scm > hg
diff mercurial/commands.py @ 36511:aa3294027936
cmdutil: expand filename format string by templater (BC)
This is BC because '{}' could be a valid filename before, but I believe good
programmers wouldn't use such catastrophic output filenames. On the other
hand, '\' has to be escaped since it is a directory separator on Windows.
Thanks to Matt Harbison for spotting this weird issue.
This patch also adds cmdutil.rendertemplate(ctx, tmpl, props) as a simpler
way of expanding template against single changeset.
.. bc::
'{' in output filename passed to archive/cat/export is taken as a start
of a template expression.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sun, 07 Jan 2018 11:53:07 +0900 |
parents | 6e90c59b6da1 |
children | 4de15c54e59f |
line wrap: on
line diff
--- a/mercurial/commands.py Sun Feb 18 11:53:26 2018 +0900 +++ b/mercurial/commands.py Sun Jan 07 11:53:07 2018 +0900 @@ -1285,7 +1285,9 @@ no revision is given, the parent of the working directory is used. Output may be to a file, in which case the name of the file is - given using a format string. The formatting rules as follows: + given using a template string. See :hg:`help templates`. In addition + to the common template keywords, the following formatting rules are + supported: :``%%``: literal "%" character :``%s``: basename of file being printed @@ -1296,6 +1298,7 @@ :``%h``: short-form changeset hash (12 hexadecimal digits) :``%r``: zero-padded changeset revision number :``%b``: basename of the exporting repository + :``\\``: literal "\\" character Returns 0 on success. """ @@ -1901,7 +1904,9 @@ first parent only. Output may be to a file, in which case the name of the file is - given using a format string. The formatting rules are as follows: + given using a template string. See :hg:`help templates`. In addition + to the common template keywords, the following formatting rules are + supported: :``%%``: literal "%" character :``%H``: changeset hash (40 hexadecimal digits) @@ -1912,6 +1917,7 @@ :``%m``: first line of the commit message (only alphanumeric characters) :``%n``: zero-padded sequence number, starting at 1 :``%r``: zero-padded changeset revision number + :``\\``: literal "\\" character Without the -a/--text option, export will avoid generating diffs of files it detects as binary. With -a, export will generate a