##// END OF EJS Templates
rbc: fix superfluous rebuilding from scratch - don't abuse self._rbcnamescount...
Mads Kiilerich -
r29615:a2a380e2 stable
parent child Browse files
Show More
@@ -358,7 +358,7 b' class revbranchcache(object):'
358 self._repo = repo
358 self._repo = repo
359 self._names = [] # branch names in local encoding with static index
359 self._names = [] # branch names in local encoding with static index
360 self._rbcrevs = array('c') # structs of type _rbcrecfmt
360 self._rbcrevs = array('c') # structs of type _rbcrecfmt
361 self._rbcsnameslen = 0
361 self._rbcsnameslen = 0 # length of names read at _rbcsnameslen
362 try:
362 try:
363 bndata = repo.vfs.read(_rbcnames)
363 bndata = repo.vfs.read(_rbcnames)
364 self._rbcsnameslen = len(bndata) # for verification before writing
364 self._rbcsnameslen = len(bndata) # for verification before writing
@@ -380,7 +380,8 b' class revbranchcache(object):'
380 len(repo.changelog))
380 len(repo.changelog))
381 if self._rbcrevslen == 0:
381 if self._rbcrevslen == 0:
382 self._names = []
382 self._names = []
383 self._rbcnamescount = len(self._names) # number of good names on disk
383 self._rbcnamescount = len(self._names) # number of names read at
384 # _rbcsnameslen
384 self._namesreverse = dict((b, r) for r, b in enumerate(self._names))
385 self._namesreverse = dict((b, r) for r, b in enumerate(self._names))
385
386
386 def _clear(self):
387 def _clear(self):
@@ -416,13 +417,17 b' class revbranchcache(object):'
416 if cachenode == '\0\0\0\0':
417 if cachenode == '\0\0\0\0':
417 pass
418 pass
418 elif cachenode == reponode:
419 elif cachenode == reponode:
419 if branchidx < self._rbcnamescount:
420 try:
420 return self._names[branchidx], close
421 return self._names[branchidx], close
421 # referenced branch doesn't exist - rebuild is expensive but needed
422 except IndexError:
422 self._repo.ui.debug("rebuilding corrupted revision branch cache\n")
423 # recover from invalid reference to unknown branch
424 self._repo.ui.debug("referenced branch names not found"
425 " - rebuilding revision branch cache from scratch\n")
423 self._clear()
426 self._clear()
424 else:
427 else:
425 # rev/node map has changed, invalidate the cache from here up
428 # rev/node map has changed, invalidate the cache from here up
429 self._repo.ui.debug("history modification detected - truncating "
430 "revision branch cache to revision %s\n" % rev)
426 truncate = rbcrevidx + _rbcrecsize
431 truncate = rbcrevidx + _rbcrecsize
427 del self._rbcrevs[truncate:]
432 del self._rbcrevs[truncate:]
428 self._rbcrevslen = min(self._rbcrevslen, truncate)
433 self._rbcrevslen = min(self._rbcrevslen, truncate)
@@ -587,6 +587,8 b' recovery from invalid cache file with so'
587 $ f --size .hg/cache/rbc-revs*
587 $ f --size .hg/cache/rbc-revs*
588 .hg/cache/rbc-revs-v1: size=120
588 .hg/cache/rbc-revs-v1: size=120
589 $ hg log -r 'branch(.)' -T '{rev} ' --debug
589 $ hg log -r 'branch(.)' -T '{rev} ' --debug
590 history modification detected - truncating revision branch cache to revision 13
591 history modification detected - truncating revision branch cache to revision 1
590 3 4 8 9 10 11 12 13 truncating cache/rbc-revs-v1 to 8
592 3 4 8 9 10 11 12 13 truncating cache/rbc-revs-v1 to 8
591 $ rm -f .hg/cache/branch* && hg head a -T '{rev}\n' --debug
593 $ rm -f .hg/cache/branch* && hg head a -T '{rev}\n' --debug
592 5
594 5
@@ -632,7 +634,7 b' situation where the cache is out of sync'
632 cache is rebuilt when corruption is detected
634 cache is rebuilt when corruption is detected
633 $ echo > .hg/cache/rbc-names-v1
635 $ echo > .hg/cache/rbc-names-v1
634 $ hg log -r '5:&branch(.)' -T '{rev} ' --debug
636 $ hg log -r '5:&branch(.)' -T '{rev} ' --debug
635 rebuilding corrupted revision branch cache
637 referenced branch names not found - rebuilding revision branch cache from scratch
636 8 9 10 11 12 13 truncating cache/rbc-revs-v1 to 40
638 8 9 10 11 12 13 truncating cache/rbc-revs-v1 to 40
637 $ f --size --hexdump .hg/cache/rbc-*
639 $ f --size --hexdump .hg/cache/rbc-*
638 .hg/cache/rbc-names-v1: size=79
640 .hg/cache/rbc-names-v1: size=79
@@ -688,16 +690,13 b' Test for multiple incorrect branch cache'
688 0010: 56 46 78 69 00 00 00 01 |VFxi....|
690 0010: 56 46 78 69 00 00 00 01 |VFxi....|
689 $ : > .hg/cache/rbc-revs-v1
691 $ : > .hg/cache/rbc-revs-v1
690
692
693 No superfluous rebuilding of cache:
691 $ hg log -r "branch(null)&branch(branch)" --debug
694 $ hg log -r "branch(null)&branch(branch)" --debug
692 rebuilding corrupted revision branch cache
693 rebuilding corrupted revision branch cache
694 truncating cache/rbc-revs-v1 to 8
695 BUG: the cache was declared corrupt multiple times and not fully rebuilt:
696 $ f --size --hexdump .hg/cache/rbc-*
695 $ f --size --hexdump .hg/cache/rbc-*
697 .hg/cache/rbc-names-v1: size=14
696 .hg/cache/rbc-names-v1: size=14
698 0000: 64 65 66 61 75 6c 74 00 62 72 61 6e 63 68 |default.branch|
697 0000: 64 65 66 61 75 6c 74 00 62 72 61 6e 63 68 |default.branch|
699 .hg/cache/rbc-revs-v1: size=24
698 .hg/cache/rbc-revs-v1: size=24
700 0000: 00 00 00 00 00 00 00 00 fa 4c 04 e5 00 00 00 00 |.........L......|
699 0000: 66 e5 f5 aa 00 00 00 00 fa 4c 04 e5 00 00 00 00 |f........L......|
701 0010: 56 46 78 69 00 00 00 01 |VFxi....|
700 0010: 56 46 78 69 00 00 00 01 |VFxi....|
702
701
703 $ cd ..
702 $ cd ..
@@ -302,6 +302,7 b' Check that the right ancestors is used w'
302 bundle2-input-part: total payload size 1713
302 bundle2-input-part: total payload size 1713
303 bundle2-input-bundle: 0 parts total
303 bundle2-input-bundle: 0 parts total
304 invalid branchheads cache (served): tip differs
304 invalid branchheads cache (served): tip differs
305 history modification detected - truncating revision branch cache to revision 9
305 rebase completed
306 rebase completed
306 updating the branch cache
307 updating the branch cache
307 truncating cache/rbc-revs-v1 to 72
308 truncating cache/rbc-revs-v1 to 72
General Comments 0
You need to be logged in to leave comments. Login now