Show More
@@ -33,6 +33,9 unpack_from = struct.unpack_from | |||||
33 | _rbcversion = b'-v2' |
|
33 | _rbcversion = b'-v2' | |
34 | _rbcnames = b'rbc-names' + _rbcversion |
|
34 | _rbcnames = b'rbc-names' + _rbcversion | |
35 | _rbcrevs = b'rbc-revs' + _rbcversion |
|
35 | _rbcrevs = b'rbc-revs' + _rbcversion | |
|
36 | _rbc_legacy_version = b'-v1' | |||
|
37 | _rbc_legacy_names = b'rbc-names' + _rbc_legacy_version | |||
|
38 | _rbc_legacy_revs = b'rbc-revs' + _rbc_legacy_version | |||
36 | # [4 byte hash prefix][4 byte branch name number with sign bit indicating open] |
|
39 | # [4 byte hash prefix][4 byte branch name number with sign bit indicating open] | |
37 | _rbcrecfmt = b'>4sI' |
|
40 | _rbcrecfmt = b'>4sI' | |
38 | _rbcrecsize = calcsize(_rbcrecfmt) |
|
41 | _rbcrecsize = calcsize(_rbcrecfmt) | |
@@ -143,8 +146,17 class revbranchcache: | |||||
143 | self._names = [] # branch names in local encoding with static index |
|
146 | self._names = [] # branch names in local encoding with static index | |
144 | self._rbcrevs = rbcrevs(bytearray()) |
|
147 | self._rbcrevs = rbcrevs(bytearray()) | |
145 | self._rbcsnameslen = 0 # length of names read at _rbcsnameslen |
|
148 | self._rbcsnameslen = 0 # length of names read at _rbcsnameslen | |
|
149 | v1_fallback = False | |||
146 | try: |
|
150 | try: | |
147 | bndata = repo.cachevfs.read(_rbcnames) |
|
151 | try: | |
|
152 | bndata = repo.cachevfs.read(_rbcnames) | |||
|
153 | except (IOError, OSError): | |||
|
154 | # If we don't have "v2" data, we might have "v1" data worth | |||
|
155 | # using. | |||
|
156 | # | |||
|
157 | # consider stop doing this many version after hg-6.9 release | |||
|
158 | bndata = repo.cachevfs.read(_rbc_legacy_names) | |||
|
159 | v1_fallback = True | |||
148 | self._rbcsnameslen = len(bndata) # for verification before writing |
|
160 | self._rbcsnameslen = len(bndata) # for verification before writing | |
149 | if bndata: |
|
161 | if bndata: | |
150 | self._names = [ |
|
162 | self._names = [ | |
@@ -158,10 +170,19 class revbranchcache: | |||||
158 | if self._names: |
|
170 | if self._names: | |
159 | try: |
|
171 | try: | |
160 | usemmap = repo.ui.configbool(b'storage', b'revbranchcache.mmap') |
|
172 | usemmap = repo.ui.configbool(b'storage', b'revbranchcache.mmap') | |
161 | with repo.cachevfs(_rbcrevs) as fp: |
|
173 | if not v1_fallback: | |
162 |
|
|
174 | with repo.cachevfs(_rbcrevs) as fp: | |
163 | data = util.buffer(util.mmapread(fp)) |
|
175 | if usemmap and repo.cachevfs.is_mmap_safe(_rbcrevs): | |
164 | else: |
|
176 | data = util.buffer(util.mmapread(fp)) | |
|
177 | else: | |||
|
178 | data = fp.read() | |||
|
179 | else: | |||
|
180 | # If we don't have "v2" data, we might have "v1" data worth | |||
|
181 | # using. | |||
|
182 | # | |||
|
183 | # Consider stop doing this many version after hg-6.9 | |||
|
184 | # release. | |||
|
185 | with repo.cachevfs(_rbc_legacy_revs) as fp: | |||
165 | data = fp.read() |
|
186 | data = fp.read() | |
166 | self._rbcrevs = rbcrevs(data) |
|
187 | self._rbcrevs = rbcrevs(data) | |
167 | except (IOError, OSError) as inst: |
|
188 | except (IOError, OSError) as inst: |
@@ -877,6 +877,69 recovery from invalid cache file with so | |||||
877 | .hg/cache/rbc-revs-v2: size=160 |
|
877 | .hg/cache/rbc-revs-v2: size=160 | |
878 | 0000: 19 70 9c 5a 00 00 00 00 dd 6b 44 0d 00 00 00 01 |.p.Z.....kD.....| |
|
878 | 0000: 19 70 9c 5a 00 00 00 00 dd 6b 44 0d 00 00 00 01 |.p.Z.....kD.....| | |
879 |
|
879 | |||
|
880 | Smoothly reuse "v1" format if no v2 exists | |||
|
881 | ------------------------------------------ | |||
|
882 | ||||
|
883 | read only operation with valid data( | |||
|
884 | (does not need to rewrite anything, maybe we should force it?) | |||
|
885 | ||||
|
886 | $ rm .hg/cache/rbc-names-v2 | |||
|
887 | $ rm .hg/cache/rbc-revs-v2 | |||
|
888 | $ rm .hg/cache/branch* | |||
|
889 | $ hg head a -T '{rev}\n' --debug | |||
|
890 | 5 | |||
|
891 | $ mv .hg/cache/rbc-names-v2 .hg/cache/rbc-names-v1 | |||
|
892 | $ mv .hg/cache/rbc-revs-v2 .hg/cache/rbc-revs-v1 | |||
|
893 | $ rm .hg/cache/branch* | |||
|
894 | $ hg head a -T '{rev}\n' --debug | |||
|
895 | 5 | |||
|
896 | $ f --size .hg/cache/rbc-*-* | |||
|
897 | .hg/cache/rbc-names-v1: size=92 | |||
|
898 | .hg/cache/rbc-revs-v1: size=160 | |||
|
899 | ||||
|
900 | ||||
|
901 | Write operation write a full v2 files | |||
|
902 | ||||
|
903 | $ hg branch not-here-for-long | |||
|
904 | marked working directory as branch not-here-for-long | |||
|
905 | $ hg ci -m not-long --debug | |||
|
906 | reusing manifest from p1 (no file change) | |||
|
907 | committing changelog | |||
|
908 | rbc-names-v2 changed - rewriting it | |||
|
909 | updating the branch cache | |||
|
910 | committed changeset * (glob) | |||
|
911 | $ f --size .hg/cache/rbc-* | |||
|
912 | .hg/cache/rbc-names-v1: size=92 | |||
|
913 | .hg/cache/rbc-names-v2: size=110 | |||
|
914 | .hg/cache/rbc-revs-v1: size=160 | |||
|
915 | .hg/cache/rbc-revs-v2: size=168 | |||
|
916 | ||||
|
917 | ||||
|
918 | With invalid v1 data, we rewrite it too (as v2) | |||
|
919 | ||||
|
920 | $ cp .hg/cache/rbc-names-v2 .hg/cache/rbc-names-v1 | |||
|
921 | $ mv .hg/cache/rbc-names-v2 .hg/cache/rbc-revs-v1 | |||
|
922 | $ rm .hg/cache/rbc-revs-v2 | |||
|
923 | $ rm .hg/cache/branch* | |||
|
924 | $ | |||
|
925 | $ hg head a -T '{rev}\n' --debug | |||
|
926 | history modification detected - truncating revision branch cache to revision 0 | |||
|
927 | 5 | |||
|
928 | $ f --size .hg/cache/rbc-*-* | |||
|
929 | .hg/cache/rbc-names-v1: size=110 | |||
|
930 | .hg/cache/rbc-revs-v1: size=110 | |||
|
931 | .hg/cache/rbc-revs-v2: size=168 | |||
|
932 | ||||
|
933 | cleanup | |||
|
934 | ||||
|
935 | $ hg up -qr '.^' | |||
|
936 | $ hg rollback -qf | |||
|
937 | $ rm .hg/cache/* | |||
|
938 | $ hg debugupdatecache | |||
|
939 | $ f --size .hg/cache/rbc-* | |||
|
940 | .hg/cache/rbc-names-v2: size=92 | |||
|
941 | .hg/cache/rbc-revs-v2: size=160 | |||
|
942 | ||||
880 | cache is updated when committing |
|
943 | cache is updated when committing | |
881 | $ hg branch i-will-regret-this |
|
944 | $ hg branch i-will-regret-this | |
882 | marked working directory as branch i-will-regret-this |
|
945 | marked working directory as branch i-will-regret-this |
@@ -267,6 +267,7 List of files accessed over HTTP: | |||||
267 | /remote/.hg/cache/branch2-immutable |
|
267 | /remote/.hg/cache/branch2-immutable | |
268 | /remote/.hg/cache/branch2-served |
|
268 | /remote/.hg/cache/branch2-served | |
269 | /remote/.hg/cache/hgtagsfnodes1 |
|
269 | /remote/.hg/cache/hgtagsfnodes1 | |
|
270 | /remote/.hg/cache/rbc-names-v1 | |||
270 | /remote/.hg/cache/rbc-names-v2 |
|
271 | /remote/.hg/cache/rbc-names-v2 | |
271 | /remote/.hg/cache/tags2-served |
|
272 | /remote/.hg/cache/tags2-served | |
272 | /remote/.hg/dirstate |
|
273 | /remote/.hg/dirstate |
General Comments 0
You need to be logged in to leave comments.
Login now