# HG changeset patch # User Anton Shestakov # Date 1693418915 10800 # Node ID d13cfd9eb6c0b3d5055ce9b90a0fb81aa38c8dd9 # Parent 7b2bd0332b56b588cc07d1d5d4f7f9818c20ac08 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. diff -r 7b2bd0332b56 -r d13cfd9eb6c0 hgext3rd/topic/compat.py --- 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'): diff -r 7b2bd0332b56 -r d13cfd9eb6c0 hgext3rd/topic/topicmap.py --- a/hgext3rd/topic/topicmap.py Sun Aug 13 16:08:26 2023 -0300 +++ b/hgext3rd/topic/topicmap.py Wed Aug 30 15:08:35 2023 -0300 @@ -97,7 +97,7 @@ other = repo.filtered(topicfilter(repo.filtername)) return orig(self, other, *args, **kwargs) -def commitstatus(orig, repo, node, branch, bheads=None, tip=None, opts=None): +def commitstatus(orig, repo, node, branch, bheads=None, tip=None, **opts): # wrap commit status use the topic branch heads ctx = repo[node] ctxbranch = common.formatfqbn(branch=ctx.branch()) @@ -105,16 +105,14 @@ bheads = repo.branchheads(b"%s:%s" % (branch, ctx.topic())) with discovery.override_context_branch(repo) as repo: - ret = orig(repo, node, branch, bheads=bheads, tip=tip, opts=opts) + ret = orig(repo, node, branch, bheads=bheads, tip=tip, **opts) # logic copy-pasted from cmdutil.commitstatus() - if opts is None: - opts = {} if ctx.topic(): return ret parents = ctx.parents() - if (not opts.get(b'amend') and bheads and node not in bheads and not any( + if (not opts.get('amend') and bheads and node not in bheads and not any( p.node() in bheads and common.formatfqbn(branch=p.branch()) == branch for p in parents )):