Skip to content

Commit

Permalink
firefoxtree: enable compatibility with Mercurial 4.8 (Bug 1501686) r=gps
Browse files Browse the repository at this point in the history
In versions above 4.8, the old-style template keyword
definitions will be deprecated. This commit forces
the `fxheads` template keyword to be dynamically
defined with the new API in versions above 4.6, and
with the old API for versions below 4.6. Doing so
fixes a deprecation warning in tests on version
4.8 and makes us compatible with modern hg.

Differential Revision: https://phabricator.services.mozilla.com/D10917

--HG--
extra : moz-landing-system : lando
  • Loading branch information
cgsheeh committed Nov 5, 2018
1 parent 263e9e3 commit 0b277c1
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions hgext/firefoxtree/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@
if not wireproto:
wireproto = import_module('mercurial.wireproto')

testedwith = '4.4 4.5 4.6 4.7'
testedwith = '4.4 4.5 4.6 4.7 4.8'
minimumhgversion = '4.4'
buglink = 'https://bugzilla.mozilla.org/enter_bug.cgi?product=Developer%20Services&component=Mercurial%3A%20firefoxtree'
# The root revisions in mozilla-central and comm-central, respectively.
Expand Down Expand Up @@ -590,9 +590,24 @@ def _getcachedlabels(repo, ctx, cache):

return labels

@templatekeyword('fxheads')
def template_fxheads(repo, ctx, templ, cache, **args):
# TRACKING hg46
if util.versiontuple(n=2) >= (4, 6):
fxheadsdec = templatekeyword('fxheads', requires={'repo, ctx, cache'})
else:
fxheadsdec = templatekeyword('fxheads')

@fxheadsdec
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

labels = _getcachedlabels(repo, ctx, cache)
if not labels:
return []
Expand Down

0 comments on commit 0b277c1

Please sign in to comment.