Show More
@@ -741,13 +741,7 b' class _DeltaSearch:' | |||
|
741 | 741 | group_chunk_size = self.revlog.delta_config.candidate_group_chunk_size |
|
742 | 742 | |
|
743 | 743 | tested = {nullrev} |
|
744 | candidates = _refinedgroups( | |
|
745 | self.revlog, | |
|
746 | self.p1, | |
|
747 | self.p2, | |
|
748 | self.cachedelta, | |
|
749 | snapshot_cache=self.snapshot_cache, | |
|
750 | ) | |
|
744 | candidates = self._refined_groups() | |
|
751 | 745 | while True: |
|
752 | 746 | temptative = candidates.send(good) |
|
753 | 747 | if temptative is None: |
@@ -869,70 +863,79 b' class _DeltaSearch:' | |||
|
869 | 863 | |
|
870 | 864 | yield None |
|
871 | 865 | |
|
866 | def _refined_groups(self): | |
|
867 | good = None | |
|
868 | # First we try to reuse a the delta contained in the bundle. (or from | |
|
869 | # the source revlog) | |
|
870 | # | |
|
871 | # This logic only applies to general delta repositories and can be | |
|
872 | # disabled through configuration. Disabling reuse source delta is | |
|
873 | # useful when we want to make sure we recomputed "optimal" deltas. | |
|
874 | debug_info = None | |
|
875 | if ( | |
|
876 | self.cachedelta is not None | |
|
877 | and self.cachedelta[2] > DELTA_BASE_REUSE_NO | |
|
878 | ): | |
|
879 | # Assume what we received from the server is a good choice | |
|
880 | # build delta will reuse the cache | |
|
881 | if debug_info is not None: | |
|
882 | debug_info['cached-delta.tested'] += 1 | |
|
883 | good = yield (self.cachedelta[0],) | |
|
884 | if good is not None: | |
|
885 | if debug_info is not None: | |
|
886 | debug_info['cached-delta.accepted'] += 1 | |
|
887 | yield None | |
|
888 | return | |
|
889 | if self.snapshot_cache is None: | |
|
890 | self.snapshot_cache = SnapshotCache() | |
|
891 | groups = _rawgroups( | |
|
892 | self.revlog, | |
|
893 | self.p1, | |
|
894 | self.p2, | |
|
895 | self.cachedelta, | |
|
896 | self.snapshot_cache, | |
|
897 | ) | |
|
898 | for candidates in groups: | |
|
899 | good = yield candidates | |
|
900 | if good is not None: | |
|
901 | break | |
|
872 | 902 | |
|
873 | def _refinedgroups(revlog, p1, p2, cachedelta, snapshot_cache=None): | |
|
874 | good = None | |
|
875 | # First we try to reuse a the delta contained in the bundle. | |
|
876 | # (or from the source revlog) | |
|
877 | # | |
|
878 | # This logic only applies to general delta repositories and can be disabled | |
|
879 | # through configuration. Disabling reuse source delta is useful when | |
|
880 | # we want to make sure we recomputed "optimal" deltas. | |
|
881 | debug_info = None | |
|
882 | if cachedelta is not None and cachedelta[2] > DELTA_BASE_REUSE_NO: | |
|
883 | # Assume what we received from the server is a good choice | |
|
884 | # build delta will reuse the cache | |
|
885 | if debug_info is not None: | |
|
886 | debug_info['cached-delta.tested'] += 1 | |
|
887 | good = yield (cachedelta[0],) | |
|
888 | if good is not None: | |
|
889 | if debug_info is not None: | |
|
890 | debug_info['cached-delta.accepted'] += 1 | |
|
903 | # If sparse revlog is enabled, we can try to refine the available | |
|
904 | # deltas | |
|
905 | if not self.revlog.delta_config.sparse_revlog: | |
|
891 | 906 | yield None |
|
892 | 907 | return |
|
893 | if snapshot_cache is None: | |
|
894 | snapshot_cache = SnapshotCache() | |
|
895 | groups = _rawgroups( | |
|
896 | revlog, | |
|
897 | p1, | |
|
898 | p2, | |
|
899 | cachedelta, | |
|
900 | snapshot_cache, | |
|
901 | ) | |
|
902 | for candidates in groups: | |
|
903 | good = yield candidates | |
|
904 | if good is not None: | |
|
905 | break | |
|
906 | ||
|
907 | # If sparse revlog is enabled, we can try to refine the available deltas | |
|
908 | if not revlog.delta_config.sparse_revlog: | |
|
909 | yield None | |
|
910 | return | |
|
911 | 908 | |
|
912 | # if we have a refinable value, try to refine it | |
|
913 | if good is not None and good not in (p1, p2) and revlog.issnapshot(good): | |
|
914 | # refine snapshot down | |
|
915 | previous = None | |
|
916 | while previous != good: | |
|
917 | previous = good | |
|
918 | base = revlog.deltaparent(good) | |
|
919 | if base == nullrev: | |
|
920 | break | |
|
921 | good = yield (base,) | |
|
922 | # refine snapshot up | |
|
923 | if not snapshot_cache.snapshots: | |
|
924 | snapshot_cache.update(revlog, good + 1) | |
|
925 | previous = None | |
|
926 | while good != previous: | |
|
927 | previous = good | |
|
928 | children = tuple(sorted(c for c in snapshot_cache.snapshots[good])) | |
|
929 | good = yield children | |
|
909 | # if we have a refinable value, try to refine it | |
|
910 | if ( | |
|
911 | good is not None | |
|
912 | and good not in (self.p1, self.p2) | |
|
913 | and self.revlog.issnapshot(good) | |
|
914 | ): | |
|
915 | # refine snapshot down | |
|
916 | previous = None | |
|
917 | while previous != good: | |
|
918 | previous = good | |
|
919 | base = self.revlog.deltaparent(good) | |
|
920 | if base == nullrev: | |
|
921 | break | |
|
922 | good = yield (base,) | |
|
923 | # refine snapshot up | |
|
924 | if not self.snapshot_cache.snapshots: | |
|
925 | self.snapshot_cache.update(self.revlog, good + 1) | |
|
926 | previous = None | |
|
927 | while good != previous: | |
|
928 | previous = good | |
|
929 | children = tuple( | |
|
930 | sorted(c for c in self.snapshot_cache.snapshots[good]) | |
|
931 | ) | |
|
932 | good = yield children | |
|
930 | 933 | |
|
931 | if debug_info is not None: | |
|
932 | if good is None: | |
|
933 | debug_info['no-solution'] += 1 | |
|
934 | if debug_info is not None: | |
|
935 | if good is None: | |
|
936 | debug_info['no-solution'] += 1 | |
|
934 | 937 | |
|
935 | yield None | |
|
938 | yield None | |
|
936 | 939 | |
|
937 | 940 | |
|
938 | 941 | def _rawgroups(revlog, p1, p2, cachedelta, snapshot_cache=None): |
General Comments 0
You need to be logged in to leave comments.
Login now