comparison mercurial/localrepo.py @ 9674:603b23c6967b

localrepo/branchcache: kill unused localrepo.branchcache The UTF-8 version of the branchcache is the master, always up-to-date, we can rename it to localrepo._branchcache.
author Benoit Boissinot <benoit.boissinot@ens-lyon.org>
date Sat, 31 Oct 2009 00:27:50 +0100
parents 863ba2ea1f0b
children ee913987e4b0
comparison
equal deleted inserted replaced
9673:863ba2ea1f0b 9674:603b23c6967b
96 # heads, and local tags are defined in .hg/localtags.) They 96 # heads, and local tags are defined in .hg/localtags.) They
97 # constitute the in-memory cache of tags. 97 # constitute the in-memory cache of tags.
98 self._tags = None 98 self._tags = None
99 self._tagtypes = None 99 self._tagtypes = None
100 100
101 self.branchcache = None 101 self._branchcache = None # in UTF-8
102 self._ubranchcache = None # UTF-8 version of branchcache
103 self._branchcachetip = None 102 self._branchcachetip = None
104 self.nodetagscache = None 103 self.nodetagscache = None
105 self.filterpats = {} 104 self.filterpats = {}
106 self._datafilters = {} 105 self._datafilters = {}
107 self._transref = self._lockref = self._wlockref = None 106 self._transref = self._lockref = self._wlockref = None
318 self._writebranchcache(partial, self.changelog.tip(), tiprev) 317 self._writebranchcache(partial, self.changelog.tip(), tiprev)
319 318
320 return partial 319 return partial
321 320
322 def lbranchmap(self): 321 def lbranchmap(self):
323 self.branchcache = {} 322 branchcache = {}
324 partial = self.branchmap() 323 partial = self.branchmap()
325 324
326 # the branch cache is stored on disk as UTF-8, but in the local 325 # the branch cache is stored on disk as UTF-8, but in the local
327 # charset internally 326 # charset internally
328 for k, v in partial.iteritems(): 327 for k, v in partial.iteritems():
329 self.branchcache[encoding.tolocal(k)] = v 328 branchcache[encoding.tolocal(k)] = v
330 return self.branchcache 329 return branchcache
331 330
332 def branchmap(self): 331 def branchmap(self):
333 tip = self.changelog.tip() 332 tip = self.changelog.tip()
334 if self._ubranchcache is not None and self._branchcachetip == tip: 333 if self._branchcache is not None and self._branchcachetip == tip:
335 return self._ubranchcache 334 return self._branchcache
336 335
337 oldtip = self._branchcachetip 336 oldtip = self._branchcachetip
338 self._branchcachetip = tip 337 self._branchcachetip = tip
339 if oldtip is None or oldtip not in self.changelog.nodemap: 338 if oldtip is None or oldtip not in self.changelog.nodemap:
340 partial, last, lrev = self._readbranchcache() 339 partial, last, lrev = self._readbranchcache()
341 else: 340 else:
342 lrev = self.changelog.rev(oldtip) 341 lrev = self.changelog.rev(oldtip)
343 partial = self._ubranchcache 342 partial = self._branchcache
344 343
345 self._branchtags(partial, lrev) 344 self._branchtags(partial, lrev)
346 # this private cache holds all heads (not just tips) 345 # this private cache holds all heads (not just tips)
347 self._ubranchcache = partial 346 self._branchcache = partial
348 347
349 return self._ubranchcache 348 return self._branchcache
350 349
351 def branchtags(self): 350 def branchtags(self):
352 '''return a dict where branch names map to the tipmost head of 351 '''return a dict where branch names map to the tipmost head of
353 the branch, open heads come before closed''' 352 the branch, open heads come before closed'''
354 bt = {} 353 bt = {}
630 if a in self.__dict__: 629 if a in self.__dict__:
631 delattr(self, a) 630 delattr(self, a)
632 self._tags = None 631 self._tags = None
633 self._tagtypes = None 632 self._tagtypes = None
634 self.nodetagscache = None 633 self.nodetagscache = None
635 self.branchcache = None 634 self._branchcache = None # in UTF-8
636 self._ubranchcache = None
637 self._branchcachetip = None 635 self._branchcachetip = None
638 636
639 def _lock(self, lockname, wait, releasefn, acquirefn, desc): 637 def _lock(self, lockname, wait, releasefn, acquirefn, desc):
640 try: 638 try:
641 l = lock.lock(lockname, 0, releasefn, desc=desc) 639 l = lock.lock(lockname, 0, releasefn, desc=desc)
913 self.hook('pretxncommit', throw=True, node=hex(n), parent1=xp1, 911 self.hook('pretxncommit', throw=True, node=hex(n), parent1=xp1,
914 parent2=xp2, pending=p) 912 parent2=xp2, pending=p)
915 self.changelog.finalize(trp) 913 self.changelog.finalize(trp)
916 tr.close() 914 tr.close()
917 915
918 if self.branchcache: 916 if self._branchcache:
919 self.branchtags() 917 self.branchtags()
920 918
921 self.hook("commit", node=hex(n), parent1=xp1, parent2=xp2) 919 self.hook("commit", node=hex(n), parent1=xp1, parent2=xp2)
922 return n 920 return n
923 finally: 921 finally: