Mercurial > hg
comparison mercurial/revlog.py @ 30744:e12c0fa1f65b
revlog: pass revlog flags to addrevision
Adding the ability to passing flags to addrevision instead of simply passing
default flags to _addrevision will allow extensions relying on flag transforms
to wrap around addrevision() in order to update revlog flags.
The first use case of this patch will be the lfs extension marking nodes as
stored externally when the contents are larger than the defined threshold.
One of the reasons leading to setting flags in addrevision() wrappers in the
flag processor design is that it allows to detect files larger than the 2GB
limit before the check is performed, which allows lfs to transform the contents
into metadata.
author | Remi Chaintron <remi@fb.com> |
---|---|
date | Thu, 05 Jan 2017 17:16:07 +0000 |
parents | 2df983125d37 |
children | c1b7b2285522 |
comparison
equal
deleted
inserted
replaced
30743:2df983125d37 | 30744:e12c0fa1f65b |
---|---|
1326 | 1326 |
1327 tr.replace(self.indexfile, trindex * self._io.size) | 1327 tr.replace(self.indexfile, trindex * self._io.size) |
1328 self._chunkclear() | 1328 self._chunkclear() |
1329 | 1329 |
1330 def addrevision(self, text, transaction, link, p1, p2, cachedelta=None, | 1330 def addrevision(self, text, transaction, link, p1, p2, cachedelta=None, |
1331 node=None): | 1331 node=None, flags=REVIDX_DEFAULT_FLAGS): |
1332 """add a revision to the log | 1332 """add a revision to the log |
1333 | 1333 |
1334 text - the revision data to add | 1334 text - the revision data to add |
1335 transaction - the transaction object used for rollback | 1335 transaction - the transaction object used for rollback |
1336 link - the linkrev data to add | 1336 link - the linkrev data to add |
1337 p1, p2 - the parent nodeids of the revision | 1337 p1, p2 - the parent nodeids of the revision |
1338 cachedelta - an optional precomputed delta | 1338 cachedelta - an optional precomputed delta |
1339 node - nodeid of revision; typically node is not specified, and it is | 1339 node - nodeid of revision; typically node is not specified, and it is |
1340 computed by default as hash(text, p1, p2), however subclasses might | 1340 computed by default as hash(text, p1, p2), however subclasses might |
1341 use different hashing method (and override checkhash() in such case) | 1341 use different hashing method (and override checkhash() in such case) |
1342 flags - the known flags to set on the revision | |
1342 """ | 1343 """ |
1343 if link == nullrev: | 1344 if link == nullrev: |
1344 raise RevlogError(_("attempted to add linkrev -1 to %s") | 1345 raise RevlogError(_("attempted to add linkrev -1 to %s") |
1345 % self.indexfile) | 1346 % self.indexfile) |
1346 | 1347 |
1357 if not self._inline: | 1358 if not self._inline: |
1358 dfh = self.opener(self.datafile, "a+") | 1359 dfh = self.opener(self.datafile, "a+") |
1359 ifh = self.opener(self.indexfile, "a+", checkambig=self._checkambig) | 1360 ifh = self.opener(self.indexfile, "a+", checkambig=self._checkambig) |
1360 try: | 1361 try: |
1361 return self._addrevision(node, text, transaction, link, p1, p2, | 1362 return self._addrevision(node, text, transaction, link, p1, p2, |
1362 REVIDX_DEFAULT_FLAGS, cachedelta, ifh, dfh) | 1363 flags, cachedelta, ifh, dfh) |
1363 finally: | 1364 finally: |
1364 if dfh: | 1365 if dfh: |
1365 dfh.close() | 1366 dfh.close() |
1366 ifh.close() | 1367 ifh.close() |
1367 | 1368 |