develwarn: use the lock helper in local repo
authorPierre-Yves David <pierre-yves.david@ens-lyon.org>
Fri, 05 Aug 2016 13:44:17 +0200
changeset 29705 41689e293994
parent 29703 3ef9aa7ad1fc
child 29706 7f6130c7ffe1
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.
mercurial/localrepo.py
--- 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():