Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/revlog.py @ 27250:bff71fe05768
revlog: make calls to _isgooddelta() consistent
We always want to call _isgooddelta() before accepting a delta. We
mostly call the function right after building the delta, but not
always. Instead, we have an extra call at the end of the big code
block. Let's make it consistent, so we call _isgooddelta() right after
builddelta() and exactly once per delta. That also lets us rely on
"delta is None" to mean we didn't find a good delta.
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Fri, 04 Dec 2015 17:14:14 -0800 |
parents | 0e5aab543d85 |
children | d9bfe6289acf |
comparison
equal
deleted
inserted
replaced
27249:0e5aab543d85 | 27250:bff71fe05768 |
---|---|
1448 if pdeltas: | 1448 if pdeltas: |
1449 delta = min(pdeltas, key=lambda x: x[1]) | 1449 delta = min(pdeltas, key=lambda x: x[1]) |
1450 if delta is None and prev not in tested: | 1450 if delta is None and prev not in tested: |
1451 # other approach failed try against prev to hopefully save us a | 1451 # other approach failed try against prev to hopefully save us a |
1452 # fulltext. | 1452 # fulltext. |
1453 delta = builddelta(prev) | 1453 candidatedelta = builddelta(prev) |
1454 if self._isgooddelta(candidatedelta, textlen): | |
1455 delta = candidatedelta | |
1454 if delta is not None: | 1456 if delta is not None: |
1455 dist, l, data, base, chainbase, chainlen, compresseddeltalen = delta | 1457 dist, l, data, base, chainbase, chainlen, compresseddeltalen = delta |
1456 | 1458 else: |
1457 if not self._isgooddelta(delta, textlen): | |
1458 text = buildtext() | 1459 text = buildtext() |
1459 data = self.compress(text) | 1460 data = self.compress(text) |
1460 l = len(data[1]) + len(data[0]) | 1461 l = len(data[1]) + len(data[0]) |
1461 base = chainbase = curr | 1462 base = chainbase = curr |
1462 | 1463 |