# HG changeset patch # User Mads Kiilerich # Date 2015-01-14 00:15:26 # Node ID 7aa1405528a389e70aa23b0cbc5d677e1bb3c78a # Parent 01426cad66dc1fed88ac67f311923cf9fdc621e5 branchcache: add debug output whenever cache files use truncate The cache files are usually append only but will automatically be truncated and recover in exceptional situations. Add a debug notice when such exceptional situations are encountered. diff --git a/mercurial/branchmap.py b/mercurial/branchmap.py --- a/mercurial/branchmap.py +++ b/mercurial/branchmap.py @@ -414,6 +414,7 @@ class revbranchcache(object): f.write('\0') else: f.close() + repo.ui.debug("%s changed - rewriting it\n" % _rbcnames) self._rbcnamescount = 0 self._rbcrevslen = 0 if self._rbcnamescount == 0: @@ -438,6 +439,7 @@ class revbranchcache(object): # see issue3543. SEEK_END was added in 2.5 f.seek(0, 2) #os.SEEK_END if f.tell() != start: + repo.ui.debug("truncating %s to %s\n" % (_rbcrevs, start)) f.seek(start) f.truncate() end = self._rbcrevslen * _rbcrecsize diff --git a/tests/test-branches.t b/tests/test-branches.t --- a/tests/test-branches.t +++ b/tests/test-branches.t @@ -550,6 +550,7 @@ revision branch cache is created when bu recovery from invalid cache revs file with trailing data $ echo >> .hg/cache/rbc-revs-v1 $ rm -f .hg/cache/branch* && hg head a -T '{rev}\n' --debug + truncating cache/rbc-revs-v1 to 120 5 $ f --size .hg/cache/rbc-revs* .hg/cache/rbc-revs-v1: size=120 @@ -559,6 +560,7 @@ recovery from invalid cache file with pa $ f --size .hg/cache/rbc-revs* .hg/cache/rbc-revs-v1: size=119 $ rm -f .hg/cache/branch* && hg head a -T '{rev}\n' --debug + truncating cache/rbc-revs-v1 to 112 5 $ f --size .hg/cache/rbc-revs* .hg/cache/rbc-revs-v1: size=120 @@ -580,6 +582,7 @@ recovery from invalid cache file with so $ hg log -r 'branch(.)' -T '{rev} ' 3 4 8 9 10 11 12 13 (no-eol) $ rm -f .hg/cache/branch* && hg head a -T '{rev}\n' --debug + truncating cache/rbc-revs-v1 to 8 5 $ f --size --hexdump --bytes=16 .hg/cache/rbc-revs* .hg/cache/rbc-revs-v1: size=120 diff --git a/tests/test-rebase-conflicts.t b/tests/test-rebase-conflicts.t --- a/tests/test-rebase-conflicts.t +++ b/tests/test-rebase-conflicts.t @@ -322,5 +322,6 @@ Check that the right ancestors is used w files: 1/1 chunks (100.00%) added 2 changesets with 2 changes to 1 files invalid branchheads cache (served): tip differs + truncating cache/rbc-revs-v1 to 72 rebase completed updating the branch cache