##// END OF EJS Templates
made repo locks recursive and deprecate refcounting based lock releasing...
Ronny Pfannschmidt -
r8108:a26d3374 default
parent child Browse files
Show More
@@ -683,8 +683,10 class localrepository(repo.repository):
683 683 return l
684 684
685 685 def lock(self, wait=True):
686 if self._lockref and self._lockref():
687 return self._lockref()
686 l = self._lockref and self._lockref()
687 if l is not None and l.held:
688 l.lock()
689 return l
688 690
689 691 l = self._lock(self.sjoin("lock"), wait, None, self.invalidate,
690 692 _('repository %s') % self.origroot)
@@ -692,8 +694,10 class localrepository(repo.repository):
692 694 return l
693 695
694 696 def wlock(self, wait=True):
695 if self._wlockref and self._wlockref():
696 return self._wlockref()
697 l = self._wlockref and self._wlockref()
698 if l is not None and l.held:
699 l.lock()
700 return l
697 701
698 702 l = self._lock(self.join("wlock"), wait, self.dirstate.write,
699 703 self.dirstate.invalidate, _('working directory of %s') %
@@ -27,6 +27,11 class lock(object):
27 27 self.lock()
28 28
29 29 def __del__(self):
30 if self.held:
31 # ensure the lock will be removed
32 # even if recursive locking did occur
33 self.held = 1
34
30 35 self.release()
31 36
32 37 def lock(self):
@@ -45,6 +50,9 class lock(object):
45 50 inst.locker)
46 51
47 52 def trylock(self):
53 if self.held:
54 self.held += 1
55 return
48 56 if lock._host is None:
49 57 lock._host = socket.gethostname()
50 58 lockname = '%s:%s' % (lock._host, os.getpid())
@@ -97,7 +105,9 class lock(object):
97 105 return locker
98 106
99 107 def release(self):
100 if self.held:
108 if self.held > 1:
109 self.held -= 1
110 elif self.held is 1:
101 111 self.held = 0
102 112 if self.releasefn:
103 113 self.releasefn()
@@ -105,3 +115,8 class lock(object):
105 115 os.unlink(self.f)
106 116 except: pass
107 117
118 def release(*locks):
119 for lock in locks:
120 if lock is not None:
121 lock.release()
122
General Comments 0
You need to be logged in to leave comments. Login now