##// END OF EJS Templates
localrepo: prevent wlock from being inherited when a transaction is running...
Siddharth Agarwal -
r26499:e72b62b1 default
parent child Browse files
Show More
@@ -1212,7 +1212,7 b' class localrepository(object):'
1212 1212 ce.refresh()
1213 1213
1214 1214 def _lock(self, vfs, lockname, wait, releasefn, acquirefn, desc,
1215 parentenvvar=None):
1215 inheritchecker=None, parentenvvar=None):
1216 1216 parentlock = None
1217 1217 # the contents of parentenvvar are used by the underlying lock to
1218 1218 # determine whether it can be inherited
@@ -1221,6 +1221,7 b' class localrepository(object):'
1221 1221 try:
1222 1222 l = lockmod.lock(vfs, lockname, 0, releasefn=releasefn,
1223 1223 acquirefn=acquirefn, desc=desc,
1224 inheritchecker=inheritchecker,
1224 1225 parentlock=parentlock)
1225 1226 except error.LockHeld as inst:
1226 1227 if not wait:
@@ -1265,6 +1266,11 b' class localrepository(object):'
1265 1266 self._lockref = weakref.ref(l)
1266 1267 return l
1267 1268
1269 def _wlockchecktransaction(self):
1270 if self.currenttransaction() is not None:
1271 raise error.LockInheritanceContractViolation(
1272 'wlock cannot be inherited in the middle of a transaction')
1273
1268 1274 def wlock(self, wait=True):
1269 1275 '''Lock the non-store parts of the repository (everything under
1270 1276 .hg except .hg/store) and return a weak reference to the lock.
@@ -1296,7 +1302,9 b' class localrepository(object):'
1296 1302
1297 1303 l = self._lock(self.vfs, "wlock", wait, unlock,
1298 1304 self.invalidatedirstate, _('working directory of %s') %
1299 self.origroot, parentenvvar='HG_WLOCK_LOCKER')
1305 self.origroot,
1306 inheritchecker=self._wlockchecktransaction,
1307 parentenvvar='HG_WLOCK_LOCKER')
1300 1308 self._wlockref = weakref.ref(l)
1301 1309 return l
1302 1310
@@ -260,7 +260,7 b' class testlock(unittest.TestCase):'
260 260 state.assertacquirecalled(True)
261 261
262 262 def tryinherit():
263 with lock.inherit() as lockname:
263 with lock.inherit():
264 264 pass
265 265
266 266 self.assertRaises(error.LockInheritanceContractViolation, tryinherit)
General Comments 0
You need to be logged in to leave comments. Login now