Mercurial > evolve
comparison 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 |
comparison
equal
deleted
inserted
replaced
3574:8aba29d8b133 | 3575:97530d6e340d |
---|---|
4 # GNU General Public License version 2 or any later version. | 4 # GNU General Public License version 2 or any later version. |
5 """ | 5 """ |
6 Compatibility module | 6 Compatibility module |
7 """ | 7 """ |
8 from __future__ import absolute_import | 8 from __future__ import absolute_import |
9 | |
10 import functools | |
9 | 11 |
10 from mercurial import ( | 12 from mercurial import ( |
11 obsolete, | 13 obsolete, |
12 scmutil, | 14 scmutil, |
13 util, | 15 util, |
28 successorssets = obsolete.successorssets | 30 successorssets = obsolete.successorssets |
29 | 31 |
30 # Wrap obsolete.creatmarkers and make it accept but ignore "operation" argument | 32 # Wrap obsolete.creatmarkers and make it accept but ignore "operation" argument |
31 # for hg < 4.3 | 33 # for hg < 4.3 |
32 createmarkers = obsolete.createmarkers | 34 createmarkers = obsolete.createmarkers |
33 if obsolete.createmarkers.__code__.co_argcount < 6: | 35 originalcreatemarkers = createmarkers |
36 while isinstance(originalcreatemarkers, functools.partial): | |
37 originalcreatemarkers = originalcreatemarkers.func | |
38 if originalcreatemarkers.__code__.co_argcount < 6: | |
34 def createmarkers(repo, relations, flag=0, date=None, metadata=None, | 39 def createmarkers(repo, relations, flag=0, date=None, metadata=None, |
35 operation=None): | 40 operation=None): |
36 return obsolete.createmarkers(repo, relations, flag, date, metadata) | 41 return obsolete.createmarkers(repo, relations, flag, date, metadata) |
37 | 42 |
38 def startpager(ui, cmd): | 43 def startpager(ui, cmd): |