##// END OF EJS Templates
delta-find: introduce a base class for _DeltaSearch...
marmoute -
r52239:2a333d79 default
parent child Browse files
Show More
@@ -8,6 +8,7 b''
8 """Helper class to compute deltas stored inside revlogs"""
8 """Helper class to compute deltas stored inside revlogs"""
9
9
10
10
11 import abc
11 import collections
12 import collections
12 import struct
13 import struct
13
14
@@ -590,7 +591,7 b' def drop_u_compression(delta):'
590 LIMIT_BASE2TEXT = 500
591 LIMIT_BASE2TEXT = 500
591
592
592
593
593 class _DeltaSearch:
594 class _BaseDeltaSearch(abc.ABC):
594 """perform the search of a good delta for a single revlog revision
595 """perform the search of a good delta for a single revlog revision
595
596
596 note: some of the deltacomputer.finddeltainfo logic should probably move
597 note: some of the deltacomputer.finddeltainfo logic should probably move
@@ -633,9 +634,8 b' class _DeltaSearch:'
633
634
634 self.tested = {nullrev}
635 self.tested = {nullrev}
635
636
636 self._candidates_iterator = self._candidate_groups()
637 self.current_group = None
637 self._last_good = None
638 self._init_group()
638 self.current_group = self._candidates_iterator.send(self._last_good)
639
639
640 def is_good_delta_info(self, deltainfo):
640 def is_good_delta_info(self, deltainfo):
641 """Returns True if the given delta is good.
641 """Returns True if the given delta is good.
@@ -764,6 +764,7 b' class _DeltaSearch:'
764 """True when all possible candidate have been tested"""
764 """True when all possible candidate have been tested"""
765 return self.current_group is None
765 return self.current_group is None
766
766
767 @abc.abstractmethod
767 def next_group(self, good_delta=None):
768 def next_group(self, good_delta=None):
768 """move to the next group to test
769 """move to the next group to test
769
770
@@ -775,6 +776,20 b' class _DeltaSearch:'
775 If not revision remains to be, `self.done` will be True and
776 If not revision remains to be, `self.done` will be True and
776 `self.current_group` will be None.
777 `self.current_group` will be None.
777 """
778 """
779 pass
780
781 @abc.abstractmethod
782 def _init_group(self):
783 pass
784
785
786 class _DeltaSearch(_BaseDeltaSearch):
787 def _init_group(self):
788 self._candidates_iterator = self._candidate_groups()
789 self._last_good = None
790 self.current_group = self._candidates_iterator.send(self._last_good)
791
792 def next_group(self, good_delta=None):
778 if good_delta is not None:
793 if good_delta is not None:
779 self._last_good = good_delta.base
794 self._last_good = good_delta.base
780 self.current_group = self._candidates_iterator.send(self._last_good)
795 self.current_group = self._candidates_iterator.send(self._last_good)
General Comments 0
You need to be logged in to leave comments. Login now