# HG changeset patch # User Anton Shestakov # Date 1689016425 10800 # Node ID d20e5eaba76645d41db3bf6af7fa73c7ebb116c9 # Parent 80d5d4e587f775fb454729d2a7a3202a2641c988 compat: make inspect.getargspec() work with functools.partial on Python 2 This is required now because we wrap precheck() in core to check topic namespaces before any history rewrites. diff -r 80d5d4e587f7 -r d20e5eaba766 hgext3rd/evolve/rewriteutil.py --- a/hgext3rd/evolve/rewriteutil.py Thu Jun 22 21:51:37 2023 -0300 +++ b/hgext3rd/evolve/rewriteutil.py Mon Jul 10 16:13:45 2023 -0300 @@ -11,6 +11,8 @@ # happy one piece of it (and hopefully, able to reuse it in other core # commands). +import functools + from mercurial import ( cmdutil, commands, @@ -60,8 +62,13 @@ can be used to control the commit message. """ + if not pycompat.ispy3 and isinstance(corerewriteutil.precheck, functools.partial): + # inspect.getargspec() on py2 cannot inspect functools.partial objects + # directly, so we need to provide it with the underlying function + args = pycompat.getargspec(corerewriteutil.precheck.func).args + else: + args = pycompat.getargspec(corerewriteutil.precheck).args # hg <= 6.1 (d4752aeb20f1) - args = pycompat.getargspec(corerewriteutil.precheck).args if r'check_divergence' in args: return corerewriteutil.precheck(repo, revs, action, check_divergence=check_divergence)