Mercurial > public > mercurial-scm > evolve
diff hgext3rd/topic/compat.py @ 5665:dd9dba7c1d00
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.
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Mon, 16 Nov 2020 13:08:08 -0800 |
parents | 86736040b0ec |
children | 77ce98287dc2 |
line wrap: on
line diff
--- 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)