# HG changeset patch # User Pierre-Yves David # Date 1470397457 -7200 # Node ID 41689e2939940b8f0399b810cd26251caea38dde # Parent 3ef9aa7ad1fc4c43b92d48e4bb1f4e3de68b6910 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. diff -r 3ef9aa7ad1fc -r 41689e293994 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():