Mercurial > hg
comparison tests/test-export.t @ 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 | 165cf86365ff |
children | 80d7fb6c2dec |
comparison
equal
deleted
inserted
replaced
36509:638c012a87ef | 36511:aa3294027936 |
---|---|
184 $ hg commit -m " !\"#$%&(,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]"'^'"_\`abcdefghijklmnopqrstuvwxyz{|}~" | 184 $ hg commit -m " !\"#$%&(,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]"'^'"_\`abcdefghijklmnopqrstuvwxyz{|}~" |
185 $ hg export -v -o %m.patch tip | 185 $ hg export -v -o %m.patch tip |
186 exporting patch: | 186 exporting patch: |
187 ___________0123456789_______ABCDEFGHIJKLMNOPQRSTUVWXYZ______abcdefghijklmnopqrstuvwxyz____.patch | 187 ___________0123456789_______ABCDEFGHIJKLMNOPQRSTUVWXYZ______abcdefghijklmnopqrstuvwxyz____.patch |
188 | 188 |
189 Template fragments in file name: | |
190 | |
191 $ hg export -v -o '{node|shortest}.patch' tip | |
192 exporting patch: | |
193 197e.patch | |
194 | |
195 Backslash should be preserved because it is a directory separator on Windows: | |
196 | |
197 $ mkdir out | |
198 $ hg export -v -o 'out\{node|shortest}.patch' tip | |
199 exporting patch: | |
200 out\197e.patch | |
201 | |
202 Still backslash is taken as an escape character in inner template strings: | |
203 | |
204 $ hg export -v -o '{"out\{foo}.patch"}' tip | |
205 exporting patch: | |
206 out{foo}.patch | |
207 | |
189 Invalid pattern in file name: | 208 Invalid pattern in file name: |
190 | 209 |
191 $ hg export -o '%x.patch' tip | 210 $ hg export -o '%x.patch' tip |
192 abort: invalid format spec '%x' in output filename | 211 abort: invalid format spec '%x' in output filename |
212 [255] | |
213 $ hg export -o '%' tip | |
214 abort: incomplete format spec in output filename | |
215 [255] | |
216 $ hg export -o '%{"foo"}' tip | |
217 abort: incomplete format spec in output filename | |
218 [255] | |
219 $ hg export -o '%m{' tip | |
220 hg: parse error at 3: unterminated template expansion | |
221 [255] | |
222 $ hg export -o '%\' tip | |
223 abort: invalid format spec '%\' in output filename | |
224 [255] | |
225 $ hg export -o '\%' tip | |
226 abort: incomplete format spec in output filename | |
193 [255] | 227 [255] |
194 | 228 |
195 Catch exporting unknown revisions (especially empty revsets, see issue3353) | 229 Catch exporting unknown revisions (especially empty revsets, see issue3353) |
196 | 230 |
197 $ hg export | 231 $ hg export |