Show More
@@ -295,6 +295,18 b' class localrepository(repo.repository):' | |||
|
295 | 295 | |
|
296 | 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 | 310 | try: |
|
299 | 311 | f = self.opener("branches.cache") |
|
300 | 312 | last, lrev = f.readline().rstrip().split(" ", 1) |
@@ -303,33 +315,29 b' class localrepository(repo.repository):' | |||
|
303 | 315 | self.changelog.node(lrev) == last): # sanity check |
|
304 | 316 | for l in f: |
|
305 | 317 | node, label = l.rstrip().split(" ", 1) |
|
306 |
|
|
|
318 | partial[label] = bin(node) | |
|
307 | 319 | else: # invalidate the cache |
|
308 | 320 | last, lrev = nullid, -1 |
|
309 | 321 | f.close() |
|
310 | 322 | except IOError: |
|
311 | 323 | last, lrev = nullid, -1 |
|
324 | return partial, last, lrev | |
|
312 | 325 | |
|
313 | tip = self.changelog.count() - 1 | |
|
314 | if lrev != tip: | |
|
315 | for r in xrange(lrev + 1, tip + 1): | |
|
326 | def _writebranchcache(self, branches, tip, tiprev): | |
|
327 | try: | |
|
328 | f = self.opener("branches.cache", "w") | |
|
329 | f.write("%s %s\n" % (hex(tip), tiprev)) | |
|
330 | for label, node in branches.iteritems(): | |
|
331 | f.write("%s %s\n" % (hex(node), label)) | |
|
332 | except IOError: | |
|
333 | pass | |
|
334 | ||
|
335 | def _updatebranchcache(self, partial, start, end): | |
|
336 | for r in xrange(start, end): | |
|
316 | 337 |
|
|
317 | 338 |
|
|
318 | 339 |
|
|
319 |
|
|
|
320 | self._writebranchcache() | |
|
321 | ||
|
322 | return self.branchcache | |
|
323 | ||
|
324 | def _writebranchcache(self): | |
|
325 | try: | |
|
326 | f = self.opener("branches.cache", "w") | |
|
327 | t = self.changelog.tip() | |
|
328 | f.write("%s %s\n" % (hex(t), self.changelog.count() - 1)) | |
|
329 | for label, node in self.branchcache.iteritems(): | |
|
330 | f.write("%s %s\n" % (hex(node), label)) | |
|
331 | except IOError: | |
|
332 | pass | |
|
340 | partial[b] = c.node() | |
|
333 | 341 | |
|
334 | 342 | def lookup(self, key): |
|
335 | 343 | if key == '.': |
General Comments 0
You need to be logged in to leave comments.
Login now