hgext3rd/evolve/obscache.py
changeset 3408 f4ea9652661d
parent 3144 6f10c94a2114
child 3409 740e1267be6f
equal deleted inserted replaced
3407:b96568036837 3408:f4ea9652661d
    25 )
    25 )
    26 
    26 
    27 from mercurial.i18n import _
    27 from mercurial.i18n import _
    28 
    28 
    29 from . import (
    29 from . import (
       
    30     compat,
    30     exthelper,
    31     exthelper,
    31 )
    32 )
    32 
    33 
    33 eh = exthelper.exthelper()
    34 eh = exthelper.exthelper()
    34 
    35 
    40 elif getattr(pycompat, 'osname', os.name) == 'nt':
    41 elif getattr(pycompat, 'osname', os.name) == 'nt':
    41     timer = time.clock
    42     timer = time.clock
    42 else:
    43 else:
    43     timer = time.time
    44     timer = time.time
    44 
    45 
    45 # hg < 4.2 compat
       
    46 try:
       
    47     from mercurial import vfs as vfsmod
       
    48     vfsmod.vfs
       
    49 except ImportError:
       
    50     from mercurial import scmutil as vfsmod
       
    51 
    46 
    52 obsstorefilecache = localrepo.localrepository.obsstore
    47 obsstorefilecache = localrepo.localrepository.obsstore
    53 
    48 
    54 # obsstore is a filecache so we have do to some spacial dancing
    49 # obsstore is a filecache so we have do to some spacial dancing
    55 @eh.wrapfunction(obsstorefilecache, 'func')
    50 @eh.wrapfunction(obsstorefilecache, 'func')
   324             # requirement (or fix the race, that is not too hard).
   319             # requirement (or fix the race, that is not too hard).
   325             markers = markersfrom(obsstore, keyobssize, keyobslength)
   320             markers = markersfrom(obsstore, keyobssize, keyobslength)
   326 
   321 
   327         return reset, revs, markers, (obssize, obskey)
   322         return reset, revs, markers, (obssize, obskey)
   328 
   323 
   329 def getcachevfs(repo):
       
   330     cachevfs = getattr(repo, 'cachevfs', None)
       
   331     if cachevfs is None:
       
   332         cachevfs = vfsmod.vfs(repo.vfs.join('cache'))
       
   333         cachevfs.createmode = repo.store.createmode
       
   334     return cachevfs
       
   335 
       
   336 class obscache(dualsourcecache):
   324 class obscache(dualsourcecache):
   337     """cache the "does a rev" is the precursors of some obsmarkers data
   325     """cache the "does a rev" is the precursors of some obsmarkers data
   338 
   326 
   339     This is not directly holding the "is this revision obsolete" information,
   327     This is not directly holding the "is this revision obsolete" information,
   340     because phases data gets into play here. However, it allow to compute the
   328     because phases data gets into play here. However, it allow to compute the
   373     _cachename = 'evo-ext-obscache' # used for error message
   361     _cachename = 'evo-ext-obscache' # used for error message
   374 
   362 
   375     def __init__(self, repo):
   363     def __init__(self, repo):
   376         super(obscache, self).__init__()
   364         super(obscache, self).__init__()
   377         self._ondiskkey = None
   365         self._ondiskkey = None
   378         self._vfs = getcachevfs(repo)
   366         self._vfs = compat.getcachevfs(repo)
   379 
   367 
   380     @util.propertycache
   368     @util.propertycache
   381     def get(self):
   369     def get(self):
   382         """final signature: obscache.get(rev)
   370         """final signature: obscache.get(rev)
   383 
   371