tests/test-lock-badness.t
changeset 26587 56b2bcea2529
parent 26028 6fbe35588433
child 29008 38292b227deb
equal deleted inserted replaced
26586:d51c658d3f04 26587:56b2bcea2529
    12   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
    12   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
    13 
    13 
    14 Test that raising an exception in the release function doesn't cause the lock to choke
    14 Test that raising an exception in the release function doesn't cause the lock to choke
    15 
    15 
    16   $ cat > testlock.py << EOF
    16   $ cat > testlock.py << EOF
    17   > from mercurial import cmdutil, error, util
    17   > from mercurial import cmdutil, error, error
    18   > 
    18   > 
    19   > cmdtable = {}
    19   > cmdtable = {}
    20   > command = cmdutil.command(cmdtable)
    20   > command = cmdutil.command(cmdtable)
    21   > 
    21   > 
    22   > def acquiretestlock(repo, releaseexc):
    22   > def acquiretestlock(repo, releaseexc):
    23   >     def unlock():
    23   >     def unlock():
    24   >         if releaseexc:
    24   >         if releaseexc:
    25   >             raise util.Abort('expected release exception')
    25   >             raise error.Abort('expected release exception')
    26   >     l = repo._lock(repo.vfs, 'testlock', False, unlock, None, 'test lock')
    26   >     l = repo._lock(repo.vfs, 'testlock', False, unlock, None, 'test lock')
    27   >     return l
    27   >     return l
    28   > 
    28   > 
    29   > @command('testlockexc')
    29   > @command('testlockexc')
    30   > def testlockexc(ui, repo):
    30   > def testlockexc(ui, repo):
    33   >         testlock.release()
    33   >         testlock.release()
    34   >     finally:
    34   >     finally:
    35   >         try:
    35   >         try:
    36   >             testlock = acquiretestlock(repo, False)
    36   >             testlock = acquiretestlock(repo, False)
    37   >         except error.LockHeld:
    37   >         except error.LockHeld:
    38   >             raise util.Abort('lockfile on disk even after releasing!')
    38   >             raise error.Abort('lockfile on disk even after releasing!')
    39   >         testlock.release()
    39   >         testlock.release()
    40   > EOF
    40   > EOF
    41   $ cat >> $HGRCPATH << EOF
    41   $ cat >> $HGRCPATH << EOF
    42   > [extensions]
    42   > [extensions]
    43   > testlock=$TESTTMP/testlock.py
    43   > testlock=$TESTTMP/testlock.py