changeset 29705:41689e293994

develwarn: use the lock helper in local repo We have a helper function to know if a lock is taken. When checking lock usage we now use it instead of manually accessing the locks.
author Pierre-Yves David <pierre-yves.david@ens-lyon.org>
date Fri, 05 Aug 2016 13:44:17 +0200
parents 3ef9aa7ad1fc
children 7f6130c7ffe1
files mercurial/localrepo.py
diffstat 1 files changed, 4 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/localrepo.py	Sat Mar 19 17:19:03 2016 -0700
+++ b/mercurial/localrepo.py	Fri Aug 05 13:44:17 2016 +0200
@@ -1007,8 +1007,7 @@
     def transaction(self, desc, report=None):
         if (self.ui.configbool('devel', 'all-warnings')
                 or self.ui.configbool('devel', 'check-locks')):
-            l = self._lockref and self._lockref()
-            if l is None or not l.held:
+            if self._currentlock(self._lockref) is None:
                 raise RuntimeError('programming error: transaction requires '
                                    'locking')
         tr = self.currenttransaction()
@@ -1320,8 +1319,8 @@
 
         If both 'lock' and 'wlock' must be acquired, ensure you always acquires
         'wlock' first to avoid a dead-lock hazard.'''
-        l = self._lockref and self._lockref()
-        if l is not None and l.held:
+        l = self._currentlock(self._lockref)
+        if l is not None:
             l.lock()
             return l
 
@@ -1352,8 +1351,7 @@
         # acquisition would not cause dead-lock as they would just fail.
         if wait and (self.ui.configbool('devel', 'all-warnings')
                      or self.ui.configbool('devel', 'check-locks')):
-            l = self._lockref and self._lockref()
-            if l is not None and l.held:
+            if self._currentlock(self._lockref) is not None:
                 self.ui.develwarn('"wlock" acquired after "lock"')
 
         def unlock():