mozext: use extension wrapper mechanism for `hg._peerorrepo` (Bug 1569734) r=smacleod
authorConnor Sheehan <sheehan@mozilla.com>
Wed, 31 Jul 2019 21:08:39 +0000
changeset 7132 a8e3d70807b08f54731dbabb91fbd081f1cb148c
parent 7131 39ec9297f7509045a60a08723e7539173e2949ad
child 7133 790b45463fd4c7c21e9bcc9872d82a62ddc85f39
push id3551
push usercosheehan@mozilla.com
push dateWed, 31 Jul 2019 21:22:35 +0000
treeherderversion-control-tools@5e857d4f3091 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmacleod
bugs1569734
mozext: use extension wrapper mechanism for `hg._peerorrepo` (Bug 1569734) r=smacleod Previous we did a manual override of this object, which was causing tracebacks on my machine. Using the extension function wrapping utility gets rid of the issue. Differential Revision: https://phabricator.services.mozilla.com/D39951
hgext/mozext/__init__.py
--- a/hgext/mozext/__init__.py
+++ b/hgext/mozext/__init__.py
@@ -379,43 +379,37 @@ configitem('mozext', 'backoutsearchlimit
 
 colortable = {
     'buildstatus.success': 'green',
     'buildstatus.failed': 'red',
     'buildstatus.testfailed': 'cyan',
 }
 
 
-# Override peer path lookup such that common names magically get resolved to
-# known URIs.
-old_peerorrepo = hg._peerorrepo
-
 def get_ircnick(ui):
     headless = ui.configbool('mozext', 'headless')
     ircnick = ui.config('mozext', 'ircnick')
     if not ircnick and not headless:
         raise error.Abort(_('Set "[mozext] ircnick" in your hgrc to your '
             'Mozilla IRC nickname to enable additional functionality.'))
     return ircnick
 
-def peerorrepo(ui, path, *args, **kwargs):
+def wrapped_peerorrepo(orig, ui, path, *args, **kwargs):
     # Always try the old mechanism first. That way if there is a local
     # path that shares the name of a magic remote the local path is accessible.
     try:
-        return old_peerorrepo(ui, path, *args, **kwargs)
+        return orig(ui, path, *args, **kwargs)
     except RepoError:
         tree, uri = resolve_trees_to_uris([path])[0]
 
         if not uri:
             raise
 
         path = uri
-        return old_peerorrepo(ui, path, *args, **kwargs)
-
-hg._peerorrepo = peerorrepo
+        return orig(ui, path, *args, **kwargs)
 
 
 def exchangepullpushlog(orig, pullop):
     res = orig(pullop)
 
     if not pullop.remote.capable('pushlog'):
         return res
 
@@ -1353,16 +1347,17 @@ def extsetup(ui):
         extensions.find('bzexport')
         bz_available = True
     except KeyError:
         pass
 
     extensions.wrapfunction(exchange, 'pull', wrappedpull)
     extensions.wrapfunction(exchange, 'push', wrappedpush)
     extensions.wrapfunction(exchange, '_pullobsolete', exchangepullpushlog)
+    extensions.wrapfunction(hg, '_peerorrepo', wrapped_peerorrepo)
 
     if not ui.configbool('mozext', 'disable_local_database'):
         revsetpredicate('pushhead([TREE])')(revset_pushhead)
         revsetpredicate('tree(X)')(revset_tree)
         revsetpredicate('firstpushdate(DATE)')(revset_firstpushdate)
         revsetpredicate('firstpushtree(X)')(revset_firstpushtree)
         revsetpredicate('pushdate(DATE)')(revset_pushdate)