annotate tests/test-devel-warnings.t @ 24744:bedefc611f25

wlock: only issue devel warning when actually acquiring the lock Before this change, any call to 'wlock' after we acquired a 'lock' was issuing a warning. This is wrong as the 'wlock' have been properly acquired before the 'lock' in a previous call. We move the warning code to only issue such warnings when we are acquiring the 'wlock' -after- acquiring 'lock'. This is the expected behavior of this warning from the start.
author Pierre-Yves David <pierre-yves.david@fb.com>
date Sun, 12 Apr 2015 10:01:48 -0400
parents 1b97cc5d2272
children bc34b286781f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
24386
d6ac30f4edef devel: move the lock-checking code into core
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
1
d6ac30f4edef devel: move the lock-checking code into core
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
2 $ cat << EOF > buggylocking.py
d6ac30f4edef devel: move the lock-checking code into core
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
3 > """A small extension that acquire locks in the wrong order
d6ac30f4edef devel: move the lock-checking code into core
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
4 > """
d6ac30f4edef devel: move the lock-checking code into core
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
5 >
d6ac30f4edef devel: move the lock-checking code into core
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
6 > from mercurial import cmdutil
d6ac30f4edef devel: move the lock-checking code into core
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
7 >
d6ac30f4edef devel: move the lock-checking code into core
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
8 > cmdtable = {}
d6ac30f4edef devel: move the lock-checking code into core
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
9 > command = cmdutil.command(cmdtable)
d6ac30f4edef devel: move the lock-checking code into core
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
10 >
d6ac30f4edef devel: move the lock-checking code into core
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
11 > @command('buggylocking', [], '')
d6ac30f4edef devel: move the lock-checking code into core
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
12 > def buggylocking(ui, repo):
24388
026f8af88e49 devel: also warn about transaction started without a lock
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 24386
diff changeset
13 > tr = repo.transaction('buggy')
24386
d6ac30f4edef devel: move the lock-checking code into core
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
14 > lo = repo.lock()
d6ac30f4edef devel: move the lock-checking code into core
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
15 > wl = repo.wlock()
24392
dc7588ce06b3 tests: avoid deprecation warning
Matt Mackall <mpm@selenic.com>
parents: 24388
diff changeset
16 > wl.release()
dc7588ce06b3 tests: avoid deprecation warning
Matt Mackall <mpm@selenic.com>
parents: 24388
diff changeset
17 > lo.release()
24744
bedefc611f25 wlock: only issue devel warning when actually acquiring the lock
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 24555
diff changeset
18 >
bedefc611f25 wlock: only issue devel warning when actually acquiring the lock
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 24555
diff changeset
19 > @command('properlocking', [], '')
bedefc611f25 wlock: only issue devel warning when actually acquiring the lock
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 24555
diff changeset
20 > def properlocking(ui, repo):
bedefc611f25 wlock: only issue devel warning when actually acquiring the lock
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 24555
diff changeset
21 > """check that reentrance is fine"""
bedefc611f25 wlock: only issue devel warning when actually acquiring the lock
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 24555
diff changeset
22 > wl = repo.wlock()
bedefc611f25 wlock: only issue devel warning when actually acquiring the lock
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 24555
diff changeset
23 > lo = repo.lock()
bedefc611f25 wlock: only issue devel warning when actually acquiring the lock
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 24555
diff changeset
24 > tr = repo.transaction('proper')
bedefc611f25 wlock: only issue devel warning when actually acquiring the lock
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 24555
diff changeset
25 > tr2 = repo.transaction('proper')
bedefc611f25 wlock: only issue devel warning when actually acquiring the lock
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 24555
diff changeset
26 > lo2 = repo.lock()
bedefc611f25 wlock: only issue devel warning when actually acquiring the lock
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 24555
diff changeset
27 > wl2 = repo.wlock()
bedefc611f25 wlock: only issue devel warning when actually acquiring the lock
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 24555
diff changeset
28 > wl2.release()
bedefc611f25 wlock: only issue devel warning when actually acquiring the lock
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 24555
diff changeset
29 > lo2.release()
bedefc611f25 wlock: only issue devel warning when actually acquiring the lock
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 24555
diff changeset
30 > tr2.close()
bedefc611f25 wlock: only issue devel warning when actually acquiring the lock
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 24555
diff changeset
31 > tr.close()
bedefc611f25 wlock: only issue devel warning when actually acquiring the lock
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 24555
diff changeset
32 > lo.release()
bedefc611f25 wlock: only issue devel warning when actually acquiring the lock
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 24555
diff changeset
33 > wl.release()
24386
d6ac30f4edef devel: move the lock-checking code into core
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
34 > EOF
d6ac30f4edef devel: move the lock-checking code into core
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
35
d6ac30f4edef devel: move the lock-checking code into core
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
36 $ cat << EOF >> $HGRCPATH
d6ac30f4edef devel: move the lock-checking code into core
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
37 > [extensions]
d6ac30f4edef devel: move the lock-checking code into core
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
38 > buggylocking=$TESTTMP/buggylocking.py
d6ac30f4edef devel: move the lock-checking code into core
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
39 > [devel]
d6ac30f4edef devel: move the lock-checking code into core
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
40 > all=1
d6ac30f4edef devel: move the lock-checking code into core
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
41 > EOF
d6ac30f4edef devel: move the lock-checking code into core
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
42
d6ac30f4edef devel: move the lock-checking code into core
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
43 $ hg init lock-checker
d6ac30f4edef devel: move the lock-checking code into core
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
44 $ cd lock-checker
d6ac30f4edef devel: move the lock-checking code into core
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
45 $ hg buggylocking
24388
026f8af88e49 devel: also warn about transaction started without a lock
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 24386
diff changeset
46 transaction with no lock
24386
d6ac30f4edef devel: move the lock-checking code into core
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
47 "lock" taken before "wlock"
d6ac30f4edef devel: move the lock-checking code into core
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
48 $ cat << EOF >> $HGRCPATH
d6ac30f4edef devel: move the lock-checking code into core
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
49 > [devel]
d6ac30f4edef devel: move the lock-checking code into core
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
50 > all=0
d6ac30f4edef devel: move the lock-checking code into core
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
51 > check-locks=1
d6ac30f4edef devel: move the lock-checking code into core
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
52 > EOF
d6ac30f4edef devel: move the lock-checking code into core
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
53 $ hg buggylocking
24388
026f8af88e49 devel: also warn about transaction started without a lock
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 24386
diff changeset
54 transaction with no lock
24386
d6ac30f4edef devel: move the lock-checking code into core
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
55 "lock" taken before "wlock"
d6ac30f4edef devel: move the lock-checking code into core
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
56 $ hg buggylocking --traceback
24388
026f8af88e49 devel: also warn about transaction started without a lock
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 24386
diff changeset
57 transaction with no lock
026f8af88e49 devel: also warn about transaction started without a lock
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 24386
diff changeset
58 at:
24555
1b97cc5d2272 tests: fix py2.4 glob for devel warnings
Matt Mackall <mpm@selenic.com>
parents: 24392
diff changeset
59 */hg:* in * (glob)
24388
026f8af88e49 devel: also warn about transaction started without a lock
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 24386
diff changeset
60 */mercurial/dispatch.py:* in run (glob)
026f8af88e49 devel: also warn about transaction started without a lock
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 24386
diff changeset
61 */mercurial/dispatch.py:* in dispatch (glob)
026f8af88e49 devel: also warn about transaction started without a lock
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 24386
diff changeset
62 */mercurial/dispatch.py:* in _runcatch (glob)
026f8af88e49 devel: also warn about transaction started without a lock
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 24386
diff changeset
63 */mercurial/dispatch.py:* in _dispatch (glob)
026f8af88e49 devel: also warn about transaction started without a lock
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 24386
diff changeset
64 */mercurial/dispatch.py:* in runcommand (glob)
026f8af88e49 devel: also warn about transaction started without a lock
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 24386
diff changeset
65 */mercurial/dispatch.py:* in _runcommand (glob)
026f8af88e49 devel: also warn about transaction started without a lock
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 24386
diff changeset
66 */mercurial/dispatch.py:* in checkargs (glob)
026f8af88e49 devel: also warn about transaction started without a lock
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 24386
diff changeset
67 */mercurial/dispatch.py:* in <lambda> (glob)
026f8af88e49 devel: also warn about transaction started without a lock
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 24386
diff changeset
68 */mercurial/util.py:* in check (glob)
026f8af88e49 devel: also warn about transaction started without a lock
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 24386
diff changeset
69 $TESTTMP/buggylocking.py:* in buggylocking (glob)
24386
d6ac30f4edef devel: move the lock-checking code into core
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
70 "lock" taken before "wlock"
d6ac30f4edef devel: move the lock-checking code into core
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
71 at:
24555
1b97cc5d2272 tests: fix py2.4 glob for devel warnings
Matt Mackall <mpm@selenic.com>
parents: 24392
diff changeset
72 */hg:* in * (glob)
24386
d6ac30f4edef devel: move the lock-checking code into core
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
73 */mercurial/dispatch.py:* in run (glob)
d6ac30f4edef devel: move the lock-checking code into core
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
74 */mercurial/dispatch.py:* in dispatch (glob)
d6ac30f4edef devel: move the lock-checking code into core
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
75 */mercurial/dispatch.py:* in _runcatch (glob)
d6ac30f4edef devel: move the lock-checking code into core
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
76 */mercurial/dispatch.py:* in _dispatch (glob)
d6ac30f4edef devel: move the lock-checking code into core
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
77 */mercurial/dispatch.py:* in runcommand (glob)
d6ac30f4edef devel: move the lock-checking code into core
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
78 */mercurial/dispatch.py:* in _runcommand (glob)
d6ac30f4edef devel: move the lock-checking code into core
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
79 */mercurial/dispatch.py:* in checkargs (glob)
d6ac30f4edef devel: move the lock-checking code into core
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
80 */mercurial/dispatch.py:* in <lambda> (glob)
d6ac30f4edef devel: move the lock-checking code into core
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
81 */mercurial/util.py:* in check (glob)
d6ac30f4edef devel: move the lock-checking code into core
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
82 $TESTTMP/buggylocking.py:* in buggylocking (glob)
24744
bedefc611f25 wlock: only issue devel warning when actually acquiring the lock
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 24555
diff changeset
83 $ hg properlocking
24386
d6ac30f4edef devel: move the lock-checking code into core
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
84 $ cd ..