Show More
@@ -127,7 +127,7 b' class BranchMapCache(object):' | |||||
127 | self._per_filter.clear() |
|
127 | self._per_filter.clear() | |
128 |
|
128 | |||
129 |
|
129 | |||
130 |
class branchcache( |
|
130 | class branchcache(object): | |
131 | """A dict like object that hold branches heads cache. |
|
131 | """A dict like object that hold branches heads cache. | |
132 |
|
132 | |||
133 | This cache is used to avoid costly computations to determine all the |
|
133 | This cache is used to avoid costly computations to determine all the | |
@@ -151,7 +151,6 b' class branchcache(dict):' | |||||
151 |
|
151 | |||
152 | def __init__(self, entries=(), tipnode=nullid, tiprev=nullrev, |
|
152 | def __init__(self, entries=(), tipnode=nullid, tiprev=nullrev, | |
153 | filteredhash=None, closednodes=None): |
|
153 | filteredhash=None, closednodes=None): | |
154 | super(branchcache, self).__init__(entries) |
|
|||
155 | self.tipnode = tipnode |
|
154 | self.tipnode = tipnode | |
156 | self.tiprev = tiprev |
|
155 | self.tiprev = tiprev | |
157 | self.filteredhash = filteredhash |
|
156 | self.filteredhash = filteredhash | |
@@ -162,6 +161,25 b' class branchcache(dict):' | |||||
162 | self._closednodes = set() |
|
161 | self._closednodes = set() | |
163 | else: |
|
162 | else: | |
164 | self._closednodes = closednodes |
|
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 | @classmethod |
|
184 | @classmethod | |
167 | def fromfile(cls, repo): |
|
185 | def fromfile(cls, repo): | |
@@ -271,8 +289,8 b' class branchcache(dict):' | |||||
271 |
|
289 | |||
272 | def copy(self): |
|
290 | def copy(self): | |
273 | """return an deep copy of the branchcache object""" |
|
291 | """return an deep copy of the branchcache object""" | |
274 |
return |
|
292 | return branchcache( | |
275 | self, self.tipnode, self.tiprev, self.filteredhash, |
|
293 | self.entries, self.tipnode, self.tiprev, self.filteredhash, | |
276 | self._closednodes) |
|
294 | self._closednodes) | |
277 |
|
295 | |||
278 | def write(self, repo): |
|
296 | def write(self, repo): | |
@@ -295,7 +313,7 b' class branchcache(dict):' | |||||
295 | f.close() |
|
313 | f.close() | |
296 | repo.ui.log('branchcache', |
|
314 | repo.ui.log('branchcache', | |
297 | 'wrote %s branch cache with %d labels and %d nodes\n', |
|
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 | except (IOError, OSError, error.Abort) as inst: |
|
317 | except (IOError, OSError, error.Abort) as inst: | |
300 | # Abort may be raised by read only opener, so log and continue |
|
318 | # Abort may be raised by read only opener, so log and continue | |
301 | repo.ui.debug("couldn't write branch cache: %s\n" % |
|
319 | repo.ui.debug("couldn't write branch cache: %s\n" % | |
@@ -351,7 +369,7 b' class branchcache(dict):' | |||||
351 | # cache key are not valid anymore |
|
369 | # cache key are not valid anymore | |
352 | self.tipnode = nullid |
|
370 | self.tipnode = nullid | |
353 | self.tiprev = nullrev |
|
371 | self.tiprev = nullrev | |
354 | for heads in self.values(): |
|
372 | for heads in self.itervalues(): | |
355 | tiprev = max(cl.rev(node) for node in heads) |
|
373 | tiprev = max(cl.rev(node) for node in heads) | |
356 | if tiprev > self.tiprev: |
|
374 | if tiprev > self.tiprev: | |
357 | self.tipnode = cl.node(tiprev) |
|
375 | self.tipnode = cl.node(tiprev) |
@@ -1556,7 +1556,7 b' class localrepository(object):' | |||||
1556 | return scmutil.revsymbol(self, key).node() |
|
1556 | return scmutil.revsymbol(self, key).node() | |
1557 |
|
1557 | |||
1558 | def lookupbranch(self, key): |
|
1558 | def lookupbranch(self, key): | |
1559 | if key in self.branchmap(): |
|
1559 | if key in self.branchmap().entries: | |
1560 | return key |
|
1560 | return key | |
1561 |
|
1561 | |||
1562 | return scmutil.revsymbol(self, key).branch() |
|
1562 | return scmutil.revsymbol(self, key).branch() | |
@@ -2730,7 +2730,7 b' class localrepository(object):' | |||||
2730 | if branch is None: |
|
2730 | if branch is None: | |
2731 | branch = self[None].branch() |
|
2731 | branch = self[None].branch() | |
2732 | branches = self.branchmap() |
|
2732 | branches = self.branchmap() | |
2733 | if branch not in branches: |
|
2733 | if branch not in branches.entries: | |
2734 | return [] |
|
2734 | return [] | |
2735 | # the cache returns heads ordered lowest to highest |
|
2735 | # the cache returns heads ordered lowest to highest | |
2736 | bheads = list(reversed(branches.branchheads(branch, closed=closed))) |
|
2736 | bheads = list(reversed(branches.branchheads(branch, closed=closed))) |
General Comments 0
You need to be logged in to leave comments.
Login now