comparison tests/test-lock-badness.t @ 20380:c697b70f295f

localrepo: give a sigh of relief when getting lock after waiting for it A message like this was sometimes shown when pushing: remote: waiting for lock on repository foo held by 'mercurial:20858' That could scare users, making them wonder whether the push actually succeeded. To mitigate that fear, issue an additional "warning" such as: got lock after 2 seconds The return value from lock.lock.lock() was unused - instead we return the delay. This also adds the first test coverage for waiting for locks.
author Mads Kiilerich <madski@unity3d.com>
date Thu, 06 Feb 2014 01:55:09 +0100
parents e54a078153f7
children 3bfac190c7cd
comparison
equal deleted inserted replaced
20379:b75a04502ced 20380:c697b70f295f
1 #if unix-permissions no-root 1 #if unix-permissions no-root no-windows
2
3 Prepare
4
2 $ hg init a 5 $ hg init a
3 $ echo a > a/a 6 $ echo a > a/a
4 $ hg -R a ci -A -m a 7 $ hg -R a ci -A -m a
5 adding a 8 adding a
6 9
7 $ hg clone a b 10 $ hg clone a b
8 updating to branch default 11 updating to branch default
9 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
10 13
14 One process waiting for another
15
16 $ cat > hooks.py << EOF
17 > import time
18 > def sleepone(**x): time.sleep(1)
19 > def sleephalf(**x): time.sleep(0.5)
20 > EOF
11 $ echo b > b/b 21 $ echo b > b/b
12 $ hg -R b ci -A -m b 22 $ hg -R b ci -A -m b --config hooks.precommit="python:`pwd`/hooks.py:sleepone" > stdout &
23 $ hg -R b up -q --config hooks.pre-update="python:`pwd`/hooks.py:sleephalf"
24 waiting for lock on working directory of b held by '*:*' (glob)
25 got lock after 1 seconds
26 warning: ignoring unknown working parent d2ae7f538514!
27 $ wait
28 $ cat stdout
13 adding b 29 adding b
30
31 Pushing to a local read-only repo that can't be locked
14 32
15 $ chmod 100 a/.hg/store 33 $ chmod 100 a/.hg/store
16 34
17 $ hg -R b push a 35 $ hg -R b push a
18 pushing to a 36 pushing to a