mercurial/branching/rev_cache.py
changeset 52113 db1980a361cb
parent 51971 76416b6e9d9b
child 52640 24ee91ba9aa8
equal deleted inserted replaced
52112:c424df1248a3 52113:db1980a361cb
    12 )
    12 )
    13 
    13 
    14 from .. import (
    14 from .. import (
    15     encoding,
    15     encoding,
    16     error,
    16     error,
       
    17     pycompat,
    17     util,
    18     util,
    18 )
    19 )
    19 
    20 
    20 from ..utils import (
    21 from ..utils import (
    21     stringutil,
    22     stringutil,
   174                 # don't try to use cache - fall back to the slow path
   175                 # don't try to use cache - fall back to the slow path
   175                 self.branchinfo = self._branchinfo
   176                 self.branchinfo = self._branchinfo
   176 
   177 
   177         if self._names:
   178         if self._names:
   178             try:
   179             try:
   179                 usemmap = repo.ui.configbool(b'storage', b'revbranchcache.mmap')
   180                 # In order to rename the atomictempfile in _writerevs(), the
       
   181                 # existing file needs to be removed.  The Windows code
       
   182                 # (successfully) renames it to a temp file first, before moving
       
   183                 # the temp file into its place.  But the removal of the original
       
   184                 # file then fails, because it's still mapped.  The mmap object
       
   185                 # needs to be closed in order to remove the file, but in order
       
   186                 # to do that, the memoryview returned by util.buffer needs to be
       
   187                 # released.
       
   188                 usemmap = repo.ui.configbool(
       
   189                     b'storage',
       
   190                     b'revbranchcache.mmap',
       
   191                     default=not pycompat.iswindows,
       
   192                 )
   180                 if not v1_fallback:
   193                 if not v1_fallback:
   181                     with repo.cachevfs(_rbcrevs) as fp:
   194                     with repo.cachevfs(_rbcrevs) as fp:
   182                         if usemmap and repo.cachevfs.is_mmap_safe(_rbcrevs):
   195                         if usemmap and repo.cachevfs.is_mmap_safe(_rbcrevs):
   183                             data = util.buffer(util.mmapread(fp))
   196                             data = util.buffer(util.mmapread(fp))
   184                         else:
   197                         else: