comparison 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
comparison
equal deleted inserted replaced
6545:7b2bd0332b56 6547:d13cfd9eb6c0
47 return set().union( 47 return set().union(
48 *[roots for roots in repo._phasecache.phaseroots[1:] if roots] 48 *[roots for roots in repo._phasecache.phaseroots[1:] if roots]
49 ) 49 )
50 50
51 def overridecommitstatus(overridefn): 51 def overridecommitstatus(overridefn):
52 if r'tip' in cmdutil.commitstatus.__code__.co_varnames: 52 code = cmdutil.commitstatus.__code__
53 if r'opts' in code.co_varnames[code.co_argcount:]:
54 # commitstatus(..., **opts)
53 extensions.wrapfunction(cmdutil, 'commitstatus', overridefn) 55 extensions.wrapfunction(cmdutil, 'commitstatus', overridefn)
56 elif r'tip' in code.co_varnames:
57 # hg <= 6.5 (489268c8ee7e)
58 def _override(orig, repo, node, branch, bheads=None, tip=None, opts=None):
59 def _orig(repo, node, branch, bheads=None, tip=None, **opts):
60 return orig(repo, node, branch, bheads=bheads, tip=None, opts=opts)
61 opts = pycompat.strkwargs(opts)
62 return overridefn(_orig, repo, node, branch, bheads=bheads, tip=None, **opts)
63 extensions.wrapfunction(cmdutil, 'commitstatus', _override)
54 else: 64 else:
55 # hg <= 5.6 (976b26bdd0d8) 65 # hg <= 5.6 (976b26bdd0d8)
56 def _override(orig, repo, node, branch, bheads=None, opts=None): 66 def _override(orig, repo, node, branch, bheads=None, opts=None):
57 def _orig(repo, node, branch, bheads=None, tip=None, opts=None): 67 def _orig(repo, node, branch, bheads=None, tip=None, **opts):
58 return orig(repo, node, branch, bheads=bheads, opts=opts) 68 return orig(repo, node, branch, bheads=bheads, opts=opts)
59 return overridefn(_orig, repo, node, branch, bheads=bheads, tip=None, opts=opts) 69 if opts is None:
70 opts = {}
71 opts = pycompat.strkwargs(opts)
72 return overridefn(_orig, repo, node, branch, bheads=bheads, tip=None, **opts)
60 extensions.wrapfunction(cmdutil, 'commitstatus', _override) 73 extensions.wrapfunction(cmdutil, 'commitstatus', _override)
61 74
62 if util.safehasattr(error, 'InputError'): 75 if util.safehasattr(error, 'InputError'):
63 InputError = error.InputError 76 InputError = error.InputError
64 else: 77 else: