Mercurial > evolve
comparison 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 |
comparison
equal
deleted
inserted
replaced
5647:c2fab88e6d60 | 5665:dd9dba7c1d00 |
---|---|
6 Compatibility module | 6 Compatibility module |
7 """ | 7 """ |
8 from __future__ import absolute_import | 8 from __future__ import absolute_import |
9 | 9 |
10 from mercurial import ( | 10 from mercurial import ( |
11 cmdutil, | |
12 extensions, | |
11 pycompat, | 13 pycompat, |
12 registrar, | 14 registrar, |
13 util, | 15 util, |
14 ) | 16 ) |
15 | 17 |
44 if util.safehasattr(repo._phasecache, 'nonpublicphaseroots'): | 46 if util.safehasattr(repo._phasecache, 'nonpublicphaseroots'): |
45 return repo._phasecache.nonpublicphaseroots(repo) | 47 return repo._phasecache.nonpublicphaseroots(repo) |
46 return set().union( | 48 return set().union( |
47 *[roots for roots in repo._phasecache.phaseroots[1:] if roots] | 49 *[roots for roots in repo._phasecache.phaseroots[1:] if roots] |
48 ) | 50 ) |
51 | |
52 def overridecommitstatus(overridefn): | |
53 if r'tip' in cmdutil.commitstatus.__code__.co_varnames: | |
54 extensions.wrapfunction(cmdutil, 'commitstatus', overridefn) | |
55 else: | |
56 # hg <= 5.6 (976b26bdd0d8) | |
57 def _override(orig, repo, node, branch, bheads=None, opts=None): | |
58 def _orig(repo, node, branch, bheads=None, tip=None, opts=None): | |
59 return orig(repo, node, branch, bheads=bheads, opts=opts) | |
60 return overridefn(_orig, repo, node, branch, bheads=bheads, tip=None, opts=opts) | |
61 extensions.wrapfunction(cmdutil, 'commitstatus', _override) |