firefoxtree: use kwargs instead of args for pre 4.6 function signature (Bug 1505162)
authorConnor Sheehan <sheehan@mozilla.com>
Tue, 06 Nov 2018 15:57:32 -0500
changeset 6709 44468bade5404c4bef6fb574b452f6479d5dcd49
parent 6708 1ca1ab84d8277ea22d8f3bf33e836f4ccea01b11
child 6710 084a352be3be5bb9e23fc994efd80ca282ff46bf
push id3318
push usercosheehan@mozilla.com
push dateTue, 06 Nov 2018 20:57:54 +0000
treeherderversion-control-tools@44468bade540 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1505162
firefoxtree: use kwargs instead of args for pre 4.6 function signature (Bug 1505162) Template keywords in Mercurial 4.6+ have a new signature and API. When upgrading the signature backwards compatibility was required with versions 4.4 and 4.5, so the arguments were collected in `*args` and expanded after determining which API version is required. It appears that the arguments were actually keyword arguments, so `*args` is actually empty and we need to get the arguments from `kwargs`. The behaviour in question can be demonstrated with the following example: Python 2.7.13 (default, Nov 6 2018, 15:52:08) [GCC 7.3.0] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> def a(test): ... print test ... >>> r = {'test': 'hello'} >>> a(**r) hello Despite `test` being a positional argument in `a`, we can pass a dict with a "test" key and the function call will execute correctly. This commit changes the function to resolve it's arguments from `kwargs` instead of `args` on Mercurial less than 4.6.
hgext/firefoxtree/__init__.py
--- a/hgext/firefoxtree/__init__.py
+++ b/hgext/firefoxtree/__init__.py
@@ -601,17 +601,19 @@ def template_fxheads(*args, **kwargs):
     """:fxheads: List of strings. Firefox trees with heads on this commit."""
     # TRACKING hg46
     if util.versiontuple(n=2) >= (4, 6):
         context, mapping = args
         repo = context.resource(mapping, 'repo')
         ctx = context.resource(mapping, 'ctx')
         cache = context.resource(mapping, 'cache')
     else:
-        repo, ctx, templ, cache = args
+        repo = kwargs['repo']
+        ctx = kwargs['ctx']
+        cache = kwargs['cache']
 
     labels = _getcachedlabels(repo, ctx, cache)
     if not labels:
         return []
 
     res = set(tag for tag, node, tree, uri in labels if node == ctx.node())
     sortedres = sorted(res)