[PATCH 2 of 7] develwarn: use the lock helper in local repo
Augie Fackler
raf at durin42.com
Fri Aug 5 14:33:53 EDT 2016
On Fri, Aug 05, 2016 at 03:59:15PM +0200, Pierre-Yves David wrote:
> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david at ens-lyon.org>
> # Date 1470397457 -7200
> # Fri Aug 05 13:44:17 2016 +0200
> # Node ID 9677e36d339bc11d8223aadd9473eb7218b8b6cb
> # Parent 9b65c0820c940442454e5f92a9475c4ec97f705c
> # EXP-Topic vfsward
> develwarn: use the lock helper in local repo
I've taken this patch as it was separable from the rest of the series. Thanks!
>
> 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 9b65c0820c94 -r 9677e36d339b mercurial/localrepo.py
> --- a/mercurial/localrepo.py Thu Aug 04 16:56:50 2016 +0200
> +++ b/mercurial/localrepo.py Fri Aug 05 13:44:17 2016 +0200
> @@ -1007,8 +1007,7 @@ class localrepository(object):
> 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 @@ class localrepository(object):
>
> 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 @@ class localrepository(object):
> # 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():
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
More information about the Mercurial-devel
mailing list