comparison mercurial/revlog.py @ 23287:426d7f901789

revlog: bound based on the length of the compressed deltas This is only relevant for generaldelta clones.
author Siddharth Agarwal <sid0@fb.com>
date Tue, 11 Nov 2014 20:01:19 -0800
parents 40e0067899d4
children 2b9bc7963504
comparison
equal deleted inserted replaced
23286:40e0067899d4 23287:426d7f901789
1223 dist = l + offset - self.start(chainbase) 1223 dist = l + offset - self.start(chainbase)
1224 if self._generaldelta: 1224 if self._generaldelta:
1225 base = rev 1225 base = rev
1226 else: 1226 else:
1227 base = chainbase 1227 base = chainbase
1228 chainlen = self.chainlen(rev) + 1 1228 chainlen, compresseddeltalen = self._chaininfo(rev)
1229 return dist, l, data, base, chainbase, chainlen 1229 chainlen += 1
1230 compresseddeltalen += l
1231 return dist, l, data, base, chainbase, chainlen, compresseddeltalen
1230 1232
1231 curr = len(self) 1233 curr = len(self)
1232 prev = curr - 1 1234 prev = curr - 1
1233 base = chainbase = curr 1235 base = chainbase = curr
1234 chainlen = None 1236 chainlen = None
1249 d = builddelta(p2r) 1251 d = builddelta(p2r)
1250 else: 1252 else:
1251 d = builddelta(prev) 1253 d = builddelta(prev)
1252 else: 1254 else:
1253 d = builddelta(prev) 1255 d = builddelta(prev)
1254 dist, l, data, base, chainbase, chainlen = d 1256 dist, l, data, base, chainbase, chainlen, compresseddeltalen = d
1255 1257
1256 # full versions are inserted when the needed deltas 1258 # full versions are inserted when the needed deltas
1257 # become comparable to the uncompressed text 1259 # become comparable to the uncompressed text
1258 if text is None: 1260 if text is None:
1259 textlen = mdiff.patchedsize(self.rawsize(cachedelta[0]), 1261 textlen = mdiff.patchedsize(self.rawsize(cachedelta[0]),
1260 cachedelta[1]) 1262 cachedelta[1])
1261 else: 1263 else:
1262 textlen = len(text) 1264 textlen = len(text)
1265
1266 # - 'dist' is the distance from the base revision -- bounding it limits
1267 # the amount of I/O we need to do.
1268 # - 'compresseddeltalen' is the sum of the total size of deltas we need
1269 # to apply -- bounding it limits the amount of CPU we consume.
1263 if (d is None or dist > textlen * 2 or l > textlen or 1270 if (d is None or dist > textlen * 2 or l > textlen or
1271 compresseddeltalen > textlen * 2 or
1264 (self._maxchainlen and chainlen > self._maxchainlen)): 1272 (self._maxchainlen and chainlen > self._maxchainlen)):
1265 text = buildtext() 1273 text = buildtext()
1266 data = self.compress(text) 1274 data = self.compress(text)
1267 l = len(data[1]) + len(data[0]) 1275 l = len(data[1]) + len(data[0])
1268 base = chainbase = curr 1276 base = chainbase = curr