Show More
@@ -64,6 +64,12 b' try:' | |||||
64 | from mercurial import scmutil # since 1.9 (or 8b252e826c68) |
|
64 | from mercurial import scmutil # since 1.9 (or 8b252e826c68) | |
65 | except ImportError: |
|
65 | except ImportError: | |
66 | pass |
|
66 | pass | |
|
67 | try: | |||
|
68 | from mercurial import pycompat | |||
|
69 | getargspec = pycompat.getargspec # added to module after 4.5 | |||
|
70 | except (ImportError, AttributeError): | |||
|
71 | import inspect | |||
|
72 | getargspec = inspect.getargspec | |||
67 |
|
73 | |||
68 | # for "historical portability": |
|
74 | # for "historical portability": | |
69 | # define util.safehasattr forcibly, because util.safehasattr has been |
|
75 | # define util.safehasattr forcibly, because util.safehasattr has been | |
@@ -114,9 +120,8 b' def parsealiases(cmd):' | |||||
114 | if safehasattr(registrar, 'command'): |
|
120 | if safehasattr(registrar, 'command'): | |
115 | command = registrar.command(cmdtable) |
|
121 | command = registrar.command(cmdtable) | |
116 | elif safehasattr(cmdutil, 'command'): |
|
122 | elif safehasattr(cmdutil, 'command'): | |
117 | import inspect |
|
|||
118 | command = cmdutil.command(cmdtable) |
|
123 | command = cmdutil.command(cmdtable) | |
119 |
if 'norepo' not in |
|
124 | if 'norepo' not in getargspec(command).args: | |
120 | # for "historical portability": |
|
125 | # for "historical portability": | |
121 | # wrap original cmdutil.command, because "norepo" option has |
|
126 | # wrap original cmdutil.command, because "norepo" option has | |
122 | # been available since 3.1 (or 75a96326cecb) |
|
127 | # been available since 3.1 (or 75a96326cecb) |
@@ -195,11 +195,7 b' def _runextsetup(name, ui):' | |||||
195 | try: |
|
195 | try: | |
196 | extsetup(ui) |
|
196 | extsetup(ui) | |
197 | except TypeError: |
|
197 | except TypeError: | |
198 | # Try to use getfullargspec (Python 3) first, and fall |
|
198 | if pycompat.getargspec(extsetup).args: | |
199 | # back to getargspec only if it doesn't exist so as to |
|
|||
200 | # avoid warnings. |
|
|||
201 | if getattr(inspect, 'getfullargspec', |
|
|||
202 | getattr(inspect, 'getargspec'))(extsetup).args: |
|
|||
203 | raise |
|
199 | raise | |
204 | extsetup() # old extsetup with no ui argument |
|
200 | extsetup() # old extsetup with no ui argument | |
205 | except Exception as inst: |
|
201 | except Exception as inst: |
@@ -9,7 +9,6 b' from __future__ import absolute_import' | |||||
9 |
|
9 | |||
10 | import errno |
|
10 | import errno | |
11 | import hashlib |
|
11 | import hashlib | |
12 | import inspect |
|
|||
13 | import os |
|
12 | import os | |
14 | import random |
|
13 | import random | |
15 | import time |
|
14 | import time | |
@@ -1068,7 +1067,7 b' class localrepository(object):' | |||||
1068 | if not fn: |
|
1067 | if not fn: | |
1069 | fn = lambda s, c, **kwargs: util.filter(s, c) |
|
1068 | fn = lambda s, c, **kwargs: util.filter(s, c) | |
1070 | # Wrap old filters not supporting keyword arguments |
|
1069 | # Wrap old filters not supporting keyword arguments | |
1071 |
if not |
|
1070 | if not pycompat.getargspec(fn)[2]: | |
1072 | oldfn = fn |
|
1071 | oldfn = fn | |
1073 | fn = lambda s, c, **kwargs: oldfn(s, c) |
|
1072 | fn = lambda s, c, **kwargs: oldfn(s, c) | |
1074 | l.append((mf, fn, params)) |
|
1073 | l.append((mf, fn, params)) |
@@ -11,6 +11,7 b' This contains aliases to hide python ver' | |||||
11 | from __future__ import absolute_import |
|
11 | from __future__ import absolute_import | |
12 |
|
12 | |||
13 | import getopt |
|
13 | import getopt | |
|
14 | import inspect | |||
14 | import os |
|
15 | import os | |
15 | import shlex |
|
16 | import shlex | |
16 | import sys |
|
17 | import sys | |
@@ -65,6 +66,7 b' if ispy3:' | |||||
65 | maplist = lambda *args: list(map(*args)) |
|
66 | maplist = lambda *args: list(map(*args)) | |
66 | ziplist = lambda *args: list(zip(*args)) |
|
67 | ziplist = lambda *args: list(zip(*args)) | |
67 | rawinput = input |
|
68 | rawinput = input | |
|
69 | getargspec = inspect.getfullargspec | |||
68 |
|
70 | |||
69 | # TODO: .buffer might not exist if std streams were replaced; we'll need |
|
71 | # TODO: .buffer might not exist if std streams were replaced; we'll need | |
70 | # a silly wrapper to make a bytes stream backed by a unicode one. |
|
72 | # a silly wrapper to make a bytes stream backed by a unicode one. | |
@@ -330,6 +332,7 b' else:' | |||||
330 | maplist = map |
|
332 | maplist = map | |
331 | ziplist = zip |
|
333 | ziplist = zip | |
332 | rawinput = raw_input |
|
334 | rawinput = raw_input | |
|
335 | getargspec = inspect.getargspec | |||
333 |
|
336 | |||
334 | def emailparser(*args, **kwargs): |
|
337 | def emailparser(*args, **kwargs): | |
335 | import email.parser |
|
338 | import email.parser |
General Comments 0
You need to be logged in to leave comments.
Login now