comparison mercurial/localrepo.py @ 13272:5ccdca7df211

move tags.cache and branchheads.cache to a collected cache folder .hg/cache/ The generation of cache files like tags.cache and branchheads.cache is not an actual reflection of things changing in the whole of the .hg directory (like eg a commit or a rebase or something) but instead these cache files are just part of bookkeeping. As such its convienant to allow various clients to ignore file events to do with these cache files which would otherwise cause a double refresh. Eg one refresh might occur after a commit, but the act of refreshing after the commit would cause Mercurial to generate a new branchheads.cache which would then cause a second refresh, for clients. However if these cache files are moved into a directory like eg .hg/cache/ then GUI clients on OSX (and possibly other platforms) can happily ignore file events in this cache directory.
author jfh <jason@jasonfharris.com>
date Tue, 04 Jan 2011 06:29:08 +0100
parents 952baa2f3325
children dc11e30b48a3
comparison
equal deleted inserted replaced
13271:952baa2f3325 13272:5ccdca7df211
437 return bt 437 return bt
438 438
439 def _readbranchcache(self): 439 def _readbranchcache(self):
440 partial = {} 440 partial = {}
441 try: 441 try:
442 f = self.opener("branchheads.cache") 442 f = self.opener(os.path.join("cache", "branchheads"))
443 lines = f.read().split('\n') 443 lines = f.read().split('\n')
444 f.close() 444 f.close()
445 except (IOError, OSError): 445 except (IOError, OSError):
446 return {}, nullid, nullrev 446 return {}, nullid, nullrev
447 447
465 partial, last, lrev = {}, nullid, nullrev 465 partial, last, lrev = {}, nullid, nullrev
466 return partial, last, lrev 466 return partial, last, lrev
467 467
468 def _writebranchcache(self, branches, tip, tiprev): 468 def _writebranchcache(self, branches, tip, tiprev):
469 try: 469 try:
470 f = self.opener("branchheads.cache", "w", atomictemp=True) 470 f = self.opener(os.path.join("cache", "branchheads"), "w",
471 atomictemp=True)
471 f.write("%s %s\n" % (hex(tip), tiprev)) 472 f.write("%s %s\n" % (hex(tip), tiprev))
472 for label, nodes in branches.iteritems(): 473 for label, nodes in branches.iteritems():
473 for node in nodes: 474 for node in nodes:
474 f.write("%s %s\n" % (hex(node), encoding.fromlocal(label))) 475 f.write("%s %s\n" % (hex(node), encoding.fromlocal(label)))
475 f.rename() 476 f.rename()