Show More
@@ -146,6 +146,7 class revbranchcache: | |||||
146 | self._names = [] # branch names in local encoding with static index |
|
146 | self._names = [] # branch names in local encoding with static index | |
147 | self._rbcrevs = rbcrevs(bytearray()) |
|
147 | self._rbcrevs = rbcrevs(bytearray()) | |
148 | self._rbcsnameslen = 0 # length of names read at _rbcsnameslen |
|
148 | self._rbcsnameslen = 0 # length of names read at _rbcsnameslen | |
|
149 | self._force_overwrite = False | |||
149 | v1_fallback = False |
|
150 | v1_fallback = False | |
150 | try: |
|
151 | try: | |
151 | try: |
|
152 | try: | |
@@ -157,6 +158,7 class revbranchcache: | |||||
157 | # consider stop doing this many version after hg-6.9 release |
|
158 | # consider stop doing this many version after hg-6.9 release | |
158 | bndata = repo.cachevfs.read(_rbc_legacy_names) |
|
159 | bndata = repo.cachevfs.read(_rbc_legacy_names) | |
159 | v1_fallback = True |
|
160 | v1_fallback = True | |
|
161 | self._force_overwrite = True | |||
160 | self._rbcsnameslen = len(bndata) # for verification before writing |
|
162 | self._rbcsnameslen = len(bndata) # for verification before writing | |
161 | if bndata: |
|
163 | if bndata: | |
162 | self._names = [ |
|
164 | self._names = [ | |
@@ -198,7 +200,6 class revbranchcache: | |||||
198 | self._names = [] |
|
200 | self._names = [] | |
199 | self._rbcnamescount = len(self._names) # number of names read at |
|
201 | self._rbcnamescount = len(self._names) # number of names read at | |
200 | # _rbcsnameslen |
|
202 | # _rbcsnameslen | |
201 | self._force_overwrite = False |
|
|||
202 |
|
203 | |||
203 | def _clear(self): |
|
204 | def _clear(self): | |
204 | self._rbcsnameslen = 0 |
|
205 | self._rbcsnameslen = 0 | |
@@ -320,7 +321,7 class revbranchcache: | |||||
320 | step = b'' |
|
321 | step = b'' | |
321 | try: |
|
322 | try: | |
322 | # write the new names |
|
323 | # write the new names | |
323 | if self._rbcnamescount < len(self._names): |
|
324 | if self._force_overwrite or self._rbcnamescount < len(self._names): | |
324 | wlock = repo.wlock(wait=False) |
|
325 | wlock = repo.wlock(wait=False) | |
325 | step = b' names' |
|
326 | step = b' names' | |
326 | self._writenames(repo) |
|
327 | self._writenames(repo) | |
@@ -345,15 +346,24 class revbranchcache: | |||||
345 | def _writenames(self, repo): |
|
346 | def _writenames(self, repo): | |
346 | """write the new branch names to revbranchcache""" |
|
347 | """write the new branch names to revbranchcache""" | |
347 | f = None |
|
348 | f = None | |
|
349 | if self._force_overwrite: | |||
|
350 | self._rbcsnameslen = 0 | |||
|
351 | self._rbcnamescount = 0 | |||
348 | try: |
|
352 | try: | |
349 | if self._rbcnamescount != 0: |
|
353 | if self._force_overwrite or self._rbcnamescount != 0: | |
350 | f = repo.cachevfs.open(_rbcnames, b'ab') |
|
354 | f = repo.cachevfs.open(_rbcnames, b'ab') | |
351 | if f.tell() == self._rbcsnameslen: |
|
355 | current_size = f.tell() | |
|
356 | if current_size == self._rbcsnameslen: | |||
352 | f.write(b'\0') |
|
357 | f.write(b'\0') | |
353 | else: |
|
358 | else: | |
354 | f.close() |
|
359 | f.close() | |
355 |
f |
|
360 | if self._force_overwrite: | |
356 | repo.ui.debug(b"%s changed - rewriting it\n" % _rbcnames) |
|
361 | dbg = b"resetting content of %s\n" | |
|
362 | elif current_size > 0: | |||
|
363 | dbg = b"%s changed - rewriting it\n" | |||
|
364 | else: | |||
|
365 | dbg = b"%s is missing - rewriting it\n" | |||
|
366 | repo.ui.debug(dbg % _rbcnames) | |||
357 | self._rbcnamescount = 0 |
|
367 | self._rbcnamescount = 0 | |
358 | self._rbcrevslen = 0 |
|
368 | self._rbcrevslen = 0 | |
359 | if self._rbcnamescount == 0: |
|
369 | if self._rbcnamescount == 0: |
@@ -880,8 +880,8 recovery from invalid cache file with so | |||||
880 | Smoothly reuse "v1" format if no v2 exists |
|
880 | Smoothly reuse "v1" format if no v2 exists | |
881 | ------------------------------------------ |
|
881 | ------------------------------------------ | |
882 |
|
882 | |||
883 |
read only operation with valid data |
|
883 | read only operation with valid data | |
884 | (does not need to rewrite anything, maybe we should force it?) |
|
884 | (actively rewrite data) | |
885 |
|
885 | |||
886 | $ rm .hg/cache/rbc-names-v2 |
|
886 | $ rm .hg/cache/rbc-names-v2 | |
887 | $ rm .hg/cache/rbc-revs-v2 |
|
887 | $ rm .hg/cache/rbc-revs-v2 | |
@@ -895,17 +895,23 read only operation with valid data( | |||||
895 | 5 |
|
895 | 5 | |
896 | $ f --size .hg/cache/rbc-*-* |
|
896 | $ f --size .hg/cache/rbc-*-* | |
897 | .hg/cache/rbc-names-v1: size=92 |
|
897 | .hg/cache/rbc-names-v1: size=92 | |
|
898 | .hg/cache/rbc-names-v2: size=92 | |||
898 | .hg/cache/rbc-revs-v1: size=160 |
|
899 | .hg/cache/rbc-revs-v1: size=160 | |
|
900 | .hg/cache/rbc-revs-v2: size=160 | |||
899 |
|
901 | |||
900 |
|
902 | |||
901 | Write operation write a full v2 files |
|
903 | Write operation write a full v2 files | |
902 |
|
904 | |||
|
905 | $ mv .hg/cache/rbc-names-v2 .hg/cache/rbc-names-v1 | |||
|
906 | $ mv .hg/cache/rbc-revs-v2 .hg/cache/rbc-revs-v1 | |||
|
907 | $ f --size .hg/cache/rbc-* | |||
|
908 | .hg/cache/rbc-names-v1: size=92 | |||
|
909 | .hg/cache/rbc-revs-v1: size=160 | |||
903 | $ hg branch not-here-for-long |
|
910 | $ hg branch not-here-for-long | |
904 | marked working directory as branch not-here-for-long |
|
911 | marked working directory as branch not-here-for-long | |
905 | $ hg ci -m not-long --debug |
|
912 | $ hg ci -m not-long --debug | |
906 | reusing manifest from p1 (no file change) |
|
913 | reusing manifest from p1 (no file change) | |
907 | committing changelog |
|
914 | committing changelog | |
908 | rbc-names-v2 changed - rewriting it |
|
|||
909 | updating the branch cache |
|
915 | updating the branch cache | |
910 | committed changeset * (glob) |
|
916 | committed changeset * (glob) | |
911 | $ f --size .hg/cache/rbc-* |
|
917 | $ f --size .hg/cache/rbc-* | |
@@ -927,6 +933,7 With invalid v1 data, we rewrite it too | |||||
927 | 5 |
|
933 | 5 | |
928 | $ f --size .hg/cache/rbc-*-* |
|
934 | $ f --size .hg/cache/rbc-*-* | |
929 | .hg/cache/rbc-names-v1: size=110 |
|
935 | .hg/cache/rbc-names-v1: size=110 | |
|
936 | .hg/cache/rbc-names-v2: size=110 | |||
930 | .hg/cache/rbc-revs-v1: size=110 |
|
937 | .hg/cache/rbc-revs-v1: size=110 | |
931 | .hg/cache/rbc-revs-v2: size=168 |
|
938 | .hg/cache/rbc-revs-v2: size=168 | |
932 |
|
939 | |||
@@ -968,7 +975,7 cache is rebuilt when corruption is dete | |||||
968 | $ echo > .hg/cache/rbc-names-v2 |
|
975 | $ echo > .hg/cache/rbc-names-v2 | |
969 | $ hg log -r '5:&branch(.)' -T '{rev} ' --debug |
|
976 | $ hg log -r '5:&branch(.)' -T '{rev} ' --debug | |
970 | referenced branch names not found - rebuilding revision branch cache from scratch |
|
977 | referenced branch names not found - rebuilding revision branch cache from scratch | |
971 | 8 9 10 11 12 13 (no-eol) |
|
978 | 8 9 10 11 12 13 resetting content of rbc-names-v2 | |
972 | $ f --size .hg/cache/rbc-names-* |
|
979 | $ f --size .hg/cache/rbc-names-* | |
973 | .hg/cache/rbc-names-v2: size=84 |
|
980 | .hg/cache/rbc-names-v2: size=84 | |
974 | $ grep "i-will-regret-this" .hg/cache/rbc-names-* > /dev/null |
|
981 | $ grep "i-will-regret-this" .hg/cache/rbc-names-* > /dev/null |
@@ -319,7 +319,7 Check that the right ancestors is used w | |||||
319 | bundle2-input-part: "phase-heads" supported |
|
319 | bundle2-input-part: "phase-heads" supported | |
320 | bundle2-input-part: total payload size 24 |
|
320 | bundle2-input-part: total payload size 24 | |
321 | bundle2-input-bundle: 3 parts total |
|
321 | bundle2-input-bundle: 3 parts total | |
322 |
resetting content of |
|
322 | resetting content of rbc-names-v2 | |
323 | added 2 changesets with 2 changes to 1 files |
|
323 | added 2 changesets with 2 changes to 1 files | |
324 | updating the branch cache |
|
324 | updating the branch cache | |
325 | invalid branch cache (served): tip differs |
|
325 | invalid branch cache (served): tip differs |
@@ -913,7 +913,7 check strip behavior | |||||
913 | saved backup bundle to $TESTTMP/issue4736/.hg/strip-backup/6625a5168474-345bb43d-backup.hg |
|
913 | saved backup bundle to $TESTTMP/issue4736/.hg/strip-backup/6625a5168474-345bb43d-backup.hg | |
914 | updating the branch cache |
|
914 | updating the branch cache | |
915 | invalid branch cache (served): tip differs |
|
915 | invalid branch cache (served): tip differs | |
916 |
resetting content of |
|
916 | resetting content of rbc-names-v2 | |
917 | $ hg log -G |
|
917 | $ hg log -G | |
918 | o changeset: 2:5c51d8d6557d |
|
918 | o changeset: 2:5c51d8d6557d | |
919 | | tag: tip |
|
919 | | tag: tip |
General Comments 0
You need to be logged in to leave comments.
Login now