comparison hgext/remotenames.py @ 36252:e37be270e163

remotenames: port partway to python3 by using collections.MutableMapping test-logexchange.t doesn't pass after this, but at least the remotenames extension can be imported. Differential Revision: https://phab.mercurial-scm.org/D2280
author Augie Fackler <augie@google.com>
date Wed, 14 Feb 2018 23:23:57 -0500
parents 828f44cdfee3
children 18e29c65bc5c
comparison
equal deleted inserted replaced
36251:c2c5f9f6fa21 36252:e37be270e163
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 UserDict 25 import collections
26 26
27 from mercurial.i18n import _ 27 from mercurial.i18n import _
28 28
29 from mercurial.node import ( 29 from mercurial.node import (
30 bin, 30 bin,
55 ) 55 )
56 configitem('remotenames', 'branches', 56 configitem('remotenames', 'branches',
57 default=True, 57 default=True,
58 ) 58 )
59 59
60 class lazyremotenamedict(UserDict.DictMixin): 60 class lazyremotenamedict(collections.MutableMapping):
61 """ 61 """
62 Read-only dict-like Class to lazily resolve remotename entries 62 Read-only dict-like Class to lazily resolve remotename entries
63 63
64 We are doing that because remotenames startup was slow. 64 We are doing that because remotenames startup was slow.
65 We lazily read the remotenames file once to figure out the potential entries 65 We lazily read the remotenames file once to figure out the potential entries
108 if val is not None: 108 if val is not None:
109 return val 109 return val
110 else: 110 else:
111 raise KeyError() 111 raise KeyError()
112 112
113 def __iter__(self):
114 return iter(self.potentialentries)
115
116 def __len__(self):
117 return len(self.potentialentries)
118
119 def __setitem__(self):
120 raise NotImplementedError
121
122 def __delitem__(self):
123 raise NotImplementedError
124
113 def _fetchandcache(self, key): 125 def _fetchandcache(self, key):
114 if key in self.cache: 126 if key in self.cache:
115 return self.cache[key] 127 return self.cache[key]
116 val = self._resolvedata(key) 128 val = self._resolvedata(key)
117 if val is not None: 129 if val is not None: