##// END OF EJS Templates
delta: move some delta chain related computation earlier in deltainfo...
Valentin Gatien-Baron -
r42665:6e9ba867 default
parent child Browse files
Show More
@@ -932,6 +932,21 b' class deltacomputer(object):'
932 932
933 933 def _builddeltainfo(self, revinfo, base, fh):
934 934 # can we use the cached delta?
935 revlog = self.revlog
936 chainbase = revlog.chainbase(base)
937 if revlog._generaldelta:
938 deltabase = base
939 else:
940 deltabase = chainbase
941 snapshotdepth = None
942 if revlog._sparserevlog and deltabase == nullrev:
943 snapshotdepth = 0
944 elif revlog._sparserevlog and revlog.issnapshot(deltabase):
945 # A delta chain should always be one full snapshot,
946 # zero or more semi-snapshots, and zero or more deltas
947 p1, p2 = revlog.rev(revinfo.p1), revlog.rev(revinfo.p2)
948 if deltabase not in (p1, p2) and revlog.issnapshot(deltabase):
949 snapshotdepth = len(revlog._deltachain(deltabase)[0])
935 950 delta = None
936 951 if revinfo.cachedelta:
937 952 cachebase, cachediff = revinfo.cachedelta
@@ -945,31 +960,14 b' class deltacomputer(object):'
945 960 delta = revinfo.cachedelta[1]
946 961 if delta is None:
947 962 delta = self._builddeltadiff(base, revinfo, fh)
948 revlog = self.revlog
949 963 header, data = revlog.compress(delta)
950 964 deltalen = len(header) + len(data)
951 chainbase = revlog.chainbase(base)
952 965 offset = revlog.end(len(revlog) - 1)
953 966 dist = deltalen + offset - revlog.start(chainbase)
954 if revlog._generaldelta:
955 deltabase = base
956 else:
957 deltabase = chainbase
958 967 chainlen, compresseddeltalen = revlog._chaininfo(base)
959 968 chainlen += 1
960 969 compresseddeltalen += deltalen
961 970
962 revlog = self.revlog
963 snapshotdepth = None
964 if deltabase == nullrev:
965 snapshotdepth = 0
966 elif revlog._sparserevlog and revlog.issnapshot(deltabase):
967 # A delta chain should always be one full snapshot,
968 # zero or more semi-snapshots, and zero or more deltas
969 p1, p2 = revlog.rev(revinfo.p1), revlog.rev(revinfo.p2)
970 if deltabase not in (p1, p2) and revlog.issnapshot(deltabase):
971 snapshotdepth = len(revlog._deltachain(deltabase)[0])
972
973 971 return _deltainfo(dist, deltalen, (header, data), deltabase,
974 972 chainbase, chainlen, compresseddeltalen,
975 973 snapshotdepth)
General Comments 0
You need to be logged in to leave comments. Login now