remotenames: work around move of ABCs in collections
authorAugie Fackler <augie@google.com>
Tue, 13 Mar 2018 17:55:03 -0400
changeset 36956 b710fdebd0db
parent 36955 f21798a6bc20
child 36957 a8d540d2628c
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
hgext/remotenames.py
--- a/hgext/remotenames.py	Mon Feb 26 20:44:21 2018 +0800
+++ b/hgext/remotenames.py	Tue Mar 13 17:55:03 2018 -0400
@@ -22,8 +22,6 @@
 
 from __future__ import absolute_import
 
-import collections
-
 from mercurial.i18n import _
 
 from mercurial.node import (
@@ -32,12 +30,20 @@
 from mercurial import (
     logexchange,
     namespaces,
+    pycompat,
     registrar,
     revsetlang,
     smartset,
     templateutil,
 )
 
+if pycompat.ispy3:
+    import collections.abc
+    mutablemapping = collections.abc.MutableMapping
+else:
+    import collections
+    mutablemapping = collections.MutableMapping
+
 # Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for
 # extensions which SHIP WITH MERCURIAL. Non-mainline extensions should
 # be specifying the version(s) of Mercurial they are tested with, or
@@ -56,7 +62,7 @@
     default=True,
 )
 
-class lazyremotenamedict(collections.MutableMapping):
+class lazyremotenamedict(mutablemapping):
     """
     Read-only dict-like Class to lazily resolve remotename entries