comparison hgext/remotenames.py @ 36956:b710fdebd0db

remotenames: work around move of ABCs in collections This starts warning in Python 3.7, and will break in 3.8. The import is performed in a curious place because `import collections.abc` explodes badly on Python 2.7, and `from collections import abc` flunks our import checker. Differential Revision: https://phab.mercurial-scm.org/D2847
author Augie Fackler <augie@google.com>
date Tue, 13 Mar 2018 17:55:03 -0400
parents 32f9b7e3f056
children aa97e06a1912
comparison
equal deleted inserted replaced
36955:f21798a6bc20 36956:b710fdebd0db
20 Boolean value to enable or disable showing of remotebranches 20 Boolean value to enable or disable showing of remotebranches
21 """ 21 """
22 22
23 from __future__ import absolute_import 23 from __future__ import absolute_import
24 24
25 import collections
26
27 from mercurial.i18n import _ 25 from mercurial.i18n import _
28 26
29 from mercurial.node import ( 27 from mercurial.node import (
30 bin, 28 bin,
31 ) 29 )
32 from mercurial import ( 30 from mercurial import (
33 logexchange, 31 logexchange,
34 namespaces, 32 namespaces,
33 pycompat,
35 registrar, 34 registrar,
36 revsetlang, 35 revsetlang,
37 smartset, 36 smartset,
38 templateutil, 37 templateutil,
39 ) 38 )
39
40 if pycompat.ispy3:
41 import collections.abc
42 mutablemapping = collections.abc.MutableMapping
43 else:
44 import collections
45 mutablemapping = collections.MutableMapping
40 46
41 # Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for 47 # Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for
42 # extensions which SHIP WITH MERCURIAL. Non-mainline extensions should 48 # extensions which SHIP WITH MERCURIAL. Non-mainline extensions should
43 # be specifying the version(s) of Mercurial they are tested with, or 49 # be specifying the version(s) of Mercurial they are tested with, or
44 # leave the attribute unspecified. 50 # leave the attribute unspecified.
54 ) 60 )
55 configitem('remotenames', 'branches', 61 configitem('remotenames', 'branches',
56 default=True, 62 default=True,
57 ) 63 )
58 64
59 class lazyremotenamedict(collections.MutableMapping): 65 class lazyremotenamedict(mutablemapping):
60 """ 66 """
61 Read-only dict-like Class to lazily resolve remotename entries 67 Read-only dict-like Class to lazily resolve remotename entries
62 68
63 We are doing that because remotenames startup was slow. 69 We are doing that because remotenames startup was slow.
64 We lazily read the remotenames file once to figure out the potential entries 70 We lazily read the remotenames file once to figure out the potential entries