equal
deleted
inserted
replaced
156 |
156 |
157 """ |
157 """ |
158 locker = self._readlock() |
158 locker = self._readlock() |
159 return self._testlock(locker) |
159 return self._testlock(locker) |
160 |
160 |
|
161 def prepinherit(self): |
|
162 """prepare for the lock to be inherited by a Mercurial subprocess |
|
163 |
|
164 Returns a string that will be recognized by the lock in the |
|
165 subprocess. Communicating this string to the subprocess needs to be done |
|
166 separately -- typically by an environment variable. |
|
167 """ |
|
168 if not self.held: |
|
169 raise error.LockInheritanceContractViolation( |
|
170 'prepinherit can only be called while lock is held') |
|
171 if self._inherited: |
|
172 raise error.LockInheritanceContractViolation( |
|
173 'prepinherit cannot be called while lock is already inherited') |
|
174 if self.releasefn: |
|
175 self.releasefn() |
|
176 if self._parentheld: |
|
177 lockname = self.parentlock |
|
178 else: |
|
179 lockname = '%s:%s' % (lock._host, self.pid) |
|
180 self._inherited = True |
|
181 return lockname |
|
182 |
161 def release(self): |
183 def release(self): |
162 """release the lock and execute callback function if any |
184 """release the lock and execute callback function if any |
163 |
185 |
164 If the lock has been acquired multiple times, the actual release is |
186 If the lock has been acquired multiple times, the actual release is |
165 delayed to the last release call.""" |
187 delayed to the last release call.""" |