Show More
@@ -69,7 +69,7 b' class BranchMapCache:' | |||||
69 | ) |
|
69 | ) | |
70 | return bcache |
|
70 | return bcache | |
71 |
|
71 | |||
72 | def update_disk(self, repo): |
|
72 | def update_disk(self, repo, detect_pure_topo=False): | |
73 | """ensure and up-to-date cache is (or will be) written on disk |
|
73 | """ensure and up-to-date cache is (or will be) written on disk | |
74 |
|
74 | |||
75 | The cache for this repository view is updated if needed and written on |
|
75 | The cache for this repository view is updated if needed and written on | |
@@ -87,6 +87,8 b' class BranchMapCache:' | |||||
87 | bcache._filtername, |
|
87 | bcache._filtername, | |
88 | repo.filtername, |
|
88 | repo.filtername, | |
89 | ) |
|
89 | ) | |
|
90 | if detect_pure_topo: | |||
|
91 | bcache._detect_pure_topo(repo) | |||
90 | tr = repo.currenttransaction() |
|
92 | tr = repo.currenttransaction() | |
91 | if getattr(tr, 'finalized', True): |
|
93 | if getattr(tr, 'finalized', True): | |
92 | bcache.sync_disk(repo) |
|
94 | bcache.sync_disk(repo) | |
@@ -488,6 +490,9 b' class _LocalBranchCache(_BaseBranchCache' | |||||
488 | def _ensure_populated(self, repo): |
|
490 | def _ensure_populated(self, repo): | |
489 | """make sure any lazily loaded values are fully populated""" |
|
491 | """make sure any lazily loaded values are fully populated""" | |
490 |
|
492 | |||
|
493 | def _detect_pure_topo(self, repo) -> None: | |||
|
494 | pass | |||
|
495 | ||||
491 | def validfor(self, repo): |
|
496 | def validfor(self, repo): | |
492 | """check that cache contents are valid for (a subset of) this repo |
|
497 | """check that cache contents are valid for (a subset of) this repo | |
493 |
|
498 | |||
@@ -1055,6 +1060,19 b' class BranchCacheV3(_LocalBranchCache):' | |||||
1055 | self._entries[self._pure_topo_branch] = heads |
|
1060 | self._entries[self._pure_topo_branch] = heads | |
1056 | self._needs_populate = False |
|
1061 | self._needs_populate = False | |
1057 |
|
1062 | |||
|
1063 | def _detect_pure_topo(self, repo) -> None: | |||
|
1064 | if self._pure_topo_branch is not None: | |||
|
1065 | # we are pure topological already | |||
|
1066 | return | |||
|
1067 | to_node = repo.changelog.node | |||
|
1068 | topo_heads = [to_node(r) for r in self._get_topo_heads(repo)] | |||
|
1069 | if any(n in self._closednodes for n in topo_heads): | |||
|
1070 | return | |||
|
1071 | for branch, heads in self._entries.items(): | |||
|
1072 | if heads == topo_heads: | |||
|
1073 | self._pure_topo_branch = branch | |||
|
1074 | break | |||
|
1075 | ||||
1058 |
|
1076 | |||
1059 | class remotebranchcache(_BaseBranchCache): |
|
1077 | class remotebranchcache(_BaseBranchCache): | |
1060 | """Branchmap info for a remote connection, should not write locally""" |
|
1078 | """Branchmap info for a remote connection, should not write locally""" |
@@ -54,6 +54,8 b' CACHE_BRANCHMAP_ALL = b"branchmap-all"' | |||||
54 | CACHE_BRANCHMAP_SERVED = b"branchmap-served" |
|
54 | CACHE_BRANCHMAP_SERVED = b"branchmap-served" | |
55 | # Warm internal changelog cache (eg: persistent nodemap) |
|
55 | # Warm internal changelog cache (eg: persistent nodemap) | |
56 | CACHE_CHANGELOG_CACHE = b"changelog-cache" |
|
56 | CACHE_CHANGELOG_CACHE = b"changelog-cache" | |
|
57 | # check of a branchmap can use the "pure topo" mode | |||
|
58 | CACHE_BRANCHMAP_DETECT_PURE_TOPO = b"branchmap-detect-pure-topo" | |||
57 | # Warm full manifest cache |
|
59 | # Warm full manifest cache | |
58 | CACHE_FULL_MANIFEST = b"full-manifest" |
|
60 | CACHE_FULL_MANIFEST = b"full-manifest" | |
59 | # Warm file-node-tags cache |
|
61 | # Warm file-node-tags cache | |
@@ -78,6 +80,7 b' CACHES_DEFAULT = {' | |||||
78 | CACHES_ALL = { |
|
80 | CACHES_ALL = { | |
79 | CACHE_BRANCHMAP_SERVED, |
|
81 | CACHE_BRANCHMAP_SERVED, | |
80 | CACHE_BRANCHMAP_ALL, |
|
82 | CACHE_BRANCHMAP_ALL, | |
|
83 | CACHE_BRANCHMAP_DETECT_PURE_TOPO, | |||
81 | CACHE_CHANGELOG_CACHE, |
|
84 | CACHE_CHANGELOG_CACHE, | |
82 | CACHE_FILE_NODE_TAGS, |
|
85 | CACHE_FILE_NODE_TAGS, | |
83 | CACHE_FULL_MANIFEST, |
|
86 | CACHE_FULL_MANIFEST, |
@@ -2924,8 +2924,13 b' class localrepository:' | |||||
2924 | if repository.CACHE_BRANCHMAP_SERVED in caches: |
|
2924 | if repository.CACHE_BRANCHMAP_SERVED in caches: | |
2925 | if tr is None or tr.changes[b'origrepolen'] < len(self): |
|
2925 | if tr is None or tr.changes[b'origrepolen'] < len(self): | |
2926 | self.ui.debug(b'updating the branch cache\n') |
|
2926 | self.ui.debug(b'updating the branch cache\n') | |
2927 | self._branchcaches.update_disk(self.filtered(b'served')) |
|
2927 | dpt = repository.CACHE_BRANCHMAP_DETECT_PURE_TOPO in caches | |
2928 |
se |
|
2928 | served = self.filtered(b'served') | |
|
2929 | self._branchcaches.update_disk(served, detect_pure_topo=dpt) | |||
|
2930 | served_hidden = self.filtered(b'served.hidden') | |||
|
2931 | self._branchcaches.update_disk( | |||
|
2932 | served_hidden, detect_pure_topo=dpt | |||
|
2933 | ) | |||
2929 |
|
2934 | |||
2930 | if repository.CACHE_CHANGELOG_CACHE in caches: |
|
2935 | if repository.CACHE_CHANGELOG_CACHE in caches: | |
2931 | self.changelog.update_caches(transaction=tr) |
|
2936 | self.changelog.update_caches(transaction=tr) | |
@@ -2968,9 +2973,11 b' class localrepository:' | |||||
2968 | # even if they haven't explicitly been requested yet (if they've |
|
2973 | # even if they haven't explicitly been requested yet (if they've | |
2969 | # never been used by hg, they won't ever have been written, even if |
|
2974 | # never been used by hg, they won't ever have been written, even if | |
2970 | # they're a subset of another kind of cache that *has* been used). |
|
2975 | # they're a subset of another kind of cache that *has* been used). | |
|
2976 | dpt = repository.CACHE_BRANCHMAP_DETECT_PURE_TOPO in caches | |||
|
2977 | ||||
2971 | for filt in repoview.filtertable.keys(): |
|
2978 | for filt in repoview.filtertable.keys(): | |
2972 | filtered = self.filtered(filt) |
|
2979 | filtered = self.filtered(filt) | |
2973 | self._branchcaches.update_disk(filtered) |
|
2980 | self._branchcaches.update_disk(filtered, detect_pure_topo=dpt) | |
2974 |
|
2981 | |||
2975 | # flush all possibly delayed write. |
|
2982 | # flush all possibly delayed write. | |
2976 | self._branchcaches.write_dirty(self) |
|
2983 | self._branchcaches.write_dirty(self) |
General Comments 0
You need to be logged in to leave comments.
Login now