diff tests/test-devel-warnings.t @ 24386:d6ac30f4edef

devel: move the lock-checking code into core If the developer warnings are enabled, bad locking order will be reported without the need for the contrib extension.
author Pierre-Yves David <pierre-yves.david@fb.com>
date Fri, 16 Jan 2015 02:51:10 -0800
parents
children 026f8af88e49
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test-devel-warnings.t	Fri Jan 16 02:51:10 2015 -0800
@@ -0,0 +1,49 @@
+
+  $ cat << EOF > buggylocking.py
+  > """A small extension that acquire locks in the wrong order
+  > """
+  > 
+  > from mercurial import cmdutil
+  > 
+  > cmdtable = {}
+  > command = cmdutil.command(cmdtable)
+  > 
+  > @command('buggylocking', [], '')
+  > def buggylocking(ui, repo):
+  >     lo = repo.lock()
+  >     wl = repo.wlock()
+  > EOF
+
+  $ cat << EOF >> $HGRCPATH
+  > [extensions]
+  > buggylocking=$TESTTMP/buggylocking.py
+  > [devel]
+  > all=1
+  > EOF
+
+  $ hg init lock-checker
+  $ cd lock-checker
+  $ hg buggylocking
+  "lock" taken before "wlock"
+  $ cat << EOF >> $HGRCPATH
+  > [devel]
+  > all=0
+  > check-locks=1
+  > EOF
+  $ hg buggylocking
+  "lock" taken before "wlock"
+  $ hg buggylocking --traceback
+  "lock" taken before "wlock"
+   at:
+   */hg:* in <module> (glob)
+   */mercurial/dispatch.py:* in run (glob)
+   */mercurial/dispatch.py:* in dispatch (glob)
+   */mercurial/dispatch.py:* in _runcatch (glob)
+   */mercurial/dispatch.py:* in _dispatch (glob)
+   */mercurial/dispatch.py:* in runcommand (glob)
+   */mercurial/dispatch.py:* in _runcommand (glob)
+   */mercurial/dispatch.py:* in checkargs (glob)
+   */mercurial/dispatch.py:* in <lambda> (glob)
+   */mercurial/util.py:* in check (glob)
+   $TESTTMP/buggylocking.py:* in buggylocking (glob)
+  $ cd ..