changeset 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 7b2bd0332b56
children 445240ccb701
files hgext3rd/topic/compat.py hgext3rd/topic/topicmap.py
diffstat 2 files changed, 19 insertions(+), 8 deletions(-) [+]
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'):
--- 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
     )):