Add {trees} and {reltrees} template keywords
authorGregory Szorc <gps@mozilla.com>
Fri, 08 Nov 2013 11:08:31 -0800
changeset 73 e055c35a87ee7d03bd9236933f10e18b74cfb614
parent 72 35bb3c96d786f842f2776c17a37b4aacbc4c481a
child 74 bc0e9c3a49362f318bd534f08295daeb0c503310
push id53
push usergszorc@mozilla.com
push dateFri, 08 Nov 2013 19:08:35 +0000
Add {trees} and {reltrees} template keywords
__init__.py
--- a/__init__.py
+++ b/__init__.py
@@ -204,16 +204,22 @@ firstpushuser
    The username of the first person who pushed this changeset.
 
 firstpushtree
    The name of the first tree this changeset was pushed to.
 
 firstpushtbpl
    The URL of the TBPL results for the first push of this changeset.
 
+trees
+   The list of trees a changeset has landed in.
+
+reltrees
+   The list of release trees a changeset has landed in.
+
 Config Options
 ==============
 
 This extension consults the following config options.
 
 mozext.headless
    Indicates that this extension is running in *headless* mode. *headless*
    mode is intended for server operation, not local development.
@@ -1061,16 +1067,28 @@ def template_firstpushtbpl(repo, ctx, **
         return None
 
     push = pushes[0]
     tree, node = push[0], push[4]
 
     return tbpl_url(tree, hex(node)[0:12])
 
 
+def template_trees(repo, ctx, **args):
+    """:trees: List of strings. Trees this changeset has landed in.
+    """
+    return [p[0] for p in repo.changetracker.pushes_for_changeset(ctx.node())]
+
+
+def template_reltrees(repo, ctx, **args):
+    """:reltrees: List of strings. Release trees this changeset has landed in.
+    """
+    return [t for t in template_trees(repo, ctx, **args) if t in RELEASE_TREES]
+
+
 def extsetup(ui):
     global bz_available
     try:
         extensions.find('bzexport')
         bz_available = True
     except KeyError:
         pass
 
@@ -1095,16 +1113,18 @@ def extsetup(ui):
     templatekw.keywords['firstbeta'] = template_firstbeta
     templatekw.keywords['firstaurora'] = template_firstaurora
     templatekw.keywords['firstnightly'] = template_firstnightly
     templatekw.keywords['auroradate'] = template_auroradate
     templatekw.keywords['nightlydate'] = template_nightlydate
     templatekw.keywords['firstpushuser'] = template_firstpushuser
     templatekw.keywords['firstpushtree'] = template_firstpushtree
     templatekw.keywords['firstpushtbpl'] = template_firstpushtbpl
+    templatekw.keywords['trees'] = template_trees
+    templatekw.keywords['reltrees'] = template_reltrees
 
 
 def reposetup(ui, repo):
     """Custom repository implementation.
 
     Our custom repository class tracks remote tree references so users can
     reference specific revisions on remotes.
     """