##// END OF EJS Templates
templatekw: add {namespaces} keyword...
Yuya Nishihara -
r27894:a94f7eef default
parent child Browse files
Show More
@@ -421,6 +421,19 b' def shownames(namespace, **args):'
421 421 names = ns.names(repo, ctx.node())
422 422 return showlist(ns.templatename, names, plural=namespace, **args)
423 423
424 def shownamespaces(**args):
425 """:namespaces: Dict of lists. Names attached to this changeset per
426 namespace."""
427 ctx = args['ctx']
428 repo = ctx.repo()
429 namespaces = util.sortdict((k, showlist('name', ns.names(repo, ctx.node()),
430 **args))
431 for k, ns in repo.names.iteritems())
432 f = _showlist('namespace', list(namespaces), **args)
433 return _hybrid(f, namespaces,
434 lambda k: {'namespace': k, 'names': namespaces[k]},
435 lambda x: x['namespace'])
436
424 437 def shownode(repo, ctx, templ, **args):
425 438 """:node: String. The changeset identification hash, as a 40 hexadecimal
426 439 digit string.
@@ -537,6 +550,7 b' keywords = {'
537 550 'latesttag': showlatesttag,
538 551 'latesttagdistance': showlatesttagdistance,
539 552 'manifest': showmanifest,
553 'namespaces': shownamespaces,
540 554 'node': shownode,
541 555 'p1rev': showp1rev,
542 556 'p1node': showp1node,
@@ -3304,6 +3304,28 b' Test active bookmark templating'
3304 3304 1 f
3305 3305 0 f
3306 3306
3307 Test namespaces dict
3308
3309 $ hg log -T '{rev}{namespaces % " {namespace}={join(names, ",")}"}\n'
3310 2 bookmarks=bar,foo tags=tip branches=text.{rev}
3311 1 bookmarks=baz tags= branches=text.{rev}
3312 0 bookmarks= tags= branches=default
3313 $ hg log -r2 -T '{namespaces % "{namespace}: {names}\n"}'
3314 bookmarks: bar foo
3315 tags: tip
3316 branches: text.{rev}
3317 $ hg log -r2 -T '{namespaces % "{namespace}:\n{names % " {name}\n"}"}'
3318 bookmarks:
3319 bar
3320 foo
3321 tags:
3322 tip
3323 branches:
3324 text.{rev}
3325 $ hg log -r2 -T '{get(namespaces, "bookmarks") % "{name}\n"}'
3326 bar
3327 foo
3328
3307 3329 Test stringify on sub expressions
3308 3330
3309 3331 $ cd ..
General Comments 0
You need to be logged in to leave comments. Login now