##// END OF EJS Templates
revlogdeltas: split candidate groups selection from the filtering logic...
Boris Feld -
r39372:1c6ff52f default
parent child Browse files
Show More
@@ -569,9 +569,29 b' def isgooddeltainfo(revlog, deltainfo, r'
569 569 return True
570 570
571 571 def _candidategroups(revlog, p1, p2, cachedelta):
572 """Provides group of revision to be tested as delta base
573
574 This top level function focus on emitting groups with unique and worthwhile
575 content. See _raw_candidate_groups for details about the group order.
572 576 """
573 Provides revisions that present an interest to be diffed against,
574 grouped by level of easiness.
577 # should we try to build a delta?
578 if not (len(revlog) and revlog._storedeltachains):
579 return
580
581 tested = set([nullrev])
582 for group in _rawgroups(revlog, p1, p2, cachedelta):
583 group = tuple(r for r in group if r not in tested)
584 tested.update(group)
585 if group:
586 yield group
587
588 def _rawgroups(revlog, p1, p2, cachedelta):
589 """Provides group of revision to be tested as delta base
590
591 This lower level function focus on emitting delta theorically interresting
592 without looking it any practical details.
593
594 The group order aims at providing fast or small candidates first.
575 595 """
576 596 gdelta = revlog._generaldelta
577 597 curr = len(revlog)
@@ -590,10 +610,18 b' def _candidategroups(revlog, p1, p2, cac'
590 610 yield (cachedelta[0],)
591 611 tested.add(cachedelta[0])
592 612
613 # This condition is true most of the time when processing
614 # changegroup data into a generaldelta repo. The only time it
615 # isn't true is if this is the first revision in a delta chain
616 # or if ``format.generaldelta=true`` disabled ``lazydeltabase``.
617 if cachedelta and gdelta and revlog._lazydeltabase:
618 # Assume what we received from the server is a good choice
619 # build delta will reuse the cache
620 yield (cachedelta[0],)
621
593 622 if gdelta:
594 623 # exclude already lazy tested base if any
595 parents = [p for p in (p1, p2)
596 if p != nullrev and p not in tested]
624 parents = [p for p in (p1, p2) if p != nullrev]
597 625
598 626 if not revlog._deltabothparents and len(parents) == 2:
599 627 parents.sort()
@@ -602,17 +630,13 b' def _candidategroups(revlog, p1, p2, cac'
602 630 yield (parents[1],)
603 631 # then the other one (min rev) if the first did not fit
604 632 yield (parents[0],)
605 tested.update(parents)
606 633 elif len(parents) > 0:
607 634 # Test all parents (1 or 2), and keep the best candidate
608 635 yield parents
609 tested.update(parents)
610 636
611 if prev not in tested:
612 637 # other approach failed try against prev to hopefully save us a
613 638 # fulltext.
614 639 yield (prev,)
615 tested.add(prev)
616 640
617 641 class deltacomputer(object):
618 642 def __init__(self, revlog):
General Comments 0
You need to be logged in to leave comments. Login now