# HG changeset patch # User Pierre-Yves David # Date 1428867479 14400 # Node ID aaf835407bf2640210ec411fc297749648d5d4de # Parent 3ad1571d48527cf99cc2dc7b511099f7cacc02b6 wlock: do not warn for non-wait locking We are warning about lock acquired in the wrong order because this can create dead-lock situation. But non-wait acquisition will not block and therefore not create a dead-lock. So we do not need to wait in such case. diff -r 3ad1571d4852 -r aaf835407bf2 mercurial/localrepo.py --- a/mercurial/localrepo.py Sun Apr 12 14:27:42 2015 -0400 +++ b/mercurial/localrepo.py Sun Apr 12 15:37:59 2015 -0400 @@ -1212,8 +1212,10 @@ l.lock() return l - if (self.ui.configbool('devel', 'all') - or self.ui.configbool('devel', 'check-locks')): + # We do not need to check for non-waiting lock aquisition. Such + # acquisition would not cause dead-lock as they would just fail. + if wait and (self.ui.configbool('devel', 'all') + or self.ui.configbool('devel', 'check-locks')): l = self._lockref and self._lockref() if l is not None and l.held: scmutil.develwarn(self.ui, '"wlock" acquired after "lock"') diff -r 3ad1571d4852 -r aaf835407bf2 tests/test-devel-warnings.t --- a/tests/test-devel-warnings.t Sun Apr 12 14:27:42 2015 -0400 +++ b/tests/test-devel-warnings.t Sun Apr 12 15:37:59 2015 -0400 @@ -31,6 +31,13 @@ > tr.close() > lo.release() > wl.release() + > + > @command('nowaitlocking', [], '') + > def nowaitlocking(ui, repo): + > lo = repo.lock() + > wl = repo.wlock(wait=False) + > wl.release() + > lo.release() > EOF $ cat << EOF >> $HGRCPATH @@ -79,4 +86,5 @@ */mercurial/util.py:* in check (glob) $TESTTMP/buggylocking.py:* in buggylocking (glob) $ hg properlocking + $ hg nowaitlocking $ cd ..