##// END OF EJS Templates
revlog: seek to end of file before writing (issue4943)...
Gregory Szorc -
r27430:e240e914 stable
parent child Browse files
Show More
@@ -13,6 +13,7 b' and O(changes) merge between branches.'
13
13
14 # import stuff from node for others to import from revlog
14 # import stuff from node for others to import from revlog
15 import collections
15 import collections
16 import os
16 from node import bin, hex, nullid, nullrev
17 from node import bin, hex, nullid, nullrev
17 from i18n import _
18 from i18n import _
18 import ancestor, mdiff, parsers, error, util, templatefilters
19 import ancestor, mdiff, parsers, error, util, templatefilters
@@ -1426,6 +1427,20 b' class revlog(object):'
1426 return node
1427 return node
1427
1428
1428 def _writeentry(self, transaction, ifh, dfh, entry, data, link, offset):
1429 def _writeentry(self, transaction, ifh, dfh, entry, data, link, offset):
1430 # Files opened in a+ mode have inconsistent behavior on various
1431 # platforms. Windows requires that a file positioning call be made
1432 # when the file handle transitions between reads and writes. See
1433 # 3686fa2b8eee and the mixedfilemodewrapper in windows.py. On other
1434 # platforms, Python or the platform itself can be buggy. Some versions
1435 # of Solaris have been observed to not append at the end of the file
1436 # if the file was seeked to before the end. See issue4943 for more.
1437 #
1438 # We work around this issue by inserting a seek() before writing.
1439 # Note: This is likely not necessary on Python 3.
1440 ifh.seek(0, os.SEEK_END)
1441 if dfh:
1442 dfh.seek(0, os.SEEK_END)
1443
1429 curr = len(self) - 1
1444 curr = len(self) - 1
1430 if not self._inline:
1445 if not self._inline:
1431 transaction.add(self.datafile, offset)
1446 transaction.add(self.datafile, offset)
General Comments 0
You need to be logged in to leave comments. Login now