comparison mercurial/revlog.py @ 26378:e749707f0afb

revlog: always open revlogs for reading and appending An upcoming patch will teach revlogs to use the existing file handle to read revision data instead of opening a new file handle just for quick reads. For this to work, files must be opened for reading as well. This patch is merely cosmetic: there are no behavior changes.
author Gregory Szorc <gregory.szorc@gmail.com>
date Sun, 27 Sep 2015 15:59:19 -0700
parents dfef0d3be65e
children 39d643252b9f
comparison
equal deleted inserted replaced
26377:dfef0d3be65e 26378:e749707f0afb
1216 if node in self.nodemap: 1216 if node in self.nodemap:
1217 return node 1217 return node
1218 1218
1219 dfh = None 1219 dfh = None
1220 if not self._inline: 1220 if not self._inline:
1221 dfh = self.opener(self.datafile, "a") 1221 dfh = self.opener(self.datafile, "a+")
1222 ifh = self.opener(self.indexfile, "a+") 1222 ifh = self.opener(self.indexfile, "a+")
1223 try: 1223 try:
1224 return self._addrevision(node, text, transaction, link, p1, p2, 1224 return self._addrevision(node, text, transaction, link, p1, p2,
1225 REVIDX_DEFAULT_FLAGS, cachedelta, ifh, dfh) 1225 REVIDX_DEFAULT_FLAGS, cachedelta, ifh, dfh)
1226 finally: 1226 finally:
1465 transaction.add(self.indexfile, end + isize, r) 1465 transaction.add(self.indexfile, end + isize, r)
1466 dfh = None 1466 dfh = None
1467 else: 1467 else:
1468 transaction.add(self.indexfile, isize, r) 1468 transaction.add(self.indexfile, isize, r)
1469 transaction.add(self.datafile, end) 1469 transaction.add(self.datafile, end)
1470 dfh = self.opener(self.datafile, "a") 1470 dfh = self.opener(self.datafile, "a+")
1471 def flush(): 1471 def flush():
1472 if dfh: 1472 if dfh:
1473 dfh.flush() 1473 dfh.flush()
1474 ifh.flush() 1474 ifh.flush()
1475 try: 1475 try:
1533 1533
1534 if not dfh and not self._inline: 1534 if not dfh and not self._inline:
1535 # addrevision switched from inline to conventional 1535 # addrevision switched from inline to conventional
1536 # reopen the index 1536 # reopen the index
1537 ifh.close() 1537 ifh.close()
1538 dfh = self.opener(self.datafile, "a") 1538 dfh = self.opener(self.datafile, "a+")
1539 ifh = self.opener(self.indexfile, "a") 1539 ifh = self.opener(self.indexfile, "a+")
1540 finally: 1540 finally:
1541 if dfh: 1541 if dfh:
1542 dfh.close() 1542 dfh.close()
1543 ifh.close() 1543 ifh.close()
1544 1544