mercurial/revlogutils/deltas.py
changeset 51352 7083b33a2699
parent 51351 bbbfa00d1e67
child 51353 5cc04a6da19d
equal deleted inserted replaced
51351:bbbfa00d1e67 51352:7083b33a2699
   838         # Why search for delta base if we cannot use a delta base ?
   838         # Why search for delta base if we cannot use a delta base ?
   839         # also see issue6056
   839         # also see issue6056
   840         assert self.revlog.delta_config.general_delta
   840         assert self.revlog.delta_config.general_delta
   841         self._candidates_iterator = self._refined_groups()
   841         self._candidates_iterator = self._refined_groups()
   842         self._last_good = None
   842         self._last_good = None
   843         self._next_internal_group()
   843         if (
       
   844             self.cachedelta is not None
       
   845             and self.cachedelta[2] > DELTA_BASE_REUSE_NO
       
   846             and self._pre_filter_rev(self.cachedelta[0])
       
   847         ):
       
   848             # First we try to reuse a the delta contained in the bundle.  (or from
       
   849             # the source revlog)
       
   850             #
       
   851             # This logic only applies to general delta repositories and can be
       
   852             # disabled through configuration. Disabling reuse source delta is
       
   853             # useful when we want to make sure we recomputed "optimal" deltas.
       
   854             self.current_stage = _STAGE_CACHED
       
   855             self._internal_group = (self.cachedelta[0],)
       
   856             self._internal_idx = 0
       
   857             self.current_group = self._internal_group
       
   858             self.tested.update(self.current_group)
       
   859         else:
       
   860             self._next_internal_group()
   844 
   861 
   845     def _next_internal_group(self):
   862     def _next_internal_group(self):
   846         # self._internal_group can be larger than self.current_group
   863         # self._internal_group can be larger than self.current_group
   847         self._internal_idx = 0
   864         self._internal_idx = 0
   848         group = self._candidates_iterator.send(self._last_good)
   865         group = self._candidates_iterator.send(self._last_good)
   866 
   883 
   867     def next_group(self, good_delta=None):
   884     def next_group(self, good_delta=None):
   868         old_good = self._last_good
   885         old_good = self._last_good
   869         if good_delta is not None:
   886         if good_delta is not None:
   870             self._last_good = good_delta.base
   887             self._last_good = good_delta.base
       
   888         if self.current_stage == _STAGE_CACHED and good_delta is not None:
       
   889             # the cache is good, let us use the cache as requested
       
   890             self._candidates_iterator = None
       
   891             self._internal_group = None
       
   892             self._internal_idx = None
       
   893             self.current_group = None
       
   894             return
       
   895 
   871         if (self._internal_idx < len(self._internal_group)) and (
   896         if (self._internal_idx < len(self._internal_group)) and (
   872             old_good != good_delta
   897             old_good != good_delta
   873         ):
   898         ):
   874             # When the size of the candidate group is big, it can result in
   899             # When the size of the candidate group is big, it can result in
   875             # a quite significant performance impact. To reduce this, we
   900             # a quite significant performance impact. To reduce this, we
  1030 
  1055 
  1031         return True
  1056         return True
  1032 
  1057 
  1033     def _refined_groups(self):
  1058     def _refined_groups(self):
  1034         good = None
  1059         good = None
  1035         # First we try to reuse a the delta contained in the bundle.  (or from
       
  1036         # the source revlog)
       
  1037         #
       
  1038         # This logic only applies to general delta repositories and can be
       
  1039         # disabled through configuration. Disabling reuse source delta is
       
  1040         # useful when we want to make sure we recomputed "optimal" deltas.
       
  1041         if (
       
  1042             self.cachedelta is not None
       
  1043             and self.cachedelta[2] > DELTA_BASE_REUSE_NO
       
  1044         ):
       
  1045             # Assume what we received from the server is a good choice
       
  1046             # build delta will reuse the cache
       
  1047             self.current_stage = _STAGE_CACHED
       
  1048             good = yield (self.cachedelta[0],)
       
  1049             if good is not None:
       
  1050                 yield None
       
  1051                 return
       
  1052         groups = self._raw_groups()
  1060         groups = self._raw_groups()
  1053         for candidates in groups:
  1061         for candidates in groups:
  1054             good = yield candidates
  1062             good = yield candidates
  1055             if good is not None:
  1063             if good is not None:
  1056                 break
  1064                 break