Mercurial > evolve
diff hgext3rd/topic/compat.py @ 6547:d13cfd9eb6c0
topic: compatibility for commitstatus(..., **opts)
In 489268c8ee7e cmdutil.commitstatus() was changed to take opts as separate
keyword arguments.
We need to convert the byteskwargs to strings to use with double-star operator,
so in the appropriate function wrapper we also now have strings instead of
bytes in the opts dict.
author | Anton Shestakov <av6@dwimlabs.net> |
---|---|
date | Wed, 30 Aug 2023 15:08:35 -0300 |
parents | f4ffe1e67a9b |
children | 9a55b007faf6 |
line wrap: on
line diff
--- a/hgext3rd/topic/compat.py Sun Aug 13 16:08:26 2023 -0300 +++ b/hgext3rd/topic/compat.py Wed Aug 30 15:08:35 2023 -0300 @@ -49,14 +49,27 @@ ) def overridecommitstatus(overridefn): - if r'tip' in cmdutil.commitstatus.__code__.co_varnames: + code = cmdutil.commitstatus.__code__ + if r'opts' in code.co_varnames[code.co_argcount:]: + # commitstatus(..., **opts) extensions.wrapfunction(cmdutil, 'commitstatus', overridefn) + elif r'tip' in code.co_varnames: + # hg <= 6.5 (489268c8ee7e) + def _override(orig, repo, node, branch, bheads=None, tip=None, opts=None): + def _orig(repo, node, branch, bheads=None, tip=None, **opts): + return orig(repo, node, branch, bheads=bheads, tip=None, opts=opts) + opts = pycompat.strkwargs(opts) + return overridefn(_orig, repo, node, branch, bheads=bheads, tip=None, **opts) + extensions.wrapfunction(cmdutil, 'commitstatus', _override) 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): + def _orig(repo, node, branch, bheads=None, tip=None, **opts): return orig(repo, node, branch, bheads=bheads, opts=opts) - return overridefn(_orig, repo, node, branch, bheads=bheads, tip=None, opts=opts) + if opts is None: + opts = {} + opts = pycompat.strkwargs(opts) + return overridefn(_orig, repo, node, branch, bheads=bheads, tip=None, **opts) extensions.wrapfunction(cmdutil, 'commitstatus', _override) if util.safehasattr(error, 'InputError'):