mercurial/revlog.py
changeset 38116 bf59f95583c1
parent 38114 f79ba1d1b4b1
child 38117 69ec6f98cfa6
equal deleted inserted replaced
38115:b17fa9041695 38116:bf59f95583c1
  2091             except KeyError:
  2091             except KeyError:
  2092                 raise RevlogError(_('unknown compression type %r') % t)
  2092                 raise RevlogError(_('unknown compression type %r') % t)
  2093 
  2093 
  2094         return compressor.decompress(data)
  2094         return compressor.decompress(data)
  2095 
  2095 
  2096     def _isgooddeltainfo(self, d, textlen):
  2096     def _isgooddeltainfo(self, deltainfo, textlen):
  2097         """Returns True if the given delta is good. Good means that it is within
  2097         """Returns True if the given delta is good. Good means that it is within
  2098         the disk span, disk size, and chain length bounds that we know to be
  2098         the disk span, disk size, and chain length bounds that we know to be
  2099         performant."""
  2099         performant."""
  2100         if d is None:
  2100         if deltainfo is None:
  2101             return False
  2101             return False
  2102 
  2102 
  2103         # - 'd.distance' is the distance from the base revision -- bounding it
  2103         # - 'deltainfo.distance' is the distance from the base revision --
  2104         #   limits the amount of I/O we need to do.
  2104         #   bounding it limits the amount of I/O we need to do.
  2105         # - 'd.compresseddeltalen' is the sum of the total size of deltas we
  2105         # - 'deltainfo.compresseddeltalen' is the sum of the total size of
  2106         #   need to apply -- bounding it limits the amount of CPU we consume.
  2106         #   deltas we need to apply -- bounding it limits the amount of CPU
       
  2107         #   we consume.
  2107 
  2108 
  2108         defaultmax = textlen * 4
  2109         defaultmax = textlen * 4
  2109         maxdist = self._maxdeltachainspan
  2110         maxdist = self._maxdeltachainspan
  2110         if not maxdist:
  2111         if not maxdist:
  2111             maxdist = d.distance # ensure the conditional pass
  2112             maxdist = deltainfo.distance # ensure the conditional pass
  2112         maxdist = max(maxdist, defaultmax)
  2113         maxdist = max(maxdist, defaultmax)
  2113         if (d.distance > maxdist or d.deltalen > textlen or
  2114         if (deltainfo.distance > maxdist or deltainfo.deltalen > textlen or
  2114             d.compresseddeltalen > textlen * 2 or
  2115             deltainfo.compresseddeltalen > textlen * 2 or
  2115             (self._maxchainlen and d.chainlen > self._maxchainlen)):
  2116             (self._maxchainlen and deltainfo.chainlen > self._maxchainlen)):
  2116             return False
  2117             return False
  2117 
  2118 
  2118         return True
  2119         return True
  2119 
  2120 
  2120     def _addrevision(self, node, rawtext, transaction, link, p1, p2, flags,
  2121     def _addrevision(self, node, rawtext, transaction, link, p1, p2, flags,