##// END OF EJS Templates
branchmap: remove the dict interface from the branchcache class (API)...
Pulkit Goyal -
r42168:624d6683 default
parent child Browse files
Show More
@@ -127,7 +127,7 b' class BranchMapCache(object):'
127 127 self._per_filter.clear()
128 128
129 129
130 class branchcache(dict):
130 class branchcache(object):
131 131 """A dict like object that hold branches heads cache.
132 132
133 133 This cache is used to avoid costly computations to determine all the
@@ -151,7 +151,6 b' class branchcache(dict):'
151 151
152 152 def __init__(self, entries=(), tipnode=nullid, tiprev=nullrev,
153 153 filteredhash=None, closednodes=None):
154 super(branchcache, self).__init__(entries)
155 154 self.tipnode = tipnode
156 155 self.tiprev = tiprev
157 156 self.filteredhash = filteredhash
@@ -162,6 +161,25 b' class branchcache(dict):'
162 161 self._closednodes = set()
163 162 else:
164 163 self._closednodes = closednodes
164 self.entries = dict(entries)
165
166 def __iter__(self):
167 return iter(self.entries)
168
169 def __setitem__(self, key, value):
170 self.entries[key] = value
171
172 def __getitem__(self, key):
173 return self.entries[key]
174
175 def setdefault(self, *args):
176 return self.entries.setdefault(*args)
177
178 def iteritems(self):
179 return self.entries.iteritems()
180
181 def itervalues(self):
182 return self.entries.itervalues()
165 183
166 184 @classmethod
167 185 def fromfile(cls, repo):
@@ -271,8 +289,8 b' class branchcache(dict):'
271 289
272 290 def copy(self):
273 291 """return an deep copy of the branchcache object"""
274 return type(self)(
275 self, self.tipnode, self.tiprev, self.filteredhash,
292 return branchcache(
293 self.entries, self.tipnode, self.tiprev, self.filteredhash,
276 294 self._closednodes)
277 295
278 296 def write(self, repo):
@@ -295,7 +313,7 b' class branchcache(dict):'
295 313 f.close()
296 314 repo.ui.log('branchcache',
297 315 'wrote %s branch cache with %d labels and %d nodes\n',
298 repo.filtername, len(self), nodecount)
316 repo.filtername, len(self.entries), nodecount)
299 317 except (IOError, OSError, error.Abort) as inst:
300 318 # Abort may be raised by read only opener, so log and continue
301 319 repo.ui.debug("couldn't write branch cache: %s\n" %
@@ -351,7 +369,7 b' class branchcache(dict):'
351 369 # cache key are not valid anymore
352 370 self.tipnode = nullid
353 371 self.tiprev = nullrev
354 for heads in self.values():
372 for heads in self.itervalues():
355 373 tiprev = max(cl.rev(node) for node in heads)
356 374 if tiprev > self.tiprev:
357 375 self.tipnode = cl.node(tiprev)
@@ -1556,7 +1556,7 b' class localrepository(object):'
1556 1556 return scmutil.revsymbol(self, key).node()
1557 1557
1558 1558 def lookupbranch(self, key):
1559 if key in self.branchmap():
1559 if key in self.branchmap().entries:
1560 1560 return key
1561 1561
1562 1562 return scmutil.revsymbol(self, key).branch()
@@ -2730,7 +2730,7 b' class localrepository(object):'
2730 2730 if branch is None:
2731 2731 branch = self[None].branch()
2732 2732 branches = self.branchmap()
2733 if branch not in branches:
2733 if branch not in branches.entries:
2734 2734 return []
2735 2735 # the cache returns heads ordered lowest to highest
2736 2736 bheads = list(reversed(branches.branchheads(branch, closed=closed)))
General Comments 0
You need to be logged in to leave comments. Login now