firefoxtree: prevent unknown reference to _updateremoterefs (bug 1085066)
authorGregory Szorc <gps@mozilla.com>
Sun, 19 Oct 2014 21:17:54 -0700
changeset 1473 4a7444b8e597c8ad9575cafb2b6c0075611a4653
parent 1472 b5293af9f9768bec32e6f4335aa29eb661e309e3
child 1474 4056a46cb4afa04a6a859780fd0b1ed4191609e1
push id317
push usergszorc@mozilla.com
push dateFri, 31 Oct 2014 01:51:23 +0000
treeherderversion-control-tools@4a7444b8e597 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1085066
firefoxtree: prevent unknown reference to _updateremoterefs (bug 1085066) A user reported that the extension was attempting to access an unknown attribute on a repo instance. The backtrace indicated filtered repositories may be involved. The extra localrepository class for Firefox repositories provided only a single method, which didn't need to be on a class. To match the recent move of pull() into a module-level function, we move the remaining class method into a module-level function and remove the custom class. There should now be no issue accessing this function on an unknown type. Unfortunately, no test for the underlying issue is included. However, the solution does treat the symptoms. There may be a bug still lingering, likely around calling the firefoxtree code when it shouldn't be.
hgext/firefoxtree/__init__.py
--- a/hgext/firefoxtree/__init__.py
+++ b/hgext/firefoxtree/__init__.py
@@ -231,22 +231,41 @@ def pull(orig, repo, remote, *args, **kw
             if newlines:
                 newlines.append('')
             if newlines:
                 repo.opener.write('localtags', '\n'.join(newlines))
 
         tree = resolve_uri_to_tree(remote.url())
         if tree:
             tree = tree.encode('utf-8')
-            repo._updateremoterefs(remote, tree)
+            updateremoterefs(repo, remote, tree)
     finally:
         lock.release()
 
     return res
 
+def updateremoterefs(repo, remote, tree):
+    """Update the remote refs for a Firefox repository.
+
+    This is called during pull to create the remote tracking tags for
+    Firefox repos.
+    """
+    # We only care about the default branch. We could import
+    # RELBRANCH and other branches if we really cared about it.
+    # Maybe later.
+    branchmap = remote.branchmap()
+    if 'default' not in branchmap:
+        return
+
+    # Firefox repos should only ever have a single head in the
+    # default branch.
+    defaultnodes = branchmap['default']
+    node = defaultnodes[-1]
+    repo.tag(tree, node, message=None, local=True, user=None, date=None)
+
 @command('fxheads', [
     ('T', 'template', shorttemplate,
      _('display with template'), _('TEMPLATE')),
     ], _('show Firefox tree heads'))
 def fxheads(ui, repo, **opts):
     """Show last known head commits for pulled Firefox trees.
 
     The displayed list may be out of date. Pull before running to ensure
@@ -275,25 +294,9 @@ def reposetup(ui, repo):
     if not repo.local():
         return
 
     # Only change behavior on repositories that are clones of a Firefox
     # repository.
     if not isfirefoxrepo(repo):
         return
 
-    class firefoxtreerepo(repo.__class__):
-        def _updateremoterefs(self, remote, tree):
-            # We only care about the default branch. We could import
-            # RELBRANCH and other branches if we really cared about it.
-            # Maybe later.
-            branchmap = remote.branchmap()
-            if 'default' not in branchmap:
-                return
-
-            # Firefox repos should only ever have a single head in the
-            # default branch.
-            defaultnodes = branchmap['default']
-            node = defaultnodes[-1]
-            self.tag(tree, node, message=None, local=True, user=None, date=None)
-
-    repo.__class__ = firefoxtreerepo
     repo.prepushoutgoinghooks.add('firefoxtree', prepushoutgoinghook)