Show More
@@ -1,76 +1,78 b'' | |||
|
1 | 1 | #require unix-permissions no-root no-windows |
|
2 | 2 | |
|
3 | 3 | Prepare |
|
4 | 4 | |
|
5 | 5 | $ hg init a |
|
6 | 6 | $ echo a > a/a |
|
7 | 7 | $ hg -R a ci -A -m a |
|
8 | 8 | adding a |
|
9 | 9 | |
|
10 | 10 | $ hg clone a b |
|
11 | 11 | updating to branch default |
|
12 | 12 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
13 | 13 | |
|
14 | 14 | Test that raising an exception in the release function doesn't cause the lock to choke |
|
15 | 15 | |
|
16 | 16 | $ cat > testlock.py << EOF |
|
17 | 17 | > from mercurial import cmdutil, error, error |
|
18 | 18 | > |
|
19 | 19 | > cmdtable = {} |
|
20 | 20 | > command = cmdutil.command(cmdtable) |
|
21 | 21 | > |
|
22 | 22 | > def acquiretestlock(repo, releaseexc): |
|
23 | 23 | > def unlock(): |
|
24 | 24 | > if releaseexc: |
|
25 | 25 | > raise error.Abort('expected release exception') |
|
26 | 26 | > l = repo._lock(repo.vfs, 'testlock', False, unlock, None, 'test lock') |
|
27 | 27 | > return l |
|
28 | 28 | > |
|
29 | 29 | > @command('testlockexc') |
|
30 | 30 | > def testlockexc(ui, repo): |
|
31 | 31 | > testlock = acquiretestlock(repo, True) |
|
32 | 32 | > try: |
|
33 | 33 | > testlock.release() |
|
34 | 34 | > finally: |
|
35 | 35 | > try: |
|
36 | 36 | > testlock = acquiretestlock(repo, False) |
|
37 | 37 | > except error.LockHeld: |
|
38 | 38 | > raise error.Abort('lockfile on disk even after releasing!') |
|
39 | 39 | > testlock.release() |
|
40 | 40 | > EOF |
|
41 | 41 | $ cat >> $HGRCPATH << EOF |
|
42 | 42 | > [extensions] |
|
43 | 43 | > testlock=$TESTTMP/testlock.py |
|
44 | 44 | > EOF |
|
45 | 45 | |
|
46 | 46 | $ hg -R b testlockexc |
|
47 | 47 | abort: expected release exception |
|
48 | 48 | [255] |
|
49 | 49 | |
|
50 | 50 | One process waiting for another |
|
51 | 51 | |
|
52 | 52 | $ cat > hooks.py << EOF |
|
53 | 53 | > import time |
|
54 | 54 | > def sleepone(**x): time.sleep(1) |
|
55 | 55 | > def sleephalf(**x): time.sleep(0.5) |
|
56 | 56 | > EOF |
|
57 | 57 | $ echo b > b/b |
|
58 | 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 | 63 | waiting for lock on working directory of b held by '*:*' (glob) |
|
61 |
got lock after |
|
|
62 | $ wait | |
|
64 | got lock after * seconds (glob) | |
|
63 | 65 | $ cat stdout |
|
64 | 66 | adding b |
|
65 | 67 | |
|
66 | 68 | Pushing to a local read-only repo that can't be locked |
|
67 | 69 | |
|
68 | 70 | $ chmod 100 a/.hg/store |
|
69 | 71 | |
|
70 | 72 | $ hg -R b push a |
|
71 | 73 | pushing to a |
|
72 | 74 | searching for changes |
|
73 | 75 | abort: could not lock repository a: Permission denied |
|
74 | 76 | [255] |
|
75 | 77 | |
|
76 | 78 | $ chmod 700 a/.hg/store |
General Comments 0
You need to be logged in to leave comments.
Login now