Show More
@@ -36,6 +36,7 b' from .utils import (' | |||||
36 | ) |
|
36 | ) | |
37 |
|
37 | |||
38 | evalrawexp = templateutil.evalrawexp |
|
38 | evalrawexp = templateutil.evalrawexp | |
|
39 | evalwrapped = templateutil.evalwrapped | |||
39 | evalfuncarg = templateutil.evalfuncarg |
|
40 | evalfuncarg = templateutil.evalfuncarg | |
40 | evalboolean = templateutil.evalboolean |
|
41 | evalboolean = templateutil.evalboolean | |
41 | evaldate = templateutil.evaldate |
|
42 | evaldate = templateutil.evaldate | |
@@ -327,17 +328,11 b' def join(context, mapping, args):' | |||||
327 | # i18n: "join" is a keyword |
|
328 | # i18n: "join" is a keyword | |
328 | raise error.ParseError(_("join expects one or two arguments")) |
|
329 | raise error.ParseError(_("join expects one or two arguments")) | |
329 |
|
330 | |||
330 |
joinset = eval |
|
331 | joinset = evalwrapped(context, mapping, args[0]) | |
331 | joiner = " " |
|
332 | joiner = " " | |
332 | if len(args) > 1: |
|
333 | if len(args) > 1: | |
333 | joiner = evalstring(context, mapping, args[1]) |
|
334 | joiner = evalstring(context, mapping, args[1]) | |
334 | if isinstance(joinset, templateutil.wrapped): |
|
335 | return joinset.join(context, mapping, joiner) | |
335 | return joinset.join(context, mapping, joiner) |
|
|||
336 | # TODO: rethink about join() of a byte string, which had no defined |
|
|||
337 | # behavior since a string may be either a bytes or a generator. |
|
|||
338 | # TODO: fix type error on join() of non-iterable |
|
|||
339 | joinset = templateutil.unwrapvalue(context, mapping, joinset) |
|
|||
340 | return templateutil.joinitems(pycompat.maybebytestr(joinset), joiner) |
|
|||
341 |
|
336 | |||
342 | @templatefunc('label(label, expr)') |
|
337 | @templatefunc('label(label, expr)') | |
343 | def label(context, mapping, args): |
|
338 | def label(context, mapping, args): |
@@ -3249,6 +3249,17 b' Test manifest/get() can be join()-ed as ' | |||||
3249 | $ hg log -R latesttag -r tip -T '{join(get(extras, "branch"), "")}\n' |
|
3249 | $ hg log -R latesttag -r tip -T '{join(get(extras, "branch"), "")}\n' | |
3250 | default |
|
3250 | default | |
3251 |
|
3251 | |||
|
3252 | Test join() over string | |||
|
3253 | ||||
|
3254 | $ hg log -R latesttag -r tip -T '{join(rev|stringify, ".")}\n' | |||
|
3255 | 1.1 | |||
|
3256 | ||||
|
3257 | Test join() over uniterable | |||
|
3258 | ||||
|
3259 | $ hg log -R latesttag -r tip -T '{join(rev, "")}\n' | |||
|
3260 | hg: parse error: 11 is not iterable | |||
|
3261 | [255] | |||
|
3262 | ||||
3252 | Test min/max of integers |
|
3263 | Test min/max of integers | |
3253 |
|
3264 | |||
3254 | $ hg log -R latesttag -l1 -T '{min(revset("9:10"))}\n' |
|
3265 | $ hg log -R latesttag -l1 -T '{min(revset("9:10"))}\n' |
General Comments 0
You need to be logged in to leave comments.
Login now