##// END OF EJS Templates
templater: switch ctx of list expression to rev of revset() (BC)...
Yuya Nishihara -
r26234:e4609ec9 default
parent child Browse files
Show More
@@ -106,6 +106,10 b' Some sample command line templates:'
106
106
107 $ hg log --template "{ifcontains(rev, revset('.'), '@')}\n"
107 $ hg log --template "{ifcontains(rev, revset('.'), '@')}\n"
108
108
109 - Show details of parent revisions::
110
111 $ hg log --template "{revset('parents(%d)', rev) % '{desc|firstline}\n'}"
112
109 - Show only commit descriptions that start with "template"::
113 - Show only commit descriptions that start with "template"::
110
114
111 $ hg log --template "{startswith('template', firstline(desc))}\n"
115 $ hg log --template "{startswith('template', firstline(desc))}\n"
@@ -409,6 +409,14 b' def showrev(repo, ctx, templ, **args):'
409 """:rev: Integer. The repository-local changeset revision number."""
409 """:rev: Integer. The repository-local changeset revision number."""
410 return scmutil.intrev(ctx.rev())
410 return scmutil.intrev(ctx.rev())
411
411
412 def showrevslist(name, revs, **args):
413 """helper to generate a list of revisions in which a mapped template will
414 be evaluated"""
415 repo = args['ctx'].repo()
416 f = _showlist(name, revs, **args)
417 return _hybrid(f, revs,
418 lambda x: {name: x, 'ctx': repo[x], 'revcache': {}})
419
412 def showsubrepos(**args):
420 def showsubrepos(**args):
413 """:subrepos: List of strings. Updated subrepositories in the changeset."""
421 """:subrepos: List of strings. Updated subrepositories in the changeset."""
414 ctx = args['ctx']
422 ctx = args['ctx']
@@ -568,7 +568,7 b' def revset(context, mapping, args):'
568 revs = list([str(r) for r in revs])
568 revs = list([str(r) for r in revs])
569 revsetcache[raw] = revs
569 revsetcache[raw] = revs
570
570
571 return templatekw.showlist("revision", revs, **mapping)
571 return templatekw.showrevslist("revision", revs, **mapping)
572
572
573 def rstdoc(context, mapping, args):
573 def rstdoc(context, mapping, args):
574 """:rstdoc(text, style): Format ReStructuredText."""
574 """:rstdoc(text, style): Format ReStructuredText."""
@@ -3234,6 +3234,23 b' Test revset function'
3234 $ hg log --template '{revset("TIP"|lower)}\n' -l1
3234 $ hg log --template '{revset("TIP"|lower)}\n' -l1
3235 2
3235 2
3236
3236
3237 a list template is evaluated for each item of revset
3238
3239 $ hg log -T '{rev} p: {revset("p1(%s)", rev) % "{rev}:{node|short}"}\n'
3240 2 p: 1:bcc7ff960b8e
3241 1 p: 0:f7769ec2ab97
3242 0 p:
3243
3244 therefore, 'revcache' should be recreated for each rev
3245
3246 $ hg log -T '{rev} {file_adds}\np {revset("p1(%s)", rev) % "{file_adds}"}\n'
3247 2 aa b
3248 p
3249 1
3250 p a
3251 0 a
3252 p
3253
3237 Test active bookmark templating
3254 Test active bookmark templating
3238
3255
3239 $ hg book foo
3256 $ hg book foo
General Comments 0
You need to be logged in to leave comments. Login now