Show More
@@ -62,6 +62,7 b' class BranchMapCache:' | |||||
62 | def __getitem__(self, repo): |
|
62 | def __getitem__(self, repo): | |
63 | self.updatecache(repo) |
|
63 | self.updatecache(repo) | |
64 | bcache = self._per_filter[repo.filtername] |
|
64 | bcache = self._per_filter[repo.filtername] | |
|
65 | bcache._ensure_populated(repo) | |||
65 | assert bcache._filtername == repo.filtername, ( |
|
66 | assert bcache._filtername == repo.filtername, ( | |
66 | bcache._filtername, |
|
67 | bcache._filtername, | |
67 | repo.filtername, |
|
68 | repo.filtername, | |
@@ -484,6 +485,9 b' class _LocalBranchCache(_BaseBranchCache' | |||||
484 | def _compute_key_hashes(self, repo) -> Tuple[bytes]: |
|
485 | def _compute_key_hashes(self, repo) -> Tuple[bytes]: | |
485 | raise NotImplementedError |
|
486 | raise NotImplementedError | |
486 |
|
487 | |||
|
488 | def _ensure_populated(self, repo): | |||
|
489 | """make sure any lazily loaded values are fully populated""" | |||
|
490 | ||||
487 | def validfor(self, repo): |
|
491 | def validfor(self, repo): | |
488 | """check that cache contents are valid for (a subset of) this repo |
|
492 | """check that cache contents are valid for (a subset of) this repo | |
489 |
|
493 | |||
@@ -861,7 +865,18 b' class BranchCacheV3(_LocalBranchCache):' | |||||
861 | _base_filename = b"branch3" |
|
865 | _base_filename = b"branch3" | |
862 | _default_key_hashes = (None, None) |
|
866 | _default_key_hashes = (None, None) | |
863 |
|
867 | |||
864 | def _get_topo_heads(self, repo) -> List[int]: |
|
868 | def __init__(self, *args, pure_topo_branch=None, **kwargs): | |
|
869 | super().__init__(*args, **kwargs) | |||
|
870 | self._pure_topo_branch = pure_topo_branch | |||
|
871 | self._needs_populate = self._pure_topo_branch is not None | |||
|
872 | ||||
|
873 | def inherit_for(self, repo): | |||
|
874 | new = super().inherit_for(repo) | |||
|
875 | new._pure_topo_branch = self._pure_topo_branch | |||
|
876 | new._needs_populate = self._needs_populate | |||
|
877 | return new | |||
|
878 | ||||
|
879 | def _get_topo_heads(self, repo): | |||
865 | """returns the topological head of a repoview content up to self.tiprev""" |
|
880 | """returns the topological head of a repoview content up to self.tiprev""" | |
866 | cl = repo.changelog |
|
881 | cl = repo.changelog | |
867 | if self.tiprev == nullrev: |
|
882 | if self.tiprev == nullrev: | |
@@ -883,19 +898,30 b' class BranchCacheV3(_LocalBranchCache):' | |||||
883 | cache_keys[b"filtered-hash"] = hex(self.key_hashes[0]) |
|
898 | cache_keys[b"filtered-hash"] = hex(self.key_hashes[0]) | |
884 | if self.key_hashes[1] is not None: |
|
899 | if self.key_hashes[1] is not None: | |
885 | cache_keys[b"obsolete-hash"] = hex(self.key_hashes[1]) |
|
900 | cache_keys[b"obsolete-hash"] = hex(self.key_hashes[1]) | |
|
901 | if self._pure_topo_branch is not None: | |||
|
902 | cache_keys[b"topo-mode"] = b"pure" | |||
886 | pieces = (b"%s=%s" % i for i in sorted(cache_keys.items())) |
|
903 | pieces = (b"%s=%s" % i for i in sorted(cache_keys.items())) | |
887 | fp.write(b" ".join(pieces) + b'\n') |
|
904 | fp.write(b" ".join(pieces) + b'\n') | |
|
905 | if self._pure_topo_branch is not None: | |||
|
906 | label = encoding.fromlocal(self._pure_topo_branch) | |||
|
907 | fp.write(label + b'\n') | |||
888 |
|
908 | |||
889 | def _write_heads(self, repo, fp) -> int: |
|
909 | def _write_heads(self, repo, fp) -> int: | |
890 | """write list of heads to a file |
|
910 | """write list of heads to a file | |
891 |
|
911 | |||
892 | Return the number of heads written.""" |
|
912 | Return the number of heads written.""" | |
893 | nodecount = 0 |
|
913 | nodecount = 0 | |
|
914 | topo_heads = None | |||
|
915 | if self._pure_topo_branch is None: | |||
894 | topo_heads = set(self._get_topo_heads(repo)) |
|
916 | topo_heads = set(self._get_topo_heads(repo)) | |
895 | to_rev = repo.changelog.index.rev |
|
917 | to_rev = repo.changelog.index.rev | |
896 | for label, nodes in sorted(self._entries.items()): |
|
918 | for label, nodes in sorted(self._entries.items()): | |
|
919 | if label == self._pure_topo_branch: | |||
|
920 | # not need to write anything the header took care of that | |||
|
921 | continue | |||
897 | label = encoding.fromlocal(label) |
|
922 | label = encoding.fromlocal(label) | |
898 | for node in nodes: |
|
923 | for node in nodes: | |
|
924 | if topo_heads is not None: | |||
899 | rev = to_rev(node) |
|
925 | rev = to_rev(node) | |
900 | if rev in topo_heads: |
|
926 | if rev in topo_heads: | |
901 | continue |
|
927 | continue | |
@@ -916,6 +942,7 b' class BranchCacheV3(_LocalBranchCache):' | |||||
916 | args = {} |
|
942 | args = {} | |
917 | filtered_hash = None |
|
943 | filtered_hash = None | |
918 | obsolete_hash = None |
|
944 | obsolete_hash = None | |
|
945 | has_pure_topo_heads = False | |||
919 | for k, v in cache_keys.items(): |
|
946 | for k, v in cache_keys.items(): | |
920 | if k == b"tip-rev": |
|
947 | if k == b"tip-rev": | |
921 | args["tiprev"] = int(v) |
|
948 | args["tiprev"] = int(v) | |
@@ -925,16 +952,28 b' class BranchCacheV3(_LocalBranchCache):' | |||||
925 | filtered_hash = bin(v) |
|
952 | filtered_hash = bin(v) | |
926 | elif k == b"obsolete-hash": |
|
953 | elif k == b"obsolete-hash": | |
927 | obsolete_hash = bin(v) |
|
954 | obsolete_hash = bin(v) | |
|
955 | elif k == b"topo-mode": | |||
|
956 | if v == b"pure": | |||
|
957 | has_pure_topo_heads = True | |||
|
958 | else: | |||
|
959 | msg = b"unknown topo-mode: %r" % v | |||
|
960 | raise ValueError(msg) | |||
928 | else: |
|
961 | else: | |
929 | msg = b"unknown cache key: %r" % k |
|
962 | msg = b"unknown cache key: %r" % k | |
930 | raise ValueError(msg) |
|
963 | raise ValueError(msg) | |
931 | args["key_hashes"] = (filtered_hash, obsolete_hash) |
|
964 | args["key_hashes"] = (filtered_hash, obsolete_hash) | |
|
965 | if has_pure_topo_heads: | |||
|
966 | pure_line = next(lineiter).rstrip(b'\n') | |||
|
967 | args["pure_topo_branch"] = encoding.tolocal(pure_line) | |||
932 | return args |
|
968 | return args | |
933 |
|
969 | |||
934 | def _load_heads(self, repo, lineiter): |
|
970 | def _load_heads(self, repo, lineiter): | |
935 | """fully loads the branchcache by reading from the file using the line |
|
971 | """fully loads the branchcache by reading from the file using the line | |
936 | iterator passed""" |
|
972 | iterator passed""" | |
937 | super()._load_heads(repo, lineiter) |
|
973 | super()._load_heads(repo, lineiter) | |
|
974 | if self._pure_topo_branch is not None: | |||
|
975 | # no need to read the repository heads, we know their value already. | |||
|
976 | return | |||
938 | cl = repo.changelog |
|
977 | cl = repo.changelog | |
939 | getbranchinfo = repo.revbranchcache().branchinfo |
|
978 | getbranchinfo = repo.revbranchcache().branchinfo | |
940 | obsrevs = obsolete.getrevs(repo, b'obsolete') |
|
979 | obsrevs = obsolete.getrevs(repo, b'obsolete') | |
@@ -960,6 +999,62 b' class BranchCacheV3(_LocalBranchCache):' | |||||
960 | self.tiprev, |
|
999 | self.tiprev, | |
961 | ) |
|
1000 | ) | |
962 |
|
1001 | |||
|
1002 | def _process_new( | |||
|
1003 | self, | |||
|
1004 | repo, | |||
|
1005 | newbranches, | |||
|
1006 | new_closed, | |||
|
1007 | obs_ignored, | |||
|
1008 | max_rev, | |||
|
1009 | ) -> None: | |||
|
1010 | if ( | |||
|
1011 | # note: the check about `obs_ignored` is too strict as the | |||
|
1012 | # obsolete revision could be non-topological, but lets keep | |||
|
1013 | # things simple for now | |||
|
1014 | # | |||
|
1015 | # The same apply to `new_closed` if the closed changeset are | |||
|
1016 | # not a head, we don't care that it is closed, but lets keep | |||
|
1017 | # things simple here too. | |||
|
1018 | not (obs_ignored or new_closed) | |||
|
1019 | and ( | |||
|
1020 | not newbranches | |||
|
1021 | or ( | |||
|
1022 | len(newbranches) == 1 | |||
|
1023 | and ( | |||
|
1024 | self.tiprev == nullrev | |||
|
1025 | or self._pure_topo_branch in newbranches | |||
|
1026 | ) | |||
|
1027 | ) | |||
|
1028 | ) | |||
|
1029 | ): | |||
|
1030 | if newbranches: | |||
|
1031 | assert len(newbranches) == 1 | |||
|
1032 | self._pure_topo_branch = list(newbranches.keys())[0] | |||
|
1033 | self._needs_populate = True | |||
|
1034 | self._entries.pop(self._pure_topo_branch, None) | |||
|
1035 | return | |||
|
1036 | ||||
|
1037 | self._ensure_populated(repo) | |||
|
1038 | self._pure_topo_branch = None | |||
|
1039 | super()._process_new( | |||
|
1040 | repo, | |||
|
1041 | newbranches, | |||
|
1042 | new_closed, | |||
|
1043 | obs_ignored, | |||
|
1044 | max_rev, | |||
|
1045 | ) | |||
|
1046 | ||||
|
1047 | def _ensure_populated(self, repo): | |||
|
1048 | """make sure any lazily loaded values are fully populated""" | |||
|
1049 | if self._needs_populate: | |||
|
1050 | assert self._pure_topo_branch is not None | |||
|
1051 | cl = repo.changelog | |||
|
1052 | to_node = cl.node | |||
|
1053 | topo_heads = self._get_topo_heads(repo) | |||
|
1054 | heads = [to_node(r) for r in topo_heads] | |||
|
1055 | self._entries[self._pure_topo_branch] = heads | |||
|
1056 | self._needs_populate = False | |||
|
1057 | ||||
963 |
|
1058 | |||
964 | class remotebranchcache(_BaseBranchCache): |
|
1059 | class remotebranchcache(_BaseBranchCache): | |
965 | """Branchmap info for a remote connection, should not write locally""" |
|
1060 | """Branchmap info for a remote connection, should not write locally""" |
@@ -113,6 +113,19 b' We want some branching and some obsolesc' | |||||
113 | | |
|
113 | | | |
114 | o root |
|
114 | o root | |
115 |
|
115 | |||
|
116 | ||||
|
117 | #if v2 | |||
|
118 | $ show_cache | |||
|
119 | ##### .hg/cache/branch2-served | |||
|
120 | 3d808bbc94408ea19da905596d4079357a1f28be 8 | |||
|
121 | 63ba7cd843d1e95aac1a24435befeb1909c53619 o default | |||
|
122 | 3d808bbc94408ea19da905596d4079357a1f28be o default | |||
|
123 | #else | |||
|
124 | $ show_cache | |||
|
125 | ##### .hg/cache/branch3-served | |||
|
126 | tip-node=3d808bbc94408ea19da905596d4079357a1f28be tip-rev=8 topo-mode=pure | |||
|
127 | default | |||
|
128 | #endif | |||
116 | $ hg log -T '{desc}\n' --rev 'head()' |
|
129 | $ hg log -T '{desc}\n' --rev 'head()' | |
117 | B_4 |
|
130 | B_4 | |
118 | A_4 |
|
131 | A_4 | |
@@ -157,7 +170,8 b' Absolete a couple of changes' | |||||
157 | #else |
|
170 | #else | |
158 | $ show_cache |
|
171 | $ show_cache | |
159 | ##### .hg/cache/branch3-served |
|
172 | ##### .hg/cache/branch3-served | |
160 | filtered-hash=f8006d64a10d35c011a5c5fa88be1e25c5929514 tip-node=7c29ff2453bf38c75ee8982935739103c38a9284 tip-rev=7 |
|
173 | filtered-hash=f8006d64a10d35c011a5c5fa88be1e25c5929514 tip-node=7c29ff2453bf38c75ee8982935739103c38a9284 tip-rev=7 topo-mode=pure | |
|
174 | default | |||
161 | #endif |
|
175 | #endif | |
162 | $ cd .. |
|
176 | $ cd .. | |
163 |
|
177 | |||
@@ -209,7 +223,6 b' Revealing tipmost changeset' | |||||
209 | $ show_cache |
|
223 | $ show_cache | |
210 | ##### .hg/cache/branch3 |
|
224 | ##### .hg/cache/branch3 | |
211 | obsolete-hash=b6d2b1f5b70f09c25c835edcae69be35f681605c tip-node=3d808bbc94408ea19da905596d4079357a1f28be tip-rev=8 |
|
225 | obsolete-hash=b6d2b1f5b70f09c25c835edcae69be35f681605c tip-node=3d808bbc94408ea19da905596d4079357a1f28be tip-rev=8 | |
212 | 550bb31f072912453ccbb503de1d554616911e88 o default |
|
|||
213 | 7c29ff2453bf38c75ee8982935739103c38a9284 o default |
|
226 | 7c29ff2453bf38c75ee8982935739103c38a9284 o default | |
214 | ##### .hg/cache/branch3-served |
|
227 | ##### .hg/cache/branch3-served | |
215 | filtered-hash=f8006d64a10d35c011a5c5fa88be1e25c5929514 obsolete-hash=ac5282439f301518f362f37547fcd52bcc670373 tip-node=3d808bbc94408ea19da905596d4079357a1f28be tip-rev=8 |
|
228 | filtered-hash=f8006d64a10d35c011a5c5fa88be1e25c5929514 obsolete-hash=ac5282439f301518f362f37547fcd52bcc670373 tip-node=3d808bbc94408ea19da905596d4079357a1f28be tip-rev=8 | |
@@ -251,7 +264,8 b' And we can get back to normal' | |||||
251 | #else |
|
264 | #else | |
252 | $ show_cache |
|
265 | $ show_cache | |
253 | ##### .hg/cache/branch3-served |
|
266 | ##### .hg/cache/branch3-served | |
254 | filtered-hash=f8006d64a10d35c011a5c5fa88be1e25c5929514 tip-node=7c29ff2453bf38c75ee8982935739103c38a9284 tip-rev=7 |
|
267 | filtered-hash=f8006d64a10d35c011a5c5fa88be1e25c5929514 tip-node=7c29ff2453bf38c75ee8982935739103c38a9284 tip-rev=7 topo-mode=pure | |
|
268 | default | |||
255 | #endif |
|
269 | #endif | |
256 |
|
270 | |||
257 | $ cd .. |
|
271 | $ cd .. | |
@@ -299,7 +313,6 b' Check that revealing an obsolete changes' | |||||
299 | $ show_cache |
|
313 | $ show_cache | |
300 | ##### .hg/cache/branch3 |
|
314 | ##### .hg/cache/branch3 | |
301 | obsolete-hash=b6d2b1f5b70f09c25c835edcae69be35f681605c tip-node=3d808bbc94408ea19da905596d4079357a1f28be tip-rev=8 |
|
315 | obsolete-hash=b6d2b1f5b70f09c25c835edcae69be35f681605c tip-node=3d808bbc94408ea19da905596d4079357a1f28be tip-rev=8 | |
302 | 550bb31f072912453ccbb503de1d554616911e88 o default |
|
|||
303 | 7c29ff2453bf38c75ee8982935739103c38a9284 o default |
|
316 | 7c29ff2453bf38c75ee8982935739103c38a9284 o default | |
304 | ##### .hg/cache/branch3-served |
|
317 | ##### .hg/cache/branch3-served | |
305 | filtered-hash=f1456c0d675980582dda9b8edc7f13f503ce544f obsolete-hash=3e74f5349008671629e39d13d7e00d9ba94c74f7 tip-node=7c29ff2453bf38c75ee8982935739103c38a9284 tip-rev=7 |
|
318 | filtered-hash=f1456c0d675980582dda9b8edc7f13f503ce544f obsolete-hash=3e74f5349008671629e39d13d7e00d9ba94c74f7 tip-node=7c29ff2453bf38c75ee8982935739103c38a9284 tip-rev=7 | |
@@ -341,7 +354,8 b' And we can get back to normal' | |||||
341 | #else |
|
354 | #else | |
342 | $ show_cache |
|
355 | $ show_cache | |
343 | ##### .hg/cache/branch3-served |
|
356 | ##### .hg/cache/branch3-served | |
344 | filtered-hash=f8006d64a10d35c011a5c5fa88be1e25c5929514 tip-node=7c29ff2453bf38c75ee8982935739103c38a9284 tip-rev=7 |
|
357 | filtered-hash=f8006d64a10d35c011a5c5fa88be1e25c5929514 tip-node=7c29ff2453bf38c75ee8982935739103c38a9284 tip-rev=7 topo-mode=pure | |
|
358 | default | |||
345 | #endif |
|
359 | #endif | |
346 |
|
360 | |||
347 | $ cd .. |
|
361 | $ cd .. | |
@@ -434,7 +448,8 b' And we can get back to normal' | |||||
434 | #else |
|
448 | #else | |
435 | $ show_cache |
|
449 | $ show_cache | |
436 | ##### .hg/cache/branch3-served |
|
450 | ##### .hg/cache/branch3-served | |
437 | tip-node=7c29ff2453bf38c75ee8982935739103c38a9284 tip-rev=7 |
|
451 | tip-node=7c29ff2453bf38c75ee8982935739103c38a9284 tip-rev=7 topo-mode=pure | |
|
452 | default | |||
438 | #endif |
|
453 | #endif | |
439 |
|
454 | |||
440 | $ cd .. |
|
455 | $ cd .. | |
@@ -477,7 +492,8 b' Getting the obsolescence marker after th' | |||||
477 | #else |
|
492 | #else | |
478 | $ show_cache |
|
493 | $ show_cache | |
479 | ##### .hg/cache/branch3-served |
|
494 | ##### .hg/cache/branch3-served | |
480 | tip-node=3d808bbc94408ea19da905596d4079357a1f28be tip-rev=8 |
|
495 | tip-node=3d808bbc94408ea19da905596d4079357a1f28be tip-rev=8 topo-mode=pure | |
|
496 | default | |||
481 | #endif |
|
497 | #endif | |
482 |
|
498 | |||
483 | $ hg pull --rev `cat ../main-single-branch-node_B4` --remote-hidden |
|
499 | $ hg pull --rev `cat ../main-single-branch-node_B4` --remote-hidden | |
@@ -539,7 +555,8 b' And we can get back to normal' | |||||
539 | #else |
|
555 | #else | |
540 | $ show_cache |
|
556 | $ show_cache | |
541 | ##### .hg/cache/branch3-served |
|
557 | ##### .hg/cache/branch3-served | |
542 | filtered-hash=f8006d64a10d35c011a5c5fa88be1e25c5929514 tip-node=3d808bbc94408ea19da905596d4079357a1f28be tip-rev=8 |
|
558 | filtered-hash=f8006d64a10d35c011a5c5fa88be1e25c5929514 tip-node=3d808bbc94408ea19da905596d4079357a1f28be tip-rev=8 topo-mode=pure | |
|
559 | default | |||
543 | #endif |
|
560 | #endif | |
544 |
|
561 | |||
545 | $ cd .. |
|
562 | $ cd .. |
@@ -1312,7 +1312,8 b' Unbundling revision should warm the serv' | |||||
1312 | 0 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
1312 | 0 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
1313 | #if v3 |
|
1313 | #if v3 | |
1314 | $ cat branchmap-update-01/.hg/cache/branch3-base |
|
1314 | $ cat branchmap-update-01/.hg/cache/branch3-base | |
1315 | tip-node=99ba08759bc7f6fdbe5304e83d0387f35c082479 tip-rev=1 |
|
1315 | tip-node=99ba08759bc7f6fdbe5304e83d0387f35c082479 tip-rev=1 topo-mode=pure | |
|
1316 | A | |||
1316 | #else |
|
1317 | #else | |
1317 | $ cat branchmap-update-01/.hg/cache/branch2-base |
|
1318 | $ cat branchmap-update-01/.hg/cache/branch2-base | |
1318 | 99ba08759bc7f6fdbe5304e83d0387f35c082479 1 |
|
1319 | 99ba08759bc7f6fdbe5304e83d0387f35c082479 1 | |
@@ -1327,7 +1328,8 b' Unbundling revision should warm the serv' | |||||
1327 | (run 'hg update' to get a working copy) |
|
1328 | (run 'hg update' to get a working copy) | |
1328 | #if v3 |
|
1329 | #if v3 | |
1329 | $ cat branchmap-update-01/.hg/cache/branch3-served |
|
1330 | $ cat branchmap-update-01/.hg/cache/branch3-served | |
1330 | tip-node=71ca9a6d524ed3c2a215119b2086ac3b8c4c8286 tip-rev=3 |
|
1331 | tip-node=71ca9a6d524ed3c2a215119b2086ac3b8c4c8286 tip-rev=3 topo-mode=pure | |
|
1332 | A | |||
1331 | #else |
|
1333 | #else | |
1332 | $ cat branchmap-update-01/.hg/cache/branch2-served |
|
1334 | $ cat branchmap-update-01/.hg/cache/branch2-served | |
1333 | 71ca9a6d524ed3c2a215119b2086ac3b8c4c8286 3 |
|
1335 | 71ca9a6d524ed3c2a215119b2086ac3b8c4c8286 3 | |
@@ -1356,7 +1358,8 b' aborted Unbundle should not update the o' | |||||
1356 |
|
1358 | |||
1357 | #if v3 |
|
1359 | #if v3 | |
1358 | $ cat branchmap-update-02/.hg/cache/branch3-base |
|
1360 | $ cat branchmap-update-02/.hg/cache/branch3-base | |
1359 | tip-node=99ba08759bc7f6fdbe5304e83d0387f35c082479 tip-rev=1 |
|
1361 | tip-node=99ba08759bc7f6fdbe5304e83d0387f35c082479 tip-rev=1 topo-mode=pure | |
|
1362 | A | |||
1360 | #else |
|
1363 | #else | |
1361 | $ cat branchmap-update-02/.hg/cache/branch2-base |
|
1364 | $ cat branchmap-update-02/.hg/cache/branch2-base | |
1362 | 99ba08759bc7f6fdbe5304e83d0387f35c082479 1 |
|
1365 | 99ba08759bc7f6fdbe5304e83d0387f35c082479 1 | |
@@ -1372,7 +1375,8 b' aborted Unbundle should not update the o' | |||||
1372 | [40] |
|
1375 | [40] | |
1373 | #if v3 |
|
1376 | #if v3 | |
1374 | $ cat branchmap-update-02/.hg/cache/branch3-base |
|
1377 | $ cat branchmap-update-02/.hg/cache/branch3-base | |
1375 | tip-node=99ba08759bc7f6fdbe5304e83d0387f35c082479 tip-rev=1 |
|
1378 | tip-node=99ba08759bc7f6fdbe5304e83d0387f35c082479 tip-rev=1 topo-mode=pure | |
|
1379 | A | |||
1376 | #else |
|
1380 | #else | |
1377 | $ cat branchmap-update-02/.hg/cache/branch2-base |
|
1381 | $ cat branchmap-update-02/.hg/cache/branch2-base | |
1378 | 99ba08759bc7f6fdbe5304e83d0387f35c082479 1 |
|
1382 | 99ba08759bc7f6fdbe5304e83d0387f35c082479 1 |
General Comments 0
You need to be logged in to leave comments.
Login now