Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/commands.py @ 36540: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 |
comparison
equal
deleted
inserted
replaced
36539:638c012a87ef | 36540:aa3294027936 |
---|---|
1283 | 1283 |
1284 Print the specified files as they were at the given revision. If | 1284 Print the specified files as they were at the given revision. If |
1285 no revision is given, the parent of the working directory is used. | 1285 no revision is given, the parent of the working directory is used. |
1286 | 1286 |
1287 Output may be to a file, in which case the name of the file is | 1287 Output may be to a file, in which case the name of the file is |
1288 given using a format string. The formatting rules as follows: | 1288 given using a template string. See :hg:`help templates`. In addition |
1289 to the common template keywords, the following formatting rules are | |
1290 supported: | |
1289 | 1291 |
1290 :``%%``: literal "%" character | 1292 :``%%``: literal "%" character |
1291 :``%s``: basename of file being printed | 1293 :``%s``: basename of file being printed |
1292 :``%d``: dirname of file being printed, or '.' if in repository root | 1294 :``%d``: dirname of file being printed, or '.' if in repository root |
1293 :``%p``: root-relative path name of file being printed | 1295 :``%p``: root-relative path name of file being printed |
1294 :``%H``: changeset hash (40 hexadecimal digits) | 1296 :``%H``: changeset hash (40 hexadecimal digits) |
1295 :``%R``: changeset revision number | 1297 :``%R``: changeset revision number |
1296 :``%h``: short-form changeset hash (12 hexadecimal digits) | 1298 :``%h``: short-form changeset hash (12 hexadecimal digits) |
1297 :``%r``: zero-padded changeset revision number | 1299 :``%r``: zero-padded changeset revision number |
1298 :``%b``: basename of the exporting repository | 1300 :``%b``: basename of the exporting repository |
1301 :``\\``: literal "\\" character | |
1299 | 1302 |
1300 Returns 0 on success. | 1303 Returns 0 on success. |
1301 """ | 1304 """ |
1302 opts = pycompat.byteskwargs(opts) | 1305 opts = pycompat.byteskwargs(opts) |
1303 rev = opts.get('rev') | 1306 rev = opts.get('rev') |
1899 :hg:`export` may generate unexpected diff output for merge | 1902 :hg:`export` may generate unexpected diff output for merge |
1900 changesets, as it will compare the merge changeset against its | 1903 changesets, as it will compare the merge changeset against its |
1901 first parent only. | 1904 first parent only. |
1902 | 1905 |
1903 Output may be to a file, in which case the name of the file is | 1906 Output may be to a file, in which case the name of the file is |
1904 given using a format string. The formatting rules are as follows: | 1907 given using a template string. See :hg:`help templates`. In addition |
1908 to the common template keywords, the following formatting rules are | |
1909 supported: | |
1905 | 1910 |
1906 :``%%``: literal "%" character | 1911 :``%%``: literal "%" character |
1907 :``%H``: changeset hash (40 hexadecimal digits) | 1912 :``%H``: changeset hash (40 hexadecimal digits) |
1908 :``%N``: number of patches being generated | 1913 :``%N``: number of patches being generated |
1909 :``%R``: changeset revision number | 1914 :``%R``: changeset revision number |
1910 :``%b``: basename of the exporting repository | 1915 :``%b``: basename of the exporting repository |
1911 :``%h``: short-form changeset hash (12 hexadecimal digits) | 1916 :``%h``: short-form changeset hash (12 hexadecimal digits) |
1912 :``%m``: first line of the commit message (only alphanumeric characters) | 1917 :``%m``: first line of the commit message (only alphanumeric characters) |
1913 :``%n``: zero-padded sequence number, starting at 1 | 1918 :``%n``: zero-padded sequence number, starting at 1 |
1914 :``%r``: zero-padded changeset revision number | 1919 :``%r``: zero-padded changeset revision number |
1920 :``\\``: literal "\\" character | |
1915 | 1921 |
1916 Without the -a/--text option, export will avoid generating diffs | 1922 Without the -a/--text option, export will avoid generating diffs |
1917 of files it detects as binary. With -a, export will generate a | 1923 of files it detects as binary. With -a, export will generate a |
1918 diff anyway, probably with undesirable results. | 1924 diff anyway, probably with undesirable results. |
1919 | 1925 |