hgext/fastannotate/context.py
changeset 42947 0152a907f714
parent 41261 1198c86beb73
child 43076 2372284d9457
equal deleted inserted replaced
42946:5316f9ff3e48 42947:0152a907f714
   757         return self._repo.vfs.join(self._vfspath + '.l')
   757         return self._repo.vfs.join(self._vfspath + '.l')
   758 
   758 
   759     def lock(self):
   759     def lock(self):
   760         return lockmod.lock(self._repo.vfs, self._vfspath + '.lock')
   760         return lockmod.lock(self._repo.vfs, self._vfspath + '.lock')
   761 
   761 
   762     @contextlib.contextmanager
       
   763     def _lockflock(self):
       
   764         """the same as 'lock' but use flock instead of lockmod.lock, to avoid
       
   765         creating temporary symlinks."""
       
   766         import fcntl
       
   767         lockpath = self.linelogpath
       
   768         util.makedirs(os.path.dirname(lockpath))
       
   769         lockfd = os.open(lockpath, os.O_RDONLY | os.O_CREAT, 0o664)
       
   770         fcntl.flock(lockfd, fcntl.LOCK_EX)
       
   771         try:
       
   772             yield
       
   773         finally:
       
   774             fcntl.flock(lockfd, fcntl.LOCK_UN)
       
   775             os.close(lockfd)
       
   776 
       
   777     @property
   762     @property
   778     def revmappath(self):
   763     def revmappath(self):
   779         return self._repo.vfs.join(self._vfspath + '.m')
   764         return self._repo.vfs.join(self._vfspath + '.m')
   780 
   765 
   781 @contextlib.contextmanager
   766 @contextlib.contextmanager