Show More
@@ -279,6 +279,7 b' class _revisioninfo(object):' | |||||
279 | p1 = attr.ib() |
|
279 | p1 = attr.ib() | |
280 | p2 = attr.ib() |
|
280 | p2 = attr.ib() | |
281 | btext = attr.ib() |
|
281 | btext = attr.ib() | |
|
282 | textlen = attr.ib() | |||
282 | cachedelta = attr.ib() |
|
283 | cachedelta = attr.ib() | |
283 | flags = attr.ib() |
|
284 | flags = attr.ib() | |
284 |
|
285 | |||
@@ -1987,6 +1988,33 b' class revlog(object):' | |||||
1987 | return _deltainfo(dist, deltalen, (header, data), deltabase, |
|
1988 | return _deltainfo(dist, deltalen, (header, data), deltabase, | |
1988 | chainbase, chainlen, compresseddeltalen) |
|
1989 | chainbase, chainlen, compresseddeltalen) | |
1989 |
|
1990 | |||
|
1991 | def _finddeltainfo(self, revinfo, fh): | |||
|
1992 | """Find an acceptable delta against a candidate revision | |||
|
1993 | ||||
|
1994 | revinfo: information about the revision (instance of _revisioninfo) | |||
|
1995 | fh: file handle to either the .i or the .d revlog file, | |||
|
1996 | depending on whether it is inlined or not | |||
|
1997 | ||||
|
1998 | Returns the first acceptable candidate revision, as ordered by | |||
|
1999 | _getcandidaterevs | |||
|
2000 | """ | |||
|
2001 | cachedelta = revinfo.cachedelta | |||
|
2002 | p1 = revinfo.p1 | |||
|
2003 | p2 = revinfo.p2 | |||
|
2004 | ||||
|
2005 | deltainfo = None | |||
|
2006 | for candidaterevs in self._getcandidaterevs(p1, p2, cachedelta): | |||
|
2007 | nominateddeltas = [] | |||
|
2008 | for candidaterev in candidaterevs: | |||
|
2009 | candidatedelta = self._builddeltainfo(revinfo, candidaterev, fh) | |||
|
2010 | if self._isgooddeltainfo(candidatedelta, revinfo.textlen): | |||
|
2011 | nominateddeltas.append(candidatedelta) | |||
|
2012 | if nominateddeltas: | |||
|
2013 | deltainfo = min(nominateddeltas, key=lambda x: x.deltalen) | |||
|
2014 | break | |||
|
2015 | ||||
|
2016 | return deltainfo | |||
|
2017 | ||||
1990 | def _addrevision(self, node, rawtext, transaction, link, p1, p2, flags, |
|
2018 | def _addrevision(self, node, rawtext, transaction, link, p1, p2, flags, | |
1991 | cachedelta, ifh, dfh, alwayscache=False): |
|
2019 | cachedelta, ifh, dfh, alwayscache=False): | |
1992 | """internal function to add revisions to the log |
|
2020 | """internal function to add revisions to the log | |
@@ -2016,7 +2044,6 b' class revlog(object):' | |||||
2016 | curr = len(self) |
|
2044 | curr = len(self) | |
2017 | prev = curr - 1 |
|
2045 | prev = curr - 1 | |
2018 | offset = self.end(prev) |
|
2046 | offset = self.end(prev) | |
2019 | deltainfo = None |
|
|||
2020 | p1r, p2r = self.rev(p1), self.rev(p2) |
|
2047 | p1r, p2r = self.rev(p1), self.rev(p2) | |
2021 |
|
2048 | |||
2022 | # full versions are inserted when the needed deltas |
|
2049 | # full versions are inserted when the needed deltas | |
@@ -2027,16 +2054,8 b' class revlog(object):' | |||||
2027 | else: |
|
2054 | else: | |
2028 | textlen = len(rawtext) |
|
2055 | textlen = len(rawtext) | |
2029 |
|
2056 | |||
2030 | revinfo = _revisioninfo(node, p1, p2, btext, cachedelta, flags) |
|
2057 | revinfo = _revisioninfo(node, p1, p2, btext, textlen, cachedelta, flags) | |
2031 | for candidaterevs in self._getcandidaterevs(p1, p2, cachedelta): |
|
2058 | deltainfo = self._finddeltainfo(revinfo, fh) | |
2032 | nominateddeltas = [] |
|
|||
2033 | for candidaterev in candidaterevs: |
|
|||
2034 | candidatedelta = self._builddeltainfo(revinfo, candidaterev, fh) |
|
|||
2035 | if self._isgooddeltainfo(candidatedelta, textlen): |
|
|||
2036 | nominateddeltas.append(candidatedelta) |
|
|||
2037 | if nominateddeltas: |
|
|||
2038 | deltainfo = min(nominateddeltas, key=lambda x: x.deltalen) |
|
|||
2039 | break |
|
|||
2040 |
|
2059 | |||
2041 | if deltainfo is not None: |
|
2060 | if deltainfo is not None: | |
2042 | base = deltainfo.base |
|
2061 | base = deltainfo.base |
General Comments 0
You need to be logged in to leave comments.
Login now