Show More
@@ -62,6 +62,7 b' class BranchMapCache:' | |||
|
62 | 62 | def __getitem__(self, repo): |
|
63 | 63 | self.updatecache(repo) |
|
64 | 64 | bcache = self._per_filter[repo.filtername] |
|
65 | bcache._ensure_populated(repo) | |
|
65 | 66 | assert bcache._filtername == repo.filtername, ( |
|
66 | 67 | bcache._filtername, |
|
67 | 68 | repo.filtername, |
@@ -484,6 +485,9 b' class _LocalBranchCache(_BaseBranchCache' | |||
|
484 | 485 | def _compute_key_hashes(self, repo) -> Tuple[bytes]: |
|
485 | 486 | raise NotImplementedError |
|
486 | 487 | |
|
488 | def _ensure_populated(self, repo): | |
|
489 | """make sure any lazily loaded values are fully populated""" | |
|
490 | ||
|
487 | 491 | def validfor(self, repo): |
|
488 | 492 | """check that cache contents are valid for (a subset of) this repo |
|
489 | 493 | |
@@ -861,7 +865,18 b' class BranchCacheV3(_LocalBranchCache):' | |||
|
861 | 865 | _base_filename = b"branch3" |
|
862 | 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 | 880 | """returns the topological head of a repoview content up to self.tiprev""" |
|
866 | 881 | cl = repo.changelog |
|
867 | 882 | if self.tiprev == nullrev: |
@@ -883,22 +898,33 b' class BranchCacheV3(_LocalBranchCache):' | |||
|
883 | 898 | cache_keys[b"filtered-hash"] = hex(self.key_hashes[0]) |
|
884 | 899 | if self.key_hashes[1] is not None: |
|
885 | 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 | 903 | pieces = (b"%s=%s" % i for i in sorted(cache_keys.items())) |
|
887 | 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 | 909 | def _write_heads(self, repo, fp) -> int: |
|
890 | 910 | """write list of heads to a file |
|
891 | 911 | |
|
892 | 912 | Return the number of heads written.""" |
|
893 | 913 | nodecount = 0 |
|
894 | topo_heads = set(self._get_topo_heads(repo)) | |
|
914 | topo_heads = None | |
|
915 | if self._pure_topo_branch is None: | |
|
916 | topo_heads = set(self._get_topo_heads(repo)) | |
|
895 | 917 | to_rev = repo.changelog.index.rev |
|
896 | 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 | 922 | label = encoding.fromlocal(label) |
|
898 | 923 | for node in nodes: |
|
899 |
|
|
|
900 |
|
|
|
901 |
|
|
|
924 | if topo_heads is not None: | |
|
925 | rev = to_rev(node) | |
|
926 | if rev in topo_heads: | |
|
927 | continue | |
|
902 | 928 | if node in self._closednodes: |
|
903 | 929 | state = b'c' |
|
904 | 930 | else: |
@@ -916,6 +942,7 b' class BranchCacheV3(_LocalBranchCache):' | |||
|
916 | 942 | args = {} |
|
917 | 943 | filtered_hash = None |
|
918 | 944 | obsolete_hash = None |
|
945 | has_pure_topo_heads = False | |
|
919 | 946 | for k, v in cache_keys.items(): |
|
920 | 947 | if k == b"tip-rev": |
|
921 | 948 | args["tiprev"] = int(v) |
@@ -925,16 +952,28 b' class BranchCacheV3(_LocalBranchCache):' | |||
|
925 | 952 | filtered_hash = bin(v) |
|
926 | 953 | elif k == b"obsolete-hash": |
|
927 | 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 | 961 | else: |
|
929 | 962 | msg = b"unknown cache key: %r" % k |
|
930 | 963 | raise ValueError(msg) |
|
931 | 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 | 968 | return args |
|
933 | 969 | |
|
934 | 970 | def _load_heads(self, repo, lineiter): |
|
935 | 971 | """fully loads the branchcache by reading from the file using the line |
|
936 | 972 | iterator passed""" |
|
937 | 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 | 977 | cl = repo.changelog |
|
939 | 978 | getbranchinfo = repo.revbranchcache().branchinfo |
|
940 | 979 | obsrevs = obsolete.getrevs(repo, b'obsolete') |
@@ -960,6 +999,62 b' class BranchCacheV3(_LocalBranchCache):' | |||
|
960 | 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 | 1059 | class remotebranchcache(_BaseBranchCache): |
|
965 | 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 | 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 | 129 | $ hg log -T '{desc}\n' --rev 'head()' |
|
117 | 130 | B_4 |
|
118 | 131 | A_4 |
@@ -157,7 +170,8 b' Absolete a couple of changes' | |||
|
157 | 170 | #else |
|
158 | 171 | $ show_cache |
|
159 | 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 | 175 | #endif |
|
162 | 176 | $ cd .. |
|
163 | 177 | |
@@ -209,7 +223,6 b' Revealing tipmost changeset' | |||
|
209 | 223 | $ show_cache |
|
210 | 224 | ##### .hg/cache/branch3 |
|
211 | 225 | obsolete-hash=b6d2b1f5b70f09c25c835edcae69be35f681605c tip-node=3d808bbc94408ea19da905596d4079357a1f28be tip-rev=8 |
|
212 | 550bb31f072912453ccbb503de1d554616911e88 o default | |
|
213 | 226 | 7c29ff2453bf38c75ee8982935739103c38a9284 o default |
|
214 | 227 | ##### .hg/cache/branch3-served |
|
215 | 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 | 264 | #else |
|
252 | 265 | $ show_cache |
|
253 | 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 | 269 | #endif |
|
256 | 270 | |
|
257 | 271 | $ cd .. |
@@ -299,7 +313,6 b' Check that revealing an obsolete changes' | |||
|
299 | 313 | $ show_cache |
|
300 | 314 | ##### .hg/cache/branch3 |
|
301 | 315 | obsolete-hash=b6d2b1f5b70f09c25c835edcae69be35f681605c tip-node=3d808bbc94408ea19da905596d4079357a1f28be tip-rev=8 |
|
302 | 550bb31f072912453ccbb503de1d554616911e88 o default | |
|
303 | 316 | 7c29ff2453bf38c75ee8982935739103c38a9284 o default |
|
304 | 317 | ##### .hg/cache/branch3-served |
|
305 | 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 | 354 | #else |
|
342 | 355 | $ show_cache |
|
343 | 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 | 359 | #endif |
|
346 | 360 | |
|
347 | 361 | $ cd .. |
@@ -434,7 +448,8 b' And we can get back to normal' | |||
|
434 | 448 | #else |
|
435 | 449 | $ show_cache |
|
436 | 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 | 453 | #endif |
|
439 | 454 | |
|
440 | 455 | $ cd .. |
@@ -477,7 +492,8 b' Getting the obsolescence marker after th' | |||
|
477 | 492 | #else |
|
478 | 493 | $ show_cache |
|
479 | 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 | 497 | #endif |
|
482 | 498 | |
|
483 | 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 | 555 | #else |
|
540 | 556 | $ show_cache |
|
541 | 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 | 560 | #endif |
|
544 | 561 | |
|
545 | 562 | $ cd .. |
@@ -1312,7 +1312,8 b' Unbundling revision should warm the serv' | |||
|
1312 | 1312 | 0 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
1313 | 1313 | #if v3 |
|
1314 | 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 | 1317 | #else |
|
1317 | 1318 | $ cat branchmap-update-01/.hg/cache/branch2-base |
|
1318 | 1319 | 99ba08759bc7f6fdbe5304e83d0387f35c082479 1 |
@@ -1327,7 +1328,8 b' Unbundling revision should warm the serv' | |||
|
1327 | 1328 | (run 'hg update' to get a working copy) |
|
1328 | 1329 | #if v3 |
|
1329 | 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 | 1333 | #else |
|
1332 | 1334 | $ cat branchmap-update-01/.hg/cache/branch2-served |
|
1333 | 1335 | 71ca9a6d524ed3c2a215119b2086ac3b8c4c8286 3 |
@@ -1356,7 +1358,8 b' aborted Unbundle should not update the o' | |||
|
1356 | 1358 | |
|
1357 | 1359 | #if v3 |
|
1358 | 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 | 1363 | #else |
|
1361 | 1364 | $ cat branchmap-update-02/.hg/cache/branch2-base |
|
1362 | 1365 | 99ba08759bc7f6fdbe5304e83d0387f35c082479 1 |
@@ -1372,7 +1375,8 b' aborted Unbundle should not update the o' | |||
|
1372 | 1375 | [40] |
|
1373 | 1376 | #if v3 |
|
1374 | 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 | 1380 | #else |
|
1377 | 1381 | $ cat branchmap-update-02/.hg/cache/branch2-base |
|
1378 | 1382 | 99ba08759bc7f6fdbe5304e83d0387f35c082479 1 |
General Comments 0
You need to be logged in to leave comments.
Login now