Show More
@@ -1967,31 +1967,23 b' class revlog(object):' | |||||
1967 |
|
1967 | |||
1968 | deltainfo = deltacomputer.finddeltainfo(revinfo, fh) |
|
1968 | deltainfo = deltacomputer.finddeltainfo(revinfo, fh) | |
1969 |
|
1969 | |||
1970 | if deltainfo is not None: |
|
1970 | e = (offset_type(offset, flags), deltainfo.deltalen, textlen, | |
1971 |
|
|
1971 | deltainfo.base, link, p1r, p2r, node) | |
1972 | chainbase = deltainfo.chainbase |
|
|||
1973 | data = deltainfo.data |
|
|||
1974 | l = deltainfo.deltalen |
|
|||
1975 | else: |
|
|||
1976 | rawtext = deltacomputer.buildtext(revinfo, fh) |
|
|||
1977 | data = self.compress(rawtext) |
|
|||
1978 | l = len(data[1]) + len(data[0]) |
|
|||
1979 | base = chainbase = curr |
|
|||
1980 |
|
||||
1981 | e = (offset_type(offset, flags), l, textlen, |
|
|||
1982 | base, link, p1r, p2r, node) |
|
|||
1983 | self.index.append(e) |
|
1972 | self.index.append(e) | |
1984 | self.nodemap[node] = curr |
|
1973 | self.nodemap[node] = curr | |
1985 |
|
1974 | |||
1986 | entry = self._io.packentry(e, self.node, self.version, curr) |
|
1975 | entry = self._io.packentry(e, self.node, self.version, curr) | |
1987 |
self._writeentry(transaction, ifh, dfh, entry, data, |
|
1976 | self._writeentry(transaction, ifh, dfh, entry, deltainfo.data, | |
|
1977 | link, offset) | |||
|
1978 | ||||
|
1979 | rawtext = btext[0] | |||
1988 |
|
1980 | |||
1989 | if alwayscache and rawtext is None: |
|
1981 | if alwayscache and rawtext is None: | |
1990 | rawtext = deltacomputer.buildtext(revinfo, fh) |
|
1982 | rawtext = deltacomputer.buildtext(revinfo, fh) | |
1991 |
|
1983 | |||
1992 | if type(rawtext) == bytes: # only accept immutable objects |
|
1984 | if type(rawtext) == bytes: # only accept immutable objects | |
1993 | self._cache = (node, curr, rawtext) |
|
1985 | self._cache = (node, curr, rawtext) | |
1994 | self._chainbasecache[curr] = chainbase |
|
1986 | self._chainbasecache[curr] = deltainfo.chainbase | |
1995 | return node |
|
1987 | return node | |
1996 |
|
1988 | |||
1997 | def _writeentry(self, transaction, ifh, dfh, entry, data, link, offset): |
|
1989 | def _writeentry(self, transaction, ifh, dfh, entry, data, link, offset): |
@@ -690,6 +690,19 b' class deltacomputer(object):' | |||||
690 | chainbase, chainlen, compresseddeltalen, |
|
690 | chainbase, chainlen, compresseddeltalen, | |
691 | snapshotdepth) |
|
691 | snapshotdepth) | |
692 |
|
692 | |||
|
693 | def _fullsnapshotinfo(self, fh, revinfo): | |||
|
694 | curr = len(self.revlog) | |||
|
695 | rawtext = self.buildtext(revinfo, fh) | |||
|
696 | data = self.revlog.compress(rawtext) | |||
|
697 | compresseddeltalen = deltalen = dist = len(data[1]) + len(data[0]) | |||
|
698 | deltabase = chainbase = curr | |||
|
699 | snapshotdepth = 0 | |||
|
700 | chainlen = 1 | |||
|
701 | ||||
|
702 | return _deltainfo(dist, deltalen, data, deltabase, | |||
|
703 | chainbase, chainlen, compresseddeltalen, | |||
|
704 | snapshotdepth) | |||
|
705 | ||||
693 | def finddeltainfo(self, revinfo, fh): |
|
706 | def finddeltainfo(self, revinfo, fh): | |
694 | """Find an acceptable delta against a candidate revision |
|
707 | """Find an acceptable delta against a candidate revision | |
695 |
|
708 | |||
@@ -699,15 +712,18 b' class deltacomputer(object):' | |||||
699 |
|
712 | |||
700 | Returns the first acceptable candidate revision, as ordered by |
|
713 | Returns the first acceptable candidate revision, as ordered by | |
701 | _getcandidaterevs |
|
714 | _getcandidaterevs | |
|
715 | ||||
|
716 | If no suitable deltabase is found, we return delta info for a full | |||
|
717 | snapshot. | |||
702 | """ |
|
718 | """ | |
703 | if not revinfo.textlen: |
|
719 | if not revinfo.textlen: | |
704 | return None # empty file do not need delta |
|
720 | return self._fullsnapshotinfo(fh, revinfo) | |
705 |
|
721 | |||
706 | # no delta for flag processor revision (see "candelta" for why) |
|
722 | # no delta for flag processor revision (see "candelta" for why) | |
707 | # not calling candelta since only one revision needs test, also to |
|
723 | # not calling candelta since only one revision needs test, also to | |
708 | # avoid overhead fetching flags again. |
|
724 | # avoid overhead fetching flags again. | |
709 | if revinfo.flags & REVIDX_RAWTEXT_CHANGING_FLAGS: |
|
725 | if revinfo.flags & REVIDX_RAWTEXT_CHANGING_FLAGS: | |
710 | return None |
|
726 | return self._fullsnapshotinfo(fh, revinfo) | |
711 |
|
727 | |||
712 | cachedelta = revinfo.cachedelta |
|
728 | cachedelta = revinfo.cachedelta | |
713 | p1 = revinfo.p1 |
|
729 | p1 = revinfo.p1 | |
@@ -742,4 +758,6 b' class deltacomputer(object):' | |||||
742 | deltainfo = min(nominateddeltas, key=lambda x: x.deltalen) |
|
758 | deltainfo = min(nominateddeltas, key=lambda x: x.deltalen) | |
743 | break |
|
759 | break | |
744 |
|
760 | |||
|
761 | if deltainfo is None: | |||
|
762 | deltainfo = self._fullsnapshotinfo(fh, revinfo) | |||
745 | return deltainfo |
|
763 | return deltainfo |
General Comments 0
You need to be logged in to leave comments.
Login now