##// END OF EJS Templates
lock: while releasing, unlink lockfile even if the release function throws...
Siddharth Agarwal -
r23032:f484be02 default
parent child Browse files
Show More
@@ -139,8 +139,10 b' class lock(object):'
139 139 if os.getpid() != self.pid:
140 140 # we forked, and are not the parent
141 141 return
142 try:
142 143 if self.releasefn:
143 144 self.releasefn()
145 finally:
144 146 try:
145 147 self.vfs.unlink(self.f)
146 148 except OSError:
@@ -11,6 +11,42 b' Prepare'
11 11 updating to branch default
12 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
15
16 $ cat > testlock.py << EOF
17 > from mercurial import cmdutil, error, util
18 >
19 > cmdtable = {}
20 > command = cmdutil.command(cmdtable)
21 >
22 > def acquiretestlock(repo, releaseexc):
23 > def unlock():
24 > if releaseexc:
25 > raise util.Abort('expected release exception')
26 > l = repo._lock(repo.vfs, 'testlock', False, unlock, None, 'test lock')
27 > return l
28 >
29 > @command('testlockexc')
30 > def testlockexc(ui, repo):
31 > testlock = acquiretestlock(repo, True)
32 > try:
33 > testlock.release()
34 > finally:
35 > try:
36 > testlock = acquiretestlock(repo, False)
37 > except error.LockHeld:
38 > raise util.Abort('lockfile on disk even after releasing!')
39 > testlock.release()
40 > EOF
41 $ cat >> $HGRCPATH << EOF
42 > [extensions]
43 > testlock=$TESTTMP/testlock.py
44 > EOF
45
46 $ hg -R b testlockexc
47 abort: expected release exception
48 [255]
49
14 50 One process waiting for another
15 51
16 52 $ cat > hooks.py << EOF
General Comments 0
You need to be logged in to leave comments. Login now