comparison mercurial/localrepo.py @ 9673:863ba2ea1f0b

localrepo/branchcache: rebuild the "charset-aware" branchcache when needed It's simpler and the two cache weren't always in sync otherwise: localrepo.branchcache would not be updated after calling branchmap()
author Benoit Boissinot <benoit.boissinot@ens-lyon.org>
date Sat, 31 Oct 2009 00:20:28 +0100
parents 9471d9a900b4
children 603b23c6967b
comparison
equal deleted inserted replaced
9672:5bbf4f130684 9673:863ba2ea1f0b
318 self._writebranchcache(partial, self.changelog.tip(), tiprev) 318 self._writebranchcache(partial, self.changelog.tip(), tiprev)
319 319
320 return partial 320 return partial
321 321
322 def lbranchmap(self): 322 def lbranchmap(self):
323 tip = self.changelog.tip() 323 self.branchcache = {}
324 if self.branchcache is not None and self._branchcachetip == tip:
325 return self.branchcache
326
327 partial = self.branchmap() 324 partial = self.branchmap()
328 325
329 # the branch cache is stored on disk as UTF-8, but in the local 326 # the branch cache is stored on disk as UTF-8, but in the local
330 # charset internally 327 # charset internally
331 for k, v in partial.iteritems(): 328 for k, v in partial.iteritems():
337 if self._ubranchcache is not None and self._branchcachetip == tip: 334 if self._ubranchcache is not None and self._branchcachetip == tip:
338 return self._ubranchcache 335 return self._ubranchcache
339 336
340 oldtip = self._branchcachetip 337 oldtip = self._branchcachetip
341 self._branchcachetip = tip 338 self._branchcachetip = tip
342 if self.branchcache is None:
343 self.branchcache = {} # avoid recursion in changectx
344 else:
345 self.branchcache.clear() # keep using the same dict
346 if oldtip is None or oldtip not in self.changelog.nodemap: 339 if oldtip is None or oldtip not in self.changelog.nodemap:
347 partial, last, lrev = self._readbranchcache() 340 partial, last, lrev = self._readbranchcache()
348 else: 341 else:
349 lrev = self.changelog.rev(oldtip) 342 lrev = self.changelog.rev(oldtip)
350 partial = self._ubranchcache 343 partial = self._ubranchcache