mercurial/revlogutils/deltas.py
changeset 51068 533d6943f6a3
parent 51067 8c614fa16330
child 51072 26dcdbe15024
equal deleted inserted replaced
51067:8c614fa16330 51068:533d6943f6a3
    48     def __init__(self, data, density=0.5, mingap=0, snapshot=()):
    48     def __init__(self, data, density=0.5, mingap=0, snapshot=()):
    49         """data is an list of revision payload boundaries"""
    49         """data is an list of revision payload boundaries"""
    50         from .. import revlog
    50         from .. import revlog
    51 
    51 
    52         self._data = data
    52         self._data = data
    53         self._srmingapsize = mingap
       
    54         self.data_config = revlog.DataConfig()
    53         self.data_config = revlog.DataConfig()
    55         self.data_config.sr_density_threshold = density
    54         self.data_config.sr_density_threshold = density
    56         self.data_config.sr_min_gap_size = mingap
    55         self.data_config.sr_min_gap_size = mingap
    57         self.delta_config = revlog.DeltaConfig()
    56         self.delta_config = revlog.DeltaConfig()
    58         self.feature_config = revlog.FeatureConfig()
    57         self.feature_config = revlog.FeatureConfig()
    89     ``revs`` is sliced into groups that should be read in one time.
    88     ``revs`` is sliced into groups that should be read in one time.
    90     Assume that revs are sorted.
    89     Assume that revs are sorted.
    91 
    90 
    92     The initial chunk is sliced until the overall density (payload/chunks-span
    91     The initial chunk is sliced until the overall density (payload/chunks-span
    93     ratio) is above `revlog.data_config.sr_density_threshold`. No gap smaller
    92     ratio) is above `revlog.data_config.sr_density_threshold`. No gap smaller
    94     than `revlog._srmingapsize` is skipped.
    93     than `revlog.data_config.sr_min_gap_size` is skipped.
    95 
    94 
    96     If `targetsize` is set, no chunk larger than `targetsize` will be yield.
    95     If `targetsize` is set, no chunk larger than `targetsize` will be yield.
    97     For consistency with other slicing choice, this limit won't go lower than
    96     For consistency with other slicing choice, this limit won't go lower than
    98     `revlog._srmingapsize`.
    97     `revlog.data_config.sr_min_gap_size`.
    99 
    98 
   100     If individual revisions chunk are larger than this limit, they will still
    99     If individual revisions chunk are larger than this limit, they will still
   101     be raised individually.
   100     be raised individually.
   102 
   101 
   103     >>> data = [
   102     >>> data = [
   142     [[-1, 0], [11], [13, 15]]
   141     [[-1, 0], [11], [13, 15]]
   143     >>> list(slicechunk(revlog, [-1, 13, 15], targetsize=5))
   142     >>> list(slicechunk(revlog, [-1, 13, 15], targetsize=5))
   144     [[-1], [13], [15]]
   143     [[-1], [13], [15]]
   145     """
   144     """
   146     if targetsize is not None:
   145     if targetsize is not None:
   147         targetsize = max(targetsize, revlog._srmingapsize)
   146         targetsize = max(targetsize, revlog.data_config.sr_min_gap_size)
   148     # targetsize should not be specified when evaluating delta candidates:
   147     # targetsize should not be specified when evaluating delta candidates:
   149     # * targetsize is used to ensure we stay within specification when reading,
   148     # * targetsize is used to ensure we stay within specification when reading,
   150     densityslicing = getattr(revlog.index, 'slicechunktodensity', None)
   149     densityslicing = getattr(revlog.index, 'slicechunktodensity', None)
   151     if densityslicing is None:
   150     if densityslicing is None:
   152         densityslicing = lambda x, y, z: _slicechunktodensity(revlog, x, y, z)
   151         densityslicing = lambda x, y, z: _slicechunktodensity(revlog, x, y, z)
   153     for chunk in densityslicing(
   152     for chunk in densityslicing(
   154         revs, revlog.data_config.sr_density_threshold, revlog._srmingapsize
   153         revs,
       
   154         revlog.data_config.sr_density_threshold,
       
   155         revlog.data_config.sr_min_gap_size,
   155     ):
   156     ):
   156         for subchunk in _slicechunktosize(revlog, chunk, targetsize):
   157         for subchunk in _slicechunktosize(revlog, chunk, targetsize):
   157             yield subchunk
   158             yield subchunk
   158 
   159 
   159 
   160