##// END OF EJS Templates
revlog.addgroup(): always use _addrevision() to add new revlog entries...
Benoit Boissinot -
r12624:557988c6 default
parent child Browse files
Show More
@@ -1300,16 +1300,13 b' class revlog(object):'
1300 log, the rest are against the previous delta.
1300 log, the rest are against the previous delta.
1301 """
1301 """
1302
1302
1303 #track the base of the current delta log
1303 # track the base of the current delta log
1304 r = len(self)
1305 t = r - 1
1306 node = None
1304 node = None
1307
1305
1308 base = prev = nullrev
1306 r = len(self)
1309 start = end = textlen = 0
1307 end = 0
1310 if r:
1308 if r:
1311 end = self.end(t)
1309 end = self.end(r - 1)
1312
1313 ifh = self.opener(self.indexfile, "a+")
1310 ifh = self.opener(self.indexfile, "a+")
1314 isize = r * self._io.size
1311 isize = r * self._io.size
1315 if self._inline:
1312 if self._inline:
@@ -1344,16 +1341,19 b' class revlog(object):'
1344 if not p in self.nodemap:
1341 if not p in self.nodemap:
1345 if self._shallow:
1342 if self._shallow:
1346 # add null entries for missing parents
1343 # add null entries for missing parents
1347 if base == nullrev:
1344 # XXX FIXME
1348 base = len(self)
1345 #if base == nullrev:
1349 e = (offset_type(end, REVIDX_PUNCHED_FLAG),
1346 # base = len(self)
1350 0, 0, base, nullrev, nullrev, nullrev, p)
1347 #e = (offset_type(end, REVIDX_PUNCHED_FLAG),
1351 self.index.insert(-1, e)
1348 # 0, 0, base, nullrev, nullrev, nullrev, p)
1352 self.nodemap[p] = r
1349 #self.index.insert(-1, e)
1353 entry = self._io.packentry(e, self.node,
1350 #self.nodemap[p] = r
1354 self.version, r)
1351 #entry = self._io.packentry(e, self.node,
1355 ifh.write(entry)
1352 # self.version, r)
1356 t, r = r, r + 1
1353 #ifh.write(entry)
1354 #t, r = r, r + 1
1355 raise LookupError(p, self.indexfile,
1356 _('unknown parent'))
1357 else:
1357 else:
1358 raise LookupError(p, self.indexfile,
1358 raise LookupError(p, self.indexfile,
1359 _('unknown parent'))
1359 _('unknown parent'))
@@ -1364,58 +1364,14 b' class revlog(object):'
1364 if not chain in self.nodemap:
1364 if not chain in self.nodemap:
1365 raise LookupError(chain, self.indexfile, _('unknown base'))
1365 raise LookupError(chain, self.indexfile, _('unknown base'))
1366
1366
1367 # full versions are inserted when the needed deltas become
1367 chainrev = self.rev(chain)
1368 # comparable to the uncompressed text or when the previous
1368 chain = self._addrevision(node, None, transaction, link,
1369 # version is not the one we have a delta against. We use
1369 p1, p2, (chainrev, delta), ifh, dfh)
1370 # the size of the previous full rev as a proxy for the
1370 if not dfh and not self._inline:
1371 # current size.
1371 # addrevision switched from inline to conventional
1372
1372 # reopen the index
1373 if chain == prev:
1373 dfh = self.opener(self.datafile, "a")
1374 cdelta = compress(delta)
1374 ifh = self.opener(self.indexfile, "a")
1375 cdeltalen = len(cdelta[0]) + len(cdelta[1])
1376 textlen = mdiff.patchedsize(textlen, delta)
1377
1378 if chain != prev or (end - start + cdeltalen) > textlen * 2:
1379 # flush our writes here so we can read it in revision
1380 if dfh:
1381 dfh.flush()
1382 ifh.flush()
1383 text = self.revision(chain)
1384 text = mdiff.patch(text, delta)
1385 del delta
1386 chk = self._addrevision(node, text, transaction, link,
1387 p1, p2, None, ifh, dfh)
1388 if not dfh and not self._inline:
1389 # addrevision switched from inline to conventional
1390 # reopen the index
1391 dfh = self.opener(self.datafile, "a")
1392 ifh = self.opener(self.indexfile, "a")
1393 if chk != node:
1394 raise RevlogError(_("consistency error adding group"))
1395 textlen = len(text)
1396 else:
1397 e = (offset_type(end, 0), cdeltalen, textlen, base,
1398 link, self.rev(p1), self.rev(p2), node)
1399 self.index.insert(-1, e)
1400 self.nodemap[node] = r
1401 entry = self._io.packentry(e, self.node, self.version, r)
1402 if self._inline:
1403 ifh.write(entry)
1404 ifh.write(cdelta[0])
1405 ifh.write(cdelta[1])
1406 self.checkinlinesize(transaction, ifh)
1407 if not self._inline:
1408 dfh = self.opener(self.datafile, "a")
1409 ifh = self.opener(self.indexfile, "a")
1410 else:
1411 dfh.write(cdelta[0])
1412 dfh.write(cdelta[1])
1413 ifh.write(entry)
1414
1415 t, r, chain, prev = r, r + 1, node, node
1416 base = self.base(t)
1417 start = self.start(base)
1418 end = self.end(t)
1419 finally:
1375 finally:
1420 if dfh:
1376 if dfh:
1421 dfh.close()
1377 dfh.close()
General Comments 0
You need to be logged in to leave comments. Login now