Mercurial > public > mercurial-scm > hg
comparison mercurial/revlog.py @ 27178:5ebc4a192550
addrevision: rename 'd' to 'delta'
That variable is quite central to the whole function. Giving it a more explicit
name help with code readability.
author | Pierre-Yves David <pierre-yves.david@fb.com> |
---|---|
date | Tue, 01 Dec 2015 15:29:11 -0800 |
parents | 7860366b46c9 |
children | b481bf14992d |
comparison
equal
deleted
inserted
replaced
27177:e76b27a642ca | 27178:5ebc4a192550 |
---|---|
1406 curr = len(self) | 1406 curr = len(self) |
1407 prev = curr - 1 | 1407 prev = curr - 1 |
1408 base = chainbase = curr | 1408 base = chainbase = curr |
1409 chainlen = None | 1409 chainlen = None |
1410 offset = self.end(prev) | 1410 offset = self.end(prev) |
1411 d = None | 1411 delta = None |
1412 if self._basecache is None: | 1412 if self._basecache is None: |
1413 self._basecache = (prev, self.chainbase(prev)) | 1413 self._basecache = (prev, self.chainbase(prev)) |
1414 basecache = self._basecache | 1414 basecache = self._basecache |
1415 p1r, p2r = self.rev(p1), self.rev(p2) | 1415 p1r, p2r = self.rev(p1), self.rev(p2) |
1416 | 1416 |
1425 # should we try to build a delta? | 1425 # should we try to build a delta? |
1426 if prev != nullrev: | 1426 if prev != nullrev: |
1427 if cachedelta and self._generaldelta and self._lazydeltabase: | 1427 if cachedelta and self._generaldelta and self._lazydeltabase: |
1428 # Assume what we received from the server is a good choice | 1428 # Assume what we received from the server is a good choice |
1429 # build delta will reuse the cache | 1429 # build delta will reuse the cache |
1430 d = builddelta(cachedelta[0]) | 1430 delta = builddelta(cachedelta[0]) |
1431 elif self._generaldelta: | 1431 elif self._generaldelta: |
1432 if p2r != nullrev and self._aggressivemergedeltas: | 1432 if p2r != nullrev and self._aggressivemergedeltas: |
1433 d = builddelta(p1r) | 1433 delta = builddelta(p1r) |
1434 d2 = builddelta(p2r) | 1434 delta2 = builddelta(p2r) |
1435 p1good = self._isgooddelta(d, textlen) | 1435 p1good = self._isgooddelta(delta, textlen) |
1436 p2good = self._isgooddelta(d2, textlen) | 1436 p2good = self._isgooddelta(delta2, textlen) |
1437 if p1good and p2good: | 1437 if p1good and p2good: |
1438 # If both are good deltas, choose the smallest | 1438 # If both are good deltas, choose the smallest |
1439 if d2[1] < d[1]: | 1439 if delta2[1] < delta[1]: |
1440 d = d2 | 1440 delta = delta2 |
1441 elif p2good: | 1441 elif p2good: |
1442 # If only p2 is good, use it | 1442 # If only p2 is good, use it |
1443 d = d2 | 1443 delta = delta2 |
1444 elif p1good: | 1444 elif p1good: |
1445 pass | 1445 pass |
1446 else: | 1446 else: |
1447 # Neither is good, try against prev to hopefully save us | 1447 # Neither is good, try against prev to hopefully save us |
1448 # a fulltext. | 1448 # a fulltext. |
1449 d = builddelta(prev) | 1449 delta = builddelta(prev) |
1450 else: | 1450 else: |
1451 # Pick whichever parent is closer to us (to minimize the | 1451 # Pick whichever parent is closer to us (to minimize the |
1452 # chance of having to build a fulltext). Since | 1452 # chance of having to build a fulltext). Since |
1453 # nullrev == -1, any non-merge commit will always pick p1r. | 1453 # nullrev == -1, any non-merge commit will always pick p1r. |
1454 drev = p2r if p2r > p1r else p1r | 1454 drev = p2r if p2r > p1r else p1r |
1455 d = builddelta(drev) | 1455 delta = builddelta(drev) |
1456 # If the chosen delta will result in us making a full text, | 1456 # If the chosen delta will result in us making a full text, |
1457 # give it one last try against prev. | 1457 # give it one last try against prev. |
1458 if drev != prev and not self._isgooddelta(d, textlen): | 1458 if drev != prev and not self._isgooddelta(delta, textlen): |
1459 d = builddelta(prev) | 1459 delta = builddelta(prev) |
1460 else: | 1460 else: |
1461 d = builddelta(prev) | 1461 delta = builddelta(prev) |
1462 dist, l, data, base, chainbase, chainlen, compresseddeltalen = d | 1462 dist, l, data, base, chainbase, chainlen, compresseddeltalen = delta |
1463 | 1463 |
1464 if not self._isgooddelta(d, textlen): | 1464 if not self._isgooddelta(delta, textlen): |
1465 text = buildtext() | 1465 text = buildtext() |
1466 data = self.compress(text) | 1466 data = self.compress(text) |
1467 l = len(data[1]) + len(data[0]) | 1467 l = len(data[1]) + len(data[0]) |
1468 base = chainbase = curr | 1468 base = chainbase = curr |
1469 | 1469 |