##// END OF EJS Templates
revlog: extract delta building to a subfunction
Matt Mackall -
r12888:ad01fe38 stable
parent child Browse files
Show More
@@ -1172,6 +1172,20 b' class revlog(object):'
1172 raise RevlogError(_("consistency error in delta"))
1172 raise RevlogError(_("consistency error in delta"))
1173 return btext[0]
1173 return btext[0]
1174
1174
1175 def builddelta(rev):
1176 # can we use the cached delta?
1177 if cachedelta and cachedelta[0] == rev:
1178 delta = cachedelta[1]
1179 else:
1180 t = buildtext()
1181 ptext = self.revision(self.node(rev))
1182 delta = mdiff.textdiff(ptext, t)
1183 data = compress(delta)
1184 l = len(data[1]) + len(data[0])
1185 base = self.base(rev)
1186 dist = l + offset - self.start(base)
1187 return dist, l, data, base
1188
1175 curr = len(self)
1189 curr = len(self)
1176 prev = curr - 1
1190 prev = curr - 1
1177 base = curr
1191 base = curr
@@ -1187,17 +1201,8 b' class revlog(object):'
1187
1201
1188 # should we try to build a delta?
1202 # should we try to build a delta?
1189 if deltarev != nullrev:
1203 if deltarev != nullrev:
1190 # can we use the cached delta?
1204 d = builddelta(deltarev)
1191 if cachedelta and cachedelta[0] == deltarev:
1205 dist, l, data, base = d
1192 d = cachedelta[1]
1193 else:
1194 t = buildtext()
1195 ptext = self.revision(deltanode)
1196 d = mdiff.textdiff(ptext, t)
1197 data = compress(d)
1198 l = len(data[1]) + len(data[0])
1199 base = self.base(deltarev)
1200 dist = l + offset - self.start(base)
1201
1206
1202 # full versions are inserted when the needed deltas
1207 # full versions are inserted when the needed deltas
1203 # become comparable to the uncompressed text
1208 # become comparable to the uncompressed text
General Comments 0
You need to be logged in to leave comments. Login now