hg tbpl
authorGregory Szorc <gps@mozilla.com>
Mon, 22 Jul 2013 00:15:12 -0700
changeset 15 699ae892efef7dbd6ec0d0d45d6da82f824a5d27
parent 14 1b090642a2d0a6c94491fb0453af956307a55818
child 16 761f34455600006c20c9022ee30cbd69189ff420
push id6
push usergszorc@mozilla.com
push dateMon, 22 Jul 2013 07:39:24 +0000
hg tbpl
__init__.py
mozautomation/repository.py
--- a/__init__.py
+++ b/__init__.py
@@ -97,16 +97,18 @@ from mercurial.node import (
 from mercurial import (
     cmdutil,
     encoding,
     hg,
     util,
 )
 
 from mozautomation.repository import (
+    MercurialRepository,
+    resolve_trees_to_official,
     resolve_trees_to_uris,
     resolve_uri_to_tree,
 )
 
 
 commands.norepo += ' cloneunified moztrees treestatus'
 cmdtable = {}
 command = cmdutil.command(cmdtable)
@@ -242,16 +244,52 @@ def treestatus(ui, *trees, **opts):
         s = status[tree]
         if s.status == 'closed':
             ui.write('%s: %s (%s)\n' % (tree.rjust(longest), s.status,
                 s.reason))
         else:
             ui.write('%s: %s\n' % (tree.rjust(longest), s.status))
 
 
+@command('tbpl', [], _('hg tbpl [TREE] [REV]'))
+def tbpl(ui, repo, tree=None, rev=None, **opts):
+    """Open TBPL showing build status for the specified revision.
+
+    The command receives a tree name and a revision to query. The tree is
+    required because a revision/changeset may existing in multiple
+    repositories.
+    """
+    if not tree:
+        raise util.Abort('A tree must be specified.')
+
+    if not rev:
+        raise util.Abort('A revision must be specified.')
+
+    tree, repo_url = resolve_trees_to_uris([tree])[0]
+    if not repo_url:
+        raise util.Abort("Don't know about tree: %s" % tree)
+
+    r = MercurialRepository(repo_url)
+    node = repo[rev].hex()
+    push = r.push_info_for_changeset(node)
+
+    if not push:
+        raise util.Abort("Could not find push info for changeset %s" % node)
+
+    push_node = push.last_node
+    tree_official = resolve_trees_to_official([tree])[0]
+    tree_official = '-'.join(s.title() for s in tree_official.split('-'))
+
+    url = 'https://tbpl.mozilla.org/?tree=%s&rev=%s' % (tree_official,
+        push_node[0:12])
+
+    import webbrowser
+    webbrowser.get('firefox').open(url)
+
+
 class remoterefs(dict):
     """Represents a remote refs file."""
 
     def __init__(self, repo):
         dict.__init__(self)
         self._repo = repo
 
         try:
--- a/mozautomation/repository.py
+++ b/mozautomation/repository.py
@@ -78,16 +78,17 @@ REPOS = {
 
 OFFICIAL_MAP = {
     'central': 'mozilla-central',
     'inbound': 'mozilla-inbound',
     'services': 'services-central',
     'release': 'mozilla-release',
     'aurora': 'mozilla-aurora',
     'beta': 'mozilla-beta',
+    'build': 'build-system',
     'esr17': 'mozilla-esr17',
 }
 
 
 def resolve_trees_to_official(trees):
     mapped = []
     for tree in trees:
         mapped.extend(TREE_ALIASES.get(tree, [tree]))