Mercurial > hg
comparison mercurial/revlog.py @ 26116:562cfc99e611
revlog: move textlen calculation to be above delta chooser
This moves the textlen calculation to be above the delta chooser. Since textlen
is needed for calling isgooddelta, we need it above the delta chooser so future
patches can call isgooddelta.
author | Durham Goode <durham@fb.com> |
---|---|
date | Sun, 30 Aug 2015 13:34:30 -0700 |
parents | 748347e0e8d4 |
children | 4dc5b51f38fe |
comparison
equal
deleted
inserted
replaced
26115:748347e0e8d4 | 26116:562cfc99e611 |
---|---|
1330 if self._basecache is None: | 1330 if self._basecache is None: |
1331 self._basecache = (prev, self.chainbase(prev)) | 1331 self._basecache = (prev, self.chainbase(prev)) |
1332 basecache = self._basecache | 1332 basecache = self._basecache |
1333 p1r, p2r = self.rev(p1), self.rev(p2) | 1333 p1r, p2r = self.rev(p1), self.rev(p2) |
1334 | 1334 |
1335 # full versions are inserted when the needed deltas | |
1336 # become comparable to the uncompressed text | |
1337 if text is None: | |
1338 textlen = mdiff.patchedsize(self.rawsize(cachedelta[0]), | |
1339 cachedelta[1]) | |
1340 else: | |
1341 textlen = len(text) | |
1342 | |
1335 # should we try to build a delta? | 1343 # should we try to build a delta? |
1336 if prev != nullrev: | 1344 if prev != nullrev: |
1337 if self._generaldelta: | 1345 if self._generaldelta: |
1338 if p1r >= basecache[1]: | 1346 if p1r >= basecache[1]: |
1339 d = builddelta(p1r) | 1347 d = builddelta(p1r) |
1342 else: | 1350 else: |
1343 d = builddelta(prev) | 1351 d = builddelta(prev) |
1344 else: | 1352 else: |
1345 d = builddelta(prev) | 1353 d = builddelta(prev) |
1346 dist, l, data, base, chainbase, chainlen, compresseddeltalen = d | 1354 dist, l, data, base, chainbase, chainlen, compresseddeltalen = d |
1347 | |
1348 # full versions are inserted when the needed deltas | |
1349 # become comparable to the uncompressed text | |
1350 if text is None: | |
1351 textlen = mdiff.patchedsize(self.rawsize(cachedelta[0]), | |
1352 cachedelta[1]) | |
1353 else: | |
1354 textlen = len(text) | |
1355 | 1355 |
1356 if not self._isgooddelta(d, textlen): | 1356 if not self._isgooddelta(d, textlen): |
1357 text = buildtext() | 1357 text = buildtext() |
1358 data = self.compress(text) | 1358 data = self.compress(text) |
1359 l = len(data[1]) + len(data[0]) | 1359 l = len(data[1]) + len(data[0]) |