test-devel-warnings.t
118 lines
| 3.6 KiB
| text/troff
|
Tads3Lexer
/ tests / test-devel-warnings.t
Pierre-Yves David
|
r24386 | |||
$ cat << EOF > buggylocking.py | ||||
> """A small extension that acquire locks in the wrong order | ||||
> """ | ||||
> | ||||
Pierre-Yves David
|
r25630 | > from mercurial import cmdutil, repair, revset | ||
Pierre-Yves David
|
r24386 | > | ||
> cmdtable = {} | ||||
> command = cmdutil.command(cmdtable) | ||||
> | ||||
> @command('buggylocking', [], '') | ||||
> def buggylocking(ui, repo): | ||||
Pierre-Yves David
|
r24388 | > tr = repo.transaction('buggy') | ||
Pierre-Yves David
|
r24386 | > lo = repo.lock() | ||
> wl = repo.wlock() | ||||
Matt Mackall
|
r24392 | > wl.release() | ||
> lo.release() | ||||
Pierre-Yves David
|
r24744 | > | ||
> @command('properlocking', [], '') | ||||
> def properlocking(ui, repo): | ||||
> """check that reentrance is fine""" | ||||
> wl = repo.wlock() | ||||
> lo = repo.lock() | ||||
> tr = repo.transaction('proper') | ||||
> tr2 = repo.transaction('proper') | ||||
> lo2 = repo.lock() | ||||
> wl2 = repo.wlock() | ||||
> wl2.release() | ||||
> lo2.release() | ||||
> tr2.close() | ||||
> tr.close() | ||||
> lo.release() | ||||
> wl.release() | ||||
Pierre-Yves David
|
r24750 | > | ||
> @command('nowaitlocking', [], '') | ||||
> def nowaitlocking(ui, repo): | ||||
> lo = repo.lock() | ||||
> wl = repo.wlock(wait=False) | ||||
> wl.release() | ||||
> lo.release() | ||||
Pierre-Yves David
|
r25300 | > | ||
> @command('stripintr', [], '') | ||||
> def stripintr(ui, repo): | ||||
> lo = repo.lock() | ||||
> tr = repo.transaction('foobar') | ||||
> try: | ||||
> repair.strip(repo.ui, repo, [repo['.'].node()]) | ||||
> finally: | ||||
> lo.release() | ||||
Pierre-Yves David
|
r25630 | > | ||
> def oldstylerevset(repo, subset, x): | ||||
> return list(subset) | ||||
> | ||||
> revset.symbols['oldstyle'] = oldstylerevset | ||||
Pierre-Yves David
|
r24386 | > EOF | ||
$ cat << EOF >> $HGRCPATH | ||||
> [extensions] | ||||
> buggylocking=$TESTTMP/buggylocking.py | ||||
> [devel] | ||||
Pierre-Yves David
|
r25290 | > all-warnings=1 | ||
Pierre-Yves David
|
r24386 | > EOF | ||
$ hg init lock-checker | ||||
$ cd lock-checker | ||||
$ hg buggylocking | ||||
Pierre-Yves David
|
r24755 | devel-warn: transaction with no lock at: $TESTTMP/buggylocking.py:11 (buggylocking) | ||
devel-warn: "wlock" acquired after "lock" at: $TESTTMP/buggylocking.py:13 (buggylocking) | ||||
Pierre-Yves David
|
r24386 | $ cat << EOF >> $HGRCPATH | ||
> [devel] | ||||
> all=0 | ||||
> check-locks=1 | ||||
> EOF | ||||
$ hg buggylocking | ||||
Pierre-Yves David
|
r24755 | devel-warn: transaction with no lock at: $TESTTMP/buggylocking.py:11 (buggylocking) | ||
devel-warn: "wlock" acquired after "lock" at: $TESTTMP/buggylocking.py:13 (buggylocking) | ||||
Pierre-Yves David
|
r24386 | $ hg buggylocking --traceback | ||
Pierre-Yves David
|
r24755 | devel-warn: transaction with no lock at: | ||
Matt Mackall
|
r24555 | */hg:* in * (glob) | ||
Pierre-Yves David
|
r24388 | */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) | ||||
Pierre-Yves David
|
r24755 | devel-warn: "wlock" acquired after "lock" at: | ||
Matt Mackall
|
r24555 | */hg:* in * (glob) | ||
Pierre-Yves David
|
r24386 | */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) | ||||
Pierre-Yves David
|
r24744 | $ hg properlocking | ||
Pierre-Yves David
|
r24750 | $ hg nowaitlocking | ||
Pierre-Yves David
|
r25300 | |||
$ echo a > a | ||||
$ hg add a | ||||
$ hg commit -m a | ||||
$ hg stripintr | ||||
saved backup bundle to $TESTTMP/lock-checker/.hg/strip-backup/cb9a9f314b8b-cc5ccb0b-backup.hg (glob) | ||||
abort: programming error: cannot strip from inside a transaction | ||||
(contact your extension maintainer) | ||||
[255] | ||||
Pierre-Yves David
|
r25630 | $ hg log -r "oldstyle()" -T '{rev}\n' | ||
devel-warn: revset "oldstyle" use list instead of smartset, (upgrade your code) at: */mercurial/revset.py:* (mfunc) (glob) | ||||
0 | ||||
Pierre-Yves David
|
r24386 | $ cd .. | ||