comparison mercurial/revlogutils/deltas.py @ 49612:e706bb41fdb3

delta-find: move pre-filtering with other pre-filtering logic This is more consistent and will help use to be in a clean state before dealing with the "too large group" issue. As a side effect, the debug output now skip some useless cases, making it more useful.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Sun, 06 Nov 2022 12:51:50 -0500
parents 2afee2176775
children 5447c1507c86
comparison
equal deleted inserted replaced
49611:2afee2176775 49612:e706bb41fdb3
659 revlog, 659 revlog,
660 textlen, 660 textlen,
661 p1, 661 p1,
662 p2, 662 p2,
663 cachedelta, 663 cachedelta,
664 excluded_bases=None,
665 target_rev=None,
664 ): 666 ):
665 """Provides group of revision to be tested as delta base 667 """Provides group of revision to be tested as delta base
666 668
667 This top level function focus on emitting groups with unique and worthwhile 669 This top level function focus on emitting groups with unique and worthwhile
668 content. See _raw_candidate_groups for details about the group order. 670 content. See _raw_candidate_groups for details about the group order.
704 continue 706 continue
705 # filter out revision we tested already 707 # filter out revision we tested already
706 if rev in tested: 708 if rev in tested:
707 continue 709 continue
708 tested.add(rev) 710 tested.add(rev)
711 # an higher authority deamed the base unworthy (e.g. censored)
712 if excluded_bases is not None and rev in excluded_bases:
713 continue
714 # We are in some recomputation cases and that rev is too high in
715 # the revlog
716 if target_rev is not None and rev >= target_rev:
717 continue
709 # filter out delta base that will never produce good delta 718 # filter out delta base that will never produce good delta
710 if deltas_limit < revlog.length(rev): 719 if deltas_limit < revlog.length(rev):
711 continue 720 continue
712 if sparse and revlog.rawsize(rev) < (textlen // LIMIT_BASE2TEXT): 721 if sparse and revlog.rawsize(rev) < (textlen // LIMIT_BASE2TEXT):
713 continue 722 continue
1178 self.revlog, 1187 self.revlog,
1179 revinfo.textlen, 1188 revinfo.textlen,
1180 p1r, 1189 p1r,
1181 p2r, 1190 p2r,
1182 cachedelta, 1191 cachedelta,
1192 excluded_bases,
1193 target_rev,
1183 ) 1194 )
1184 candidaterevs = next(groups) 1195 candidaterevs = next(groups)
1185 while candidaterevs is not None: 1196 while candidaterevs is not None:
1186 dbg_try_rounds += 1 1197 dbg_try_rounds += 1
1187 if debug_search: 1198 if debug_search:
1241 msg %= self.revlog.length(candidaterev) 1252 msg %= self.revlog.length(candidaterev)
1242 self._write_debug(msg) 1253 self._write_debug(msg)
1243 msg = b"DBG-DELTAS-SEARCH: base=%d\n" 1254 msg = b"DBG-DELTAS-SEARCH: base=%d\n"
1244 msg %= self.revlog.deltaparent(candidaterev) 1255 msg %= self.revlog.deltaparent(candidaterev)
1245 self._write_debug(msg) 1256 self._write_debug(msg)
1246 if candidaterev in excluded_bases: 1257
1247 if debug_search:
1248 msg = b"DBG-DELTAS-SEARCH: EXCLUDED\n"
1249 self._write_debug(msg)
1250 continue
1251 if candidaterev >= target_rev:
1252 if debug_search:
1253 msg = b"DBG-DELTAS-SEARCH: TOO-HIGH\n"
1254 self._write_debug(msg)
1255 continue
1256 dbg_try_count += 1 1258 dbg_try_count += 1
1257 1259
1258 if debug_search: 1260 if debug_search:
1259 delta_start = util.timer() 1261 delta_start = util.timer()
1260 candidatedelta = self._builddeltainfo(revinfo, candidaterev, fh) 1262 candidatedelta = self._builddeltainfo(revinfo, candidaterev, fh)