688 |
688 |
689 return _deltainfo(dist, deltalen, (header, data), deltabase, |
689 return _deltainfo(dist, deltalen, (header, data), deltabase, |
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 |
696 revinfo: information about the revision (instance of _revisioninfo) |
709 revinfo: information about the revision (instance of _revisioninfo) |
697 fh: file handle to either the .i or the .d revlog file, |
710 fh: file handle to either the .i or the .d revlog file, |
698 depending on whether it is inlined or not |
711 depending on whether it is inlined or not |
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 |
714 p2 = revinfo.p2 |
730 p2 = revinfo.p2 |
715 revlog = self.revlog |
731 revlog = self.revlog |