Mercurial > evolve
diff hgext3rd/topic/compat.py @ 3575:97530d6e340d
compat: make override of createmarkers work on wrapped function
If createmarkers() has been wrapped using functools.partial(), the
__code__ attribute won't exist. Fix by unwrapping partial functions. I
tried to find another attribute to use as proxy for the
"__code__.co_argcount < 6", but there were no new functions or similar
added in that commit.
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Mon, 19 Mar 2018 15:46:17 -0700 |
parents | 2477bcdd95ff |
children | c912eaf29eec |
line wrap: on
line diff
--- a/hgext3rd/topic/compat.py Mon Mar 19 11:18:47 2018 -0700 +++ b/hgext3rd/topic/compat.py Mon Mar 19 15:46:17 2018 -0700 @@ -7,6 +7,8 @@ """ from __future__ import absolute_import +import functools + from mercurial import ( obsolete, scmutil, @@ -30,7 +32,10 @@ # Wrap obsolete.creatmarkers and make it accept but ignore "operation" argument # for hg < 4.3 createmarkers = obsolete.createmarkers -if obsolete.createmarkers.__code__.co_argcount < 6: +originalcreatemarkers = createmarkers +while isinstance(originalcreatemarkers, functools.partial): + originalcreatemarkers = originalcreatemarkers.func +if originalcreatemarkers.__code__.co_argcount < 6: def createmarkers(repo, relations, flag=0, date=None, metadata=None, operation=None): return obsolete.createmarkers(repo, relations, flag, date, metadata)