Show More
@@ -1,4 +1,5 | |||||
1 | # repository.py - Interfaces and base classes for repositories and peers. |
|
1 | # repository.py - Interfaces and base classes for repositories and peers. | |
|
2 | # coding: utf-8 | |||
2 | # |
|
3 | # | |
3 | # Copyright 2017 Gregory Szorc <gregory.szorc@gmail.com> |
|
4 | # Copyright 2017 Gregory Szorc <gregory.szorc@gmail.com> | |
4 | # |
|
5 | # | |
@@ -44,6 +45,49 CG_DELTAMODE_FULL = b'fulltext' | |||||
44 | CG_DELTAMODE_P1 = b'p1' |
|
45 | CG_DELTAMODE_P1 = b'p1' | |
45 |
|
46 | |||
46 |
|
47 | |||
|
48 | ## Cache related constants: | |||
|
49 | # | |||
|
50 | # Used to control which cache should be warmed in a repo.updatecaches(β¦) call. | |||
|
51 | ||||
|
52 | # Warm branchmaps of all known repoview's filter-level | |||
|
53 | CACHE_BRANCHMAP_ALL = b"branchmap-all" | |||
|
54 | # Warm branchmaps of repoview's filter-level used by server | |||
|
55 | CACHE_BRANCHMAP_SERVED = b"branchmap-served" | |||
|
56 | # Warm internal changelog cache (eg: persistent nodemap) | |||
|
57 | CACHE_CHANGELOG_CACHE = b"changelog-cache" | |||
|
58 | # Warm full manifest cache | |||
|
59 | CACHE_FULL_MANIFEST = b"full-manifest" | |||
|
60 | # Warm file-node-tags cache | |||
|
61 | CACHE_FILE_NODE_TAGS = b"file-node-tags" | |||
|
62 | # Warm internal manifestlog cache (eg: persistent nodemap) | |||
|
63 | CACHE_MANIFESTLOG_CACHE = b"manifestlog-cache" | |||
|
64 | # Warn rev branch cache | |||
|
65 | CACHE_REV_BRANCH = b"rev-branch-cache" | |||
|
66 | # Warm tags' cache for default repoview' | |||
|
67 | CACHE_TAGS_DEFAULT = b"tags-default" | |||
|
68 | # Warm tags' cache for repoview's filter-level used by server | |||
|
69 | CACHE_TAGS_SERVED = b"tags-served" | |||
|
70 | ||||
|
71 | # the cache to warm by default after a simple transaction | |||
|
72 | # (this is a mutable set to let extension update it) | |||
|
73 | CACHES_DEFAULT = { | |||
|
74 | CACHE_BRANCHMAP_SERVED, | |||
|
75 | } | |||
|
76 | ||||
|
77 | # the caches to warm when warming all of them | |||
|
78 | # (this is a mutable set to let extension update it) | |||
|
79 | CACHES_ALL = { | |||
|
80 | CACHE_BRANCHMAP_SERVED, | |||
|
81 | CACHE_BRANCHMAP_ALL, | |||
|
82 | CACHE_CHANGELOG_CACHE, | |||
|
83 | CACHE_FILE_NODE_TAGS, | |||
|
84 | CACHE_FULL_MANIFEST, | |||
|
85 | CACHE_MANIFESTLOG_CACHE, | |||
|
86 | CACHE_TAGS_DEFAULT, | |||
|
87 | CACHE_TAGS_SERVED, | |||
|
88 | } | |||
|
89 | ||||
|
90 | ||||
47 | class ipeerconnection(interfaceutil.Interface): |
|
91 | class ipeerconnection(interfaceutil.Interface): | |
48 | """Represents a "connection" to a repository. |
|
92 | """Represents a "connection" to a repository. | |
49 |
|
93 |
@@ -2752,40 +2752,56 class localrepository(object): | |||||
2752 | # later call to `destroyed` will refresh them. |
|
2752 | # later call to `destroyed` will refresh them. | |
2753 | return |
|
2753 | return | |
2754 |
|
2754 | |||
|
2755 | unfi = self.unfiltered() | |||
|
2756 | ||||
|
2757 | if full: | |||
|
2758 | caches = repository.CACHES_ALL | |||
|
2759 | if full == b"post-clone": | |||
|
2760 | caches = caches.copy() | |||
|
2761 | caches.discard(repository.CACHE_FILE_NODE_TAGS) | |||
|
2762 | else: | |||
|
2763 | caches = repository.CACHES_DEFAULT | |||
|
2764 | ||||
|
2765 | if repository.CACHE_BRANCHMAP_SERVED in caches: | |||
2755 | if tr is None or tr.changes[b'origrepolen'] < len(self): |
|
2766 | if tr is None or tr.changes[b'origrepolen'] < len(self): | |
2756 | # accessing the 'served' branchmap should refresh all the others, |
|
2767 | # accessing the 'served' branchmap should refresh all the others, | |
2757 | self.ui.debug(b'updating the branch cache\n') |
|
2768 | self.ui.debug(b'updating the branch cache\n') | |
2758 | self.filtered(b'served').branchmap() |
|
2769 | self.filtered(b'served').branchmap() | |
2759 | self.filtered(b'served.hidden').branchmap() |
|
2770 | self.filtered(b'served.hidden').branchmap() | |
2760 |
|
2771 | |||
2761 | if full: |
|
2772 | if repository.CACHE_CHANGELOG_CACHE in caches: | |
2762 | unfi = self.unfiltered() |
|
|||
2763 |
|
||||
2764 | self.changelog.update_caches(transaction=tr) |
|
2773 | self.changelog.update_caches(transaction=tr) | |
|
2774 | ||||
|
2775 | if repository.CACHE_MANIFESTLOG_CACHE in caches: | |||
2765 | self.manifestlog.update_caches(transaction=tr) |
|
2776 | self.manifestlog.update_caches(transaction=tr) | |
2766 |
|
2777 | |||
|
2778 | if repository.CACHE_REV_BRANCH in caches: | |||
2767 | rbc = unfi.revbranchcache() |
|
2779 | rbc = unfi.revbranchcache() | |
2768 | for r in unfi.changelog: |
|
2780 | for r in unfi.changelog: | |
2769 | rbc.branchinfo(r) |
|
2781 | rbc.branchinfo(r) | |
2770 | rbc.write() |
|
2782 | rbc.write() | |
2771 |
|
2783 | |||
|
2784 | if repository.CACHE_FULL_MANIFEST in caches: | |||
2772 | # ensure the working copy parents are in the manifestfulltextcache |
|
2785 | # ensure the working copy parents are in the manifestfulltextcache | |
2773 | for ctx in self[b'.'].parents(): |
|
2786 | for ctx in self[b'.'].parents(): | |
2774 | ctx.manifest() # accessing the manifest is enough |
|
2787 | ctx.manifest() # accessing the manifest is enough | |
2775 |
|
2788 | |||
2776 | if not full == b"post-clone": |
|
2789 | if repository.CACHE_FILE_NODE_TAGS in caches: | |
2777 |
|
|
2790 | # accessing fnode cache warms the cache | |
2778 |
|
|
2791 | tagsmod.fnoderevs(self.ui, unfi, unfi.changelog.revs()) | |
|
2792 | ||||
|
2793 | if repository.CACHE_TAGS_DEFAULT in caches: | |||
2779 | # accessing tags warm the cache |
|
2794 | # accessing tags warm the cache | |
2780 | self.tags() |
|
2795 | self.tags() | |
|
2796 | if repository.CACHE_TAGS_SERVED in caches: | |||
2781 | self.filtered(b'served').tags() |
|
2797 | self.filtered(b'served').tags() | |
2782 |
|
2798 | |||
2783 | # The `full` arg is documented as updating even the lazily-loaded |
|
2799 | if repository.CACHE_BRANCHMAP_ALL in caches: | |
2784 | # caches immediately, so we're forcing a write to cause these caches |
|
2800 | # The CACHE_BRANCHMAP_ALL updates lazily-loaded caches immediately, | |
2785 | # to be warmed up even if they haven't explicitly been requested |
|
2801 | # so we're forcing a write to cause these caches to be warmed up | |
2786 | # yet (if they've never been used by hg, they won't ever have been |
|
2802 | # even if they haven't explicitly been requested yet (if they've | |
2787 | # written, even if they're a subset of another kind of cache that |
|
2803 | # never been used by hg, they won't ever have been written, even if | |
2788 | # *has* been used). |
|
2804 | # they're a subset of another kind of cache that *has* been used). | |
2789 | for filt in repoview.filtertable.keys(): |
|
2805 | for filt in repoview.filtertable.keys(): | |
2790 | filtered = self.filtered(filt) |
|
2806 | filtered = self.filtered(filt) | |
2791 | filtered.branchmap().write(filtered) |
|
2807 | filtered.branchmap().write(filtered) |
General Comments 0
You need to be logged in to leave comments.
Login now