Show More
@@ -397,11 +397,15 class revbranchcache: | |||||
397 | start = 0 |
|
397 | start = 0 | |
398 | if current_size != start: |
|
398 | if current_size != start: | |
399 | threshold = current_size * REWRITE_RATIO |
|
399 | threshold = current_size * REWRITE_RATIO | |
400 |
|
|
400 | overwritten = min(end, current_size) - start | |
401 | # end affected, let overwrite the bad value |
|
401 | if (max(end, current_size) - start) >= threshold: | |
402 | overwritten = min(end, current_size) - start |
|
402 | start = 0 | |
|
403 | dbg = b"resetting content of cache/%s\n" % _rbcrevs | |||
|
404 | repo.ui.debug(dbg) | |||
|
405 | elif overwritten > 0: | |||
|
406 | # end affected, let us overwrite the bad value | |||
403 | dbg = b"overwriting %d bytes from %d in cache/%s" |
|
407 | dbg = b"overwriting %d bytes from %d in cache/%s" | |
404 |
dbg %= ( |
|
408 | dbg %= (current_size - start, start, _rbcrevs) | |
405 | if end < current_size: |
|
409 | if end < current_size: | |
406 | extra = b" leaving (%d trailing bytes)" |
|
410 | extra = b" leaving (%d trailing bytes)" | |
407 | extra %= current_size - end |
|
411 | extra %= current_size - end | |
@@ -409,9 +413,12 class revbranchcache: | |||||
409 | dbg += b'\n' |
|
413 | dbg += b'\n' | |
410 | repo.ui.debug(dbg) |
|
414 | repo.ui.debug(dbg) | |
411 | else: |
|
415 | else: | |
412 | start = 0 |
|
416 | # extra untouched data at the end, lets warn about them | |
413 | dbg = b"resetting content of cache/%s\n" % _rbcrevs |
|
417 | assert start == end # since don't write anything | |
|
418 | dbg = b"cache/%s contains %d unknown trailing bytes\n" | |||
|
419 | dbg %= (_rbcrevs, current_size - start) | |||
414 | repo.ui.debug(dbg) |
|
420 | repo.ui.debug(dbg) | |
|
421 | ||||
415 | if start > 0: |
|
422 | if start > 0: | |
416 | f.seek(start) |
|
423 | f.seek(start) | |
417 | f.write(self._rbcrevs.slice(start, end)) |
|
424 | f.write(self._rbcrevs.slice(start, end)) |
@@ -835,7 +835,7 recovery from invalid cache revs file wi | |||||
835 | $ echo >> .hg/cache/rbc-revs-v2 |
|
835 | $ echo >> .hg/cache/rbc-revs-v2 | |
836 | $ rm -f .hg/cache/branch* && hg head a -T '{rev}\n' --debug |
|
836 | $ rm -f .hg/cache/branch* && hg head a -T '{rev}\n' --debug | |
837 | 5 |
|
837 | 5 | |
838 |
|
|
838 | cache/rbc-revs-v2 contains 2 unknown trailing bytes | |
839 | $ f --size .hg/cache/rbc-revs* |
|
839 | $ f --size .hg/cache/rbc-revs* | |
840 | .hg/cache/rbc-revs-v2: size=162 |
|
840 | .hg/cache/rbc-revs-v2: size=162 | |
841 |
|
841 |
General Comments 0
You need to be logged in to leave comments.
Login now