##// END OF EJS Templates
Split branchtags into two additional functions....
Alexis S. L. Carvalho -
r3491:23cffef5 default
parent child Browse files
Show More
@@ -295,6 +295,18 b' class localrepository(repo.repository):'
295
295
296 self.branchcache = {} # avoid recursion in changectx
296 self.branchcache = {} # avoid recursion in changectx
297
297
298 partial, last, lrev = self._readbranchcache()
299
300 tiprev = self.changelog.count() - 1
301 if lrev != tiprev:
302 self._updatebranchcache(partial, lrev+1, tiprev+1)
303 self._writebranchcache(partial, self.changelog.tip(), tiprev)
304
305 self.branchcache = partial
306 return self.branchcache
307
308 def _readbranchcache(self):
309 partial = {}
298 try:
310 try:
299 f = self.opener("branches.cache")
311 f = self.opener("branches.cache")
300 last, lrev = f.readline().rstrip().split(" ", 1)
312 last, lrev = f.readline().rstrip().split(" ", 1)
@@ -303,34 +315,30 b' class localrepository(repo.repository):'
303 self.changelog.node(lrev) == last): # sanity check
315 self.changelog.node(lrev) == last): # sanity check
304 for l in f:
316 for l in f:
305 node, label = l.rstrip().split(" ", 1)
317 node, label = l.rstrip().split(" ", 1)
306 self.branchcache[label] = bin(node)
318 partial[label] = bin(node)
307 else: # invalidate the cache
319 else: # invalidate the cache
308 last, lrev = nullid, -1
320 last, lrev = nullid, -1
309 f.close()
321 f.close()
310 except IOError:
322 except IOError:
311 last, lrev = nullid, -1
323 last, lrev = nullid, -1
324 return partial, last, lrev
312
325
313 tip = self.changelog.count() - 1
326 def _writebranchcache(self, branches, tip, tiprev):
314 if lrev != tip:
315 for r in xrange(lrev + 1, tip + 1):
316 c = self.changectx(r)
317 b = c.branch()
318 if b:
319 self.branchcache[b] = c.node()
320 self._writebranchcache()
321
322 return self.branchcache
323
324 def _writebranchcache(self):
325 try:
327 try:
326 f = self.opener("branches.cache", "w")
328 f = self.opener("branches.cache", "w")
327 t = self.changelog.tip()
329 f.write("%s %s\n" % (hex(tip), tiprev))
328 f.write("%s %s\n" % (hex(t), self.changelog.count() - 1))
330 for label, node in branches.iteritems():
329 for label, node in self.branchcache.iteritems():
330 f.write("%s %s\n" % (hex(node), label))
331 f.write("%s %s\n" % (hex(node), label))
331 except IOError:
332 except IOError:
332 pass
333 pass
333
334
335 def _updatebranchcache(self, partial, start, end):
336 for r in xrange(start, end):
337 c = self.changectx(r)
338 b = c.branch()
339 if b:
340 partial[b] = c.node()
341
334 def lookup(self, key):
342 def lookup(self, key):
335 if key == '.':
343 if key == '.':
336 key = self.dirstate.parents()[0]
344 key = self.dirstate.parents()[0]
General Comments 0
You need to be logged in to leave comments. Login now