Prune RELBRANCH tags from non-release repos
authorGregory Szorc <gps@mozilla.com>
Wed, 16 Oct 2013 20:13:59 -0700
changeset 52 218c65fe5456f87fecb591cd02822d11d8f16939
parent 51 3dc420de34e5f6b10d56ebd2257c1c00ccbb248b
child 53 fa45c8eeb4ecad836cd9e39f8fe4e65805944ca3
push id35
push usergszorc@mozilla.com
push dateThu, 17 Oct 2013 03:14:04 +0000
Prune RELBRANCH tags from non-release repos
__init__.py
--- a/__init__.py
+++ b/__init__.py
@@ -150,16 +150,17 @@ from mozautomation.changetracker import 
 from mozautomation.repository import (
     MercurialRepository,
     RELEASE_TREES,
     REPOS,
     resolve_trees_to_official,
     resolve_trees_to_uris,
     resolve_uri_to_tree,
     tbpl_url,
+    TREE_ALIASES,
 )
 
 import bzauth
 import bz
 
 bz_available = False
 
 testedwith = '2.6.1 2.6.2 2.6.3 2.7.0 2.7.1 2.7.2'
@@ -647,24 +648,52 @@ def reposetup(ui, repo):
                 lock.release()
 
             return res
 
         def _update_remote_refs(self, remote, tree):
             mb = self.ui.configbool('mozext', 'refs_as_bookmarks',
                 default=False)
 
+            existing_refs = set()
+            incoming_refs = set()
+
+            for ref in self.remoterefs:
+                if ref.startswith('%s/' % tree):
+                    existing_refs.add(ref)
+
             for branch, nodes in remote.branchmap().items():
+                # Don't store RELBRANCH refs for non-release trees, as they are
+                # meaningless and cruft from yesteryear.
+                if branch.endswith('RELBRANCH') and \
+                    tree not in TREE_ALIASES['releases']:
+                    continue
+
+                ref = '%s/%s' % (tree, branch)
+                incoming_refs.add(ref)
+
                 for node in nodes:
-                    ref = '%s/%s' % (tree, branch)
                     self.remoterefs[ref] = node
 
                     if mb:
                         self._bookmarks[ref] = node
 
+            # Prune old refs.
+            for ref in existing_refs - incoming_refs:
+                try:
+                    del self.remoterefs[ref]
+                except KeyError:
+                    pass
+
+                if mb:
+                    try:
+                        del self._bookmarks[ref]
+                    except KeyError:
+                        pass
+
             self.remoterefs.write()
 
             if mb:
                 self._bookmarks.write()
 
         def _milestone_changesets(self):
             """Look up Gecko milestone changes.