##// END OF EJS Templates
revlog: optionally cache the full text when adding revisions...
Gregory Szorc -
r26243:83629142 default
parent child Browse files
Show More
@@ -1255,7 +1255,7 b' class revlog(object):'
1255 return True
1255 return True
1256
1256
1257 def _addrevision(self, node, text, transaction, link, p1, p2, flags,
1257 def _addrevision(self, node, text, transaction, link, p1, p2, flags,
1258 cachedelta, ifh, dfh):
1258 cachedelta, ifh, dfh, alwayscache=False):
1259 """internal function to add revisions to the log
1259 """internal function to add revisions to the log
1260
1260
1261 see addrevision for argument descriptions.
1261 see addrevision for argument descriptions.
@@ -1391,6 +1391,9 b' class revlog(object):'
1391 entry = self._io.packentry(e, self.node, self.version, curr)
1391 entry = self._io.packentry(e, self.node, self.version, curr)
1392 self._writeentry(transaction, ifh, dfh, entry, data, link, offset)
1392 self._writeentry(transaction, ifh, dfh, entry, data, link, offset)
1393
1393
1394 if alwayscache and text is None:
1395 text = buildtext()
1396
1394 if type(text) == str: # only accept immutable objects
1397 if type(text) == str: # only accept immutable objects
1395 self._cache = (node, curr, text)
1398 self._cache = (node, curr, text)
1396 self._basecache = (curr, chainbase)
1399 self._basecache = (curr, chainbase)
@@ -1494,15 +1497,16 b' class revlog(object):'
1494 if self._peek_iscensored(baserev, delta, flush):
1497 if self._peek_iscensored(baserev, delta, flush):
1495 flags |= REVIDX_ISCENSORED
1498 flags |= REVIDX_ISCENSORED
1496
1499
1500 # We assume consumers of addrevisioncb will want to retrieve
1501 # the added revision, which will require a call to
1502 # revision(). revision() will fast path if there is a cache
1503 # hit. So, we tell _addrevision() to always cache in this case.
1497 chain = self._addrevision(node, None, transaction, link,
1504 chain = self._addrevision(node, None, transaction, link,
1498 p1, p2, flags, (baserev, delta),
1505 p1, p2, flags, (baserev, delta),
1499 ifh, dfh)
1506 ifh, dfh,
1507 alwayscache=bool(addrevisioncb))
1500
1508
1501 if addrevisioncb:
1509 if addrevisioncb:
1502 # Data for added revision can't be read unless flushed
1503 # because _loadchunk always opensa new file handle and
1504 # there is no guarantee data was actually written yet.
1505 flush()
1506 addrevisioncb(self, chain)
1510 addrevisioncb(self, chain)
1507
1511
1508 if not dfh and not self._inline:
1512 if not dfh and not self._inline:
General Comments 0
You need to be logged in to leave comments. Login now