comparison mercurial/localrepo.py @ 20091:abfe6a8e619b

lock: take both vfs and lock file path relative to vfs to access via vfs This patch makes "lock.lock.__init__()" take both vfs and lock file path relative to vfs, instead of absolute path to lock file. This allows lock file to be accessed via vfs.
author FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
date Tue, 12 Nov 2013 16:23:52 +0900
parents 7cbb79bddee7
children 4c96c50ef937
comparison
equal deleted inserted replaced
20090:88d8e568add1 20091:abfe6a8e619b
998 delattr(unfiltered, k) 998 delattr(unfiltered, k)
999 except AttributeError: 999 except AttributeError:
1000 pass 1000 pass
1001 self.invalidatecaches() 1001 self.invalidatecaches()
1002 1002
1003 def _lock(self, lockname, wait, releasefn, acquirefn, desc): 1003 def _lock(self, vfs, lockname, wait, releasefn, acquirefn, desc):
1004 try: 1004 try:
1005 l = lockmod.lock(lockname, 0, releasefn, desc=desc) 1005 l = lockmod.lock(vfs, lockname, 0, releasefn, desc=desc)
1006 except error.LockHeld, inst: 1006 except error.LockHeld, inst:
1007 if not wait: 1007 if not wait:
1008 raise 1008 raise
1009 self.ui.warn(_("waiting for lock on %s held by %r\n") % 1009 self.ui.warn(_("waiting for lock on %s held by %r\n") %
1010 (desc, inst.locker)) 1010 (desc, inst.locker))
1011 # default to 600 seconds timeout 1011 # default to 600 seconds timeout
1012 l = lockmod.lock(lockname, 1012 l = lockmod.lock(vfs, lockname,
1013 int(self.ui.config("ui", "timeout", "600")), 1013 int(self.ui.config("ui", "timeout", "600")),
1014 releasefn, desc=desc) 1014 releasefn, desc=desc)
1015 if acquirefn: 1015 if acquirefn:
1016 acquirefn() 1016 acquirefn()
1017 return l 1017 return l
1042 for k, ce in self._filecache.items(): 1042 for k, ce in self._filecache.items():
1043 if k == 'dirstate' or k not in self.__dict__: 1043 if k == 'dirstate' or k not in self.__dict__:
1044 continue 1044 continue
1045 ce.refresh() 1045 ce.refresh()
1046 1046
1047 l = self._lock(self.sjoin("lock"), wait, unlock, 1047 l = self._lock(self.svfs, "lock", wait, unlock,
1048 self.invalidate, _('repository %s') % self.origroot) 1048 self.invalidate, _('repository %s') % self.origroot)
1049 self._lockref = weakref.ref(l) 1049 self._lockref = weakref.ref(l)
1050 return l 1050 return l
1051 1051
1052 def wlock(self, wait=True): 1052 def wlock(self, wait=True):
1060 1060
1061 def unlock(): 1061 def unlock():
1062 self.dirstate.write() 1062 self.dirstate.write()
1063 self._filecache['dirstate'].refresh() 1063 self._filecache['dirstate'].refresh()
1064 1064
1065 l = self._lock(self.join("wlock"), wait, unlock, 1065 l = self._lock(self.vfs, "wlock", wait, unlock,
1066 self.invalidatedirstate, _('working directory of %s') % 1066 self.invalidatedirstate, _('working directory of %s') %
1067 self.origroot) 1067 self.origroot)
1068 self._wlockref = weakref.ref(l) 1068 self._wlockref = weakref.ref(l)
1069 return l 1069 return l
1070 1070