# HG changeset patch # User Martin von Zweigbergk # Date 1605560888 28800 # Node ID dd9dba7c1d00625e214824b3088ad67a59c4794f # Parent c2fab88e6d600fa9235651a8cb767612b9dd57b0 compat: make topics compatible across change to cmdutil.commitstatus() `cmdutil.commitstatus()` was changed in https://phab.mercurial-scm.org/D9257 so it has a new `tip` argument. This patch adds compatibility with that. It was harder than I expected because the callers all pass the arguments as positional, so we can't look for `opts` or `tip` in the `kwargs`. I instead extracted much of the override to a helper. I think the result is okay. diff -r c2fab88e6d60 -r dd9dba7c1d00 hgext3rd/topic/compat.py --- a/hgext3rd/topic/compat.py Thu Oct 29 09:19:37 2020 -0700 +++ b/hgext3rd/topic/compat.py Mon Nov 16 13:08:08 2020 -0800 @@ -8,6 +8,8 @@ from __future__ import absolute_import from mercurial import ( + cmdutil, + extensions, pycompat, registrar, util, @@ -46,3 +48,14 @@ return set().union( *[roots for roots in repo._phasecache.phaseroots[1:] if roots] ) + +def overridecommitstatus(overridefn): + if r'tip' in cmdutil.commitstatus.__code__.co_varnames: + extensions.wrapfunction(cmdutil, 'commitstatus', overridefn) + else: + # hg <= 5.6 (976b26bdd0d8) + def _override(orig, repo, node, branch, bheads=None, opts=None): + def _orig(repo, node, branch, bheads=None, tip=None, opts=None): + return orig(repo, node, branch, bheads=bheads, opts=opts) + return overridefn(_orig, repo, node, branch, bheads=bheads, tip=None, opts=opts) + extensions.wrapfunction(cmdutil, 'commitstatus', _override) diff -r c2fab88e6d60 -r dd9dba7c1d00 hgext3rd/topic/topicmap.py --- a/hgext3rd/topic/topicmap.py Thu Oct 29 09:19:37 2020 -0700 +++ b/hgext3rd/topic/topicmap.py Mon Nov 16 13:08:08 2020 -0800 @@ -6,7 +6,6 @@ from mercurial import ( branchmap, changegroup, - cmdutil, extensions, repoview, util, @@ -89,20 +88,20 @@ _setuptopicfilter(ui) _wrapbmcache(ui) extensions.wrapfunction(changegroup.cg1unpacker, 'apply', cgapply) - extensions.wrapfunction(cmdutil, 'commitstatus', commitstatus) + compat.overridecommitstatus(commitstatus) def cgapply(orig, self, repo, *args, **kwargs): """make sure a topicmap is used when applying a changegroup""" other = repo.filtered(topicfilter(repo.filtername)) return orig(self, other, *args, **kwargs) -def commitstatus(orig, repo, node, branch, bheads=None, opts=None): +def commitstatus(orig, repo, node, branch, bheads=None, tip=None, opts=None): # wrap commit status use the topic branch heads ctx = repo[node] if ctx.topic() and ctx.branch() == branch: bheads = repo.branchheads(b"%s:%s" % (branch, ctx.topic())) - ret = orig(repo, node, branch, bheads=bheads, opts=opts) + ret = orig(repo, node, branch, bheads=bheads, tip=tip, opts=opts) # logic copy-pasted from cmdutil.commitstatus() if opts is None: