Show More
@@ -683,8 +683,10 class localrepository(repo.repository): | |||||
683 | return l |
|
683 | return l | |
684 |
|
684 | |||
685 | def lock(self, wait=True): |
|
685 | def lock(self, wait=True): | |
686 |
|
|
686 | l = self._lockref and self._lockref() | |
687 | return self._lockref() |
|
687 | if l is not None and l.held: | |
|
688 | l.lock() | |||
|
689 | return l | |||
688 |
|
690 | |||
689 | l = self._lock(self.sjoin("lock"), wait, None, self.invalidate, |
|
691 | l = self._lock(self.sjoin("lock"), wait, None, self.invalidate, | |
690 | _('repository %s') % self.origroot) |
|
692 | _('repository %s') % self.origroot) | |
@@ -692,8 +694,10 class localrepository(repo.repository): | |||||
692 | return l |
|
694 | return l | |
693 |
|
695 | |||
694 | def wlock(self, wait=True): |
|
696 | def wlock(self, wait=True): | |
695 |
|
|
697 | l = self._wlockref and self._wlockref() | |
696 | return self._wlockref() |
|
698 | if l is not None and l.held: | |
|
699 | l.lock() | |||
|
700 | return l | |||
697 |
|
701 | |||
698 | l = self._lock(self.join("wlock"), wait, self.dirstate.write, |
|
702 | l = self._lock(self.join("wlock"), wait, self.dirstate.write, | |
699 | self.dirstate.invalidate, _('working directory of %s') % |
|
703 | self.dirstate.invalidate, _('working directory of %s') % |
@@ -27,6 +27,11 class lock(object): | |||||
27 | self.lock() |
|
27 | self.lock() | |
28 |
|
28 | |||
29 | def __del__(self): |
|
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 | self.release() |
|
35 | self.release() | |
31 |
|
36 | |||
32 | def lock(self): |
|
37 | def lock(self): | |
@@ -45,6 +50,9 class lock(object): | |||||
45 | inst.locker) |
|
50 | inst.locker) | |
46 |
|
51 | |||
47 | def trylock(self): |
|
52 | def trylock(self): | |
|
53 | if self.held: | |||
|
54 | self.held += 1 | |||
|
55 | return | |||
48 | if lock._host is None: |
|
56 | if lock._host is None: | |
49 | lock._host = socket.gethostname() |
|
57 | lock._host = socket.gethostname() | |
50 | lockname = '%s:%s' % (lock._host, os.getpid()) |
|
58 | lockname = '%s:%s' % (lock._host, os.getpid()) | |
@@ -97,7 +105,9 class lock(object): | |||||
97 | return locker |
|
105 | return locker | |
98 |
|
106 | |||
99 | def release(self): |
|
107 | def release(self): | |
100 | if self.held: |
|
108 | if self.held > 1: | |
|
109 | self.held -= 1 | |||
|
110 | elif self.held is 1: | |||
101 | self.held = 0 |
|
111 | self.held = 0 | |
102 | if self.releasefn: |
|
112 | if self.releasefn: | |
103 | self.releasefn() |
|
113 | self.releasefn() | |
@@ -105,3 +115,8 class lock(object): | |||||
105 | os.unlink(self.f) |
|
115 | os.unlink(self.f) | |
106 | except: pass |
|
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