mercurial/revlog.py
changeset 27431 8f016345e6b0
parent 27361 29f50344fa83
parent 27430 e240e914d226
child 27433 12f727a5b434
equal deleted inserted replaced
27429:2e31a17ad1bf 27431:8f016345e6b0
    13 
    13 
    14 from __future__ import absolute_import
    14 from __future__ import absolute_import
    15 
    15 
    16 import collections
    16 import collections
    17 import errno
    17 import errno
       
    18 import os
    18 import struct
    19 import struct
    19 import zlib
    20 import zlib
    20 
    21 
    21 # import stuff from node for others to import from revlog
    22 # import stuff from node for others to import from revlog
    22 from .node import (
    23 from .node import (
  1493             self._cache = (node, curr, text)
  1494             self._cache = (node, curr, text)
  1494         self._basecache = (curr, chainbase)
  1495         self._basecache = (curr, chainbase)
  1495         return node
  1496         return node
  1496 
  1497 
  1497     def _writeentry(self, transaction, ifh, dfh, entry, data, link, offset):
  1498     def _writeentry(self, transaction, ifh, dfh, entry, data, link, offset):
       
  1499         # Files opened in a+ mode have inconsistent behavior on various
       
  1500         # platforms. Windows requires that a file positioning call be made
       
  1501         # when the file handle transitions between reads and writes. See
       
  1502         # 3686fa2b8eee and the mixedfilemodewrapper in windows.py. On other
       
  1503         # platforms, Python or the platform itself can be buggy. Some versions
       
  1504         # of Solaris have been observed to not append at the end of the file
       
  1505         # if the file was seeked to before the end. See issue4943 for more.
       
  1506         #
       
  1507         # We work around this issue by inserting a seek() before writing.
       
  1508         # Note: This is likely not necessary on Python 3.
       
  1509         ifh.seek(0, os.SEEK_END)
       
  1510         if dfh:
       
  1511             dfh.seek(0, os.SEEK_END)
       
  1512 
  1498         curr = len(self) - 1
  1513         curr = len(self) - 1
  1499         if not self._inline:
  1514         if not self._inline:
  1500             transaction.add(self.datafile, offset)
  1515             transaction.add(self.datafile, offset)
  1501             transaction.add(self.indexfile, curr * len(entry))
  1516             transaction.add(self.indexfile, curr * len(entry))
  1502             if data[0]:
  1517             if data[0]: