Show More
@@ -1,76 +1,78 b'' | |||||
1 | #require unix-permissions no-root no-windows |
|
1 | #require unix-permissions no-root no-windows | |
2 |
|
2 | |||
3 | Prepare |
|
3 | Prepare | |
4 |
|
4 | |||
5 | $ hg init a |
|
5 | $ hg init a | |
6 | $ echo a > a/a |
|
6 | $ echo a > a/a | |
7 | $ hg -R a ci -A -m a |
|
7 | $ hg -R a ci -A -m a | |
8 | adding a |
|
8 | adding a | |
9 |
|
9 | |||
10 | $ hg clone a b |
|
10 | $ hg clone a b | |
11 | updating to branch default |
|
11 | updating to branch default | |
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, error |
|
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 error.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): | |
31 | > testlock = acquiretestlock(repo, True) |
|
31 | > testlock = acquiretestlock(repo, True) | |
32 | > try: |
|
32 | > try: | |
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 error.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 | |
44 | > EOF |
|
44 | > EOF | |
45 |
|
45 | |||
46 | $ hg -R b testlockexc |
|
46 | $ hg -R b testlockexc | |
47 | abort: expected release exception |
|
47 | abort: expected release exception | |
48 | [255] |
|
48 | [255] | |
49 |
|
49 | |||
50 | One process waiting for another |
|
50 | One process waiting for another | |
51 |
|
51 | |||
52 | $ cat > hooks.py << EOF |
|
52 | $ cat > hooks.py << EOF | |
53 | > import time |
|
53 | > import time | |
54 | > def sleepone(**x): time.sleep(1) |
|
54 | > def sleepone(**x): time.sleep(1) | |
55 | > def sleephalf(**x): time.sleep(0.5) |
|
55 | > def sleephalf(**x): time.sleep(0.5) | |
56 | > EOF |
|
56 | > EOF | |
57 | $ echo b > b/b |
|
57 | $ echo b > b/b | |
58 | $ hg -R b ci -A -m b --config hooks.precommit="python:`pwd`/hooks.py:sleepone" > stdout & |
|
58 | $ hg -R b ci -A -m b --config hooks.precommit="python:`pwd`/hooks.py:sleepone" > stdout & | |
59 | $ hg -R b up -q --config hooks.pre-update="python:`pwd`/hooks.py:sleephalf" |
|
59 | $ hg -R b up -q --config hooks.pre-update="python:`pwd`/hooks.py:sleephalf" \ | |
|
60 | > > preup 2>&1 | |||
|
61 | $ wait | |||
|
62 | $ cat preup | |||
60 | waiting for lock on working directory of b held by '*:*' (glob) |
|
63 | waiting for lock on working directory of b held by '*:*' (glob) | |
61 |
got lock after |
|
64 | got lock after * seconds (glob) | |
62 | $ wait |
|
|||
63 | $ cat stdout |
|
65 | $ cat stdout | |
64 | adding b |
|
66 | adding b | |
65 |
|
67 | |||
66 | Pushing to a local read-only repo that can't be locked |
|
68 | Pushing to a local read-only repo that can't be locked | |
67 |
|
69 | |||
68 | $ chmod 100 a/.hg/store |
|
70 | $ chmod 100 a/.hg/store | |
69 |
|
71 | |||
70 | $ hg -R b push a |
|
72 | $ hg -R b push a | |
71 | pushing to a |
|
73 | pushing to a | |
72 | searching for changes |
|
74 | searching for changes | |
73 | abort: could not lock repository a: Permission denied |
|
75 | abort: could not lock repository a: Permission denied | |
74 | [255] |
|
76 | [255] | |
75 |
|
77 | |||
76 | $ chmod 700 a/.hg/store |
|
78 | $ chmod 700 a/.hg/store |
General Comments 0
You need to be logged in to leave comments.
Login now