mercurial/revlog.py
branchstable
changeset 32159 664d6f6c2a48
parent 32157 e9d325cfe071
child 33260 85d1ac011582
equal deleted inserted replaced
32157:e9d325cfe071 32159:664d6f6c2a48
   280         self._pcache = {}
   280         self._pcache = {}
   281         # Mapping of revision integer to full node.
   281         # Mapping of revision integer to full node.
   282         self._nodecache = {nullid: nullrev}
   282         self._nodecache = {nullid: nullrev}
   283         self._nodepos = None
   283         self._nodepos = None
   284         self._compengine = 'zlib'
   284         self._compengine = 'zlib'
   285         self._maxdeltachainspan = -1
       
   286 
   285 
   287         v = REVLOG_DEFAULT_VERSION
   286         v = REVLOG_DEFAULT_VERSION
   288         opts = getattr(opener, 'options', None)
   287         opts = getattr(opener, 'options', None)
   289         if opts is not None:
   288         if opts is not None:
   290             if 'revlogv1' in opts:
   289             if 'revlogv1' in opts:
   299             if 'aggressivemergedeltas' in opts:
   298             if 'aggressivemergedeltas' in opts:
   300                 self._aggressivemergedeltas = opts['aggressivemergedeltas']
   299                 self._aggressivemergedeltas = opts['aggressivemergedeltas']
   301             self._lazydeltabase = bool(opts.get('lazydeltabase', False))
   300             self._lazydeltabase = bool(opts.get('lazydeltabase', False))
   302             if 'compengine' in opts:
   301             if 'compengine' in opts:
   303                 self._compengine = opts['compengine']
   302                 self._compengine = opts['compengine']
   304             if 'maxdeltachainspan' in opts:
       
   305                 self._maxdeltachainspan = opts['maxdeltachainspan']
       
   306 
   303 
   307         if self._chunkcachesize <= 0:
   304         if self._chunkcachesize <= 0:
   308             raise RevlogError(_('revlog chunk cache size %r is not greater '
   305             raise RevlogError(_('revlog chunk cache size %r is not greater '
   309                                 'than 0') % self._chunkcachesize)
   306                                 'than 0') % self._chunkcachesize)
   310         elif self._chunkcachesize & (self._chunkcachesize - 1):
   307         elif self._chunkcachesize & (self._chunkcachesize - 1):
  1597         # - 'dist' is the distance from the base revision -- bounding it limits
  1594         # - 'dist' is the distance from the base revision -- bounding it limits
  1598         #   the amount of I/O we need to do.
  1595         #   the amount of I/O we need to do.
  1599         # - 'compresseddeltalen' is the sum of the total size of deltas we need
  1596         # - 'compresseddeltalen' is the sum of the total size of deltas we need
  1600         #   to apply -- bounding it limits the amount of CPU we consume.
  1597         #   to apply -- bounding it limits the amount of CPU we consume.
  1601         dist, l, data, base, chainbase, chainlen, compresseddeltalen = d
  1598         dist, l, data, base, chainbase, chainlen, compresseddeltalen = d
  1602 
  1599         if (dist > textlen * 4 or l > textlen or
  1603         defaultmax = textlen * 4
       
  1604         maxdist = self._maxdeltachainspan
       
  1605         if not maxdist:
       
  1606             maxdist = dist # ensure the conditional pass
       
  1607         maxdist = max(maxdist, defaultmax)
       
  1608         if (dist > maxdist or l > textlen or
       
  1609             compresseddeltalen > textlen * 2 or
  1600             compresseddeltalen > textlen * 2 or
  1610             (self._maxchainlen and chainlen > self._maxchainlen)):
  1601             (self._maxchainlen and chainlen > self._maxchainlen)):
  1611             return False
  1602             return False
  1612 
  1603 
  1613         return True
  1604         return True