##// END OF EJS Templates
lock: add a method to prepare the lock for inheritance...
Siddharth Agarwal -
r26357:6979a136 default
parent child Browse files
Show More
@@ -158,6 +158,28 b' class lock(object):'
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
General Comments 0
You need to be logged in to leave comments. Login now