##// END OF EJS Templates
test-lock: use synchronisation file instead of sleep...
marmoute -
r52390:9da3fcc5 stable
parent child Browse files
Show More
@@ -583,6 +583,11 b' default-type = "list_type"'
583
583
584 [[items]]
584 [[items]]
585 section = "devel"
585 section = "devel"
586 name = "lock-wait-sync-file"
587 default = ""
588
589 [[items]]
590 section = "devel"
586 name = "persistent-nodemap"
591 name = "persistent-nodemap"
587 default = false
592 default = false
588 documentation = """When true, revlogs use a special reference version of the \
593 documentation = """When true, revlogs use a special reference version of the \
@@ -3072,6 +3072,9 b' class localrepository:'
3072 warntimeout = self.ui.configint(b"ui", b"timeout.warn")
3072 warntimeout = self.ui.configint(b"ui", b"timeout.warn")
3073 # internal config: ui.signal-safe-lock
3073 # internal config: ui.signal-safe-lock
3074 signalsafe = self.ui.configbool(b'ui', b'signal-safe-lock')
3074 signalsafe = self.ui.configbool(b'ui', b'signal-safe-lock')
3075 sync_file = self.ui.config(b'devel', b'lock-wait-sync-file')
3076 if not sync_file:
3077 sync_file = None
3075
3078
3076 l = lockmod.trylock(
3079 l = lockmod.trylock(
3077 self.ui,
3080 self.ui,
@@ -3083,6 +3086,7 b' class localrepository:'
3083 acquirefn=acquirefn,
3086 acquirefn=acquirefn,
3084 desc=desc,
3087 desc=desc,
3085 signalsafe=signalsafe,
3088 signalsafe=signalsafe,
3089 devel_wait_sync_file=sync_file,
3086 )
3090 )
3087 return l
3091 return l
3088
3092
@@ -115,6 +115,7 b' def trylock(ui, vfs, lockname, timeout, '
115
115
116 This function is responsible to issue warnings and or debug messages about
116 This function is responsible to issue warnings and or debug messages about
117 the held lock while trying to acquires it."""
117 the held lock while trying to acquires it."""
118 devel_wait_file = kwargs.pop("devel_wait_sync_file", None)
118
119
119 def printwarning(printer, locker):
120 def printwarning(printer, locker):
120 """issue the usual "waiting on lock" message through any channel"""
121 """issue the usual "waiting on lock" message through any channel"""
@@ -150,6 +151,11 b' def trylock(ui, vfs, lockname, timeout, '
150 l._trylock()
151 l._trylock()
151 break
152 break
152 except error.LockHeld as inst:
153 except error.LockHeld as inst:
154 if devel_wait_file is not None:
155 # create the file to signal we are waiting
156 with open(devel_wait_file, 'w'):
157 pass
158
153 if delay == debugidx:
159 if delay == debugidx:
154 printwarning(ui.debug, inst.locker)
160 printwarning(ui.debug, inst.locker)
155 if delay == warningidx:
161 if delay == warningidx:
@@ -49,15 +49,32 b' Test that raising an exception in the re'
49
49
50 One process waiting for another
50 One process waiting for another
51
51
52 $ cat > hooks.py << EOF
52 $ SYNC_FILE_LOCKED="$TESTTMP/sync-file-locked"
53 > import time
53 $ export SYNC_FILE_LOCKED
54 > def sleepone(**x): time.sleep(1)
54 $ SYNC_FILE_TRYING_LOCK="$TESTTMP/sync-file-trying-lock"
55 > def sleephalf(**x): time.sleep(0.5)
55 $ export SYNC_FILE_TRYING_LOCK
56 $ cat << EOF > locker.sh
57 > $RUNTESTDIR/testlib/wait-on-file 10 $SYNC_FILE_TRYING_LOCK $SYNC_FILE_LOCKED;
58 > EOF
59 $ cat << EOF > waiter.sh
60 > $RUNTESTDIR/testlib/wait-on-file 10 $SYNC_FILE_LOCKED;
56 > EOF
61 > EOF
62 $ clean_sync() {
63 > rm -f "$SYNC_FILE_LOCKED"
64 > rm -f "$SYNC_FILE_TRYING_LOCK"
65 > }
66
67
68 $ clean_sync
57 $ echo b > b/b
69 $ echo b > b/b
58 $ hg -R b ci -A -m b --config hooks.precommit="python:`pwd`/hooks.py:sleepone" > stdout &
70 $ hg -R b ci -A -m b \
59 $ hg -R b up -q --config ui.timeout.warn=0 --config hooks.pre-update="python:`pwd`/hooks.py:sleephalf" \
71 > --config hooks.precommit="sh $TESTTMP/locker.sh" \
60 > > preup-stdout 2>preup-stderr
72 > > stdout &
73 $ hg -R b up -q \
74 > --config ui.timeout.warn=0 \
75 > --config hooks.pre-update="sh $TESTTMP/waiter.sh" \
76 > --config devel.lock-wait-sync-file="$SYNC_FILE_TRYING_LOCK" \
77 > > preup-stdout 2> preup-stderr
61 $ wait
78 $ wait
62 $ cat preup-stdout
79 $ cat preup-stdout
63 $ cat preup-stderr
80 $ cat preup-stderr
@@ -68,11 +85,16 b' One process waiting for another'
68
85
69 On processs waiting on another, warning after a long time.
86 On processs waiting on another, warning after a long time.
70
87
88 $ clean_sync
71 $ echo b > b/c
89 $ echo b > b/c
72 $ hg -R b ci -A -m b --config hooks.precommit="python:`pwd`/hooks.py:sleepone" > stdout &
90 $ hg -R b ci -A -m b \
73 $ hg -R b up -q --config hooks.pre-update="python:`pwd`/hooks.py:sleephalf" \
91 > --config hooks.precommit="sh $TESTTMP/locker.sh" \
74 > --config ui.timeout.warn=250 \
92 > > stdout &
75 > > preup-stdout 2>preup-stderr
93 $ hg -R b up -q \
94 > --config hooks.pre-update="sh $TESTTMP/waiter.sh" \
95 > --config devel.lock-wait-sync-file="$SYNC_FILE_TRYING_LOCK" \
96 > --config ui.timeout.warn=250 \
97 > > preup-stdout 2> preup-stderr
76 $ wait
98 $ wait
77 $ cat preup-stdout
99 $ cat preup-stdout
78 $ cat preup-stderr
100 $ cat preup-stderr
@@ -81,11 +103,16 b' On processs waiting on another, warning '
81
103
82 On processs waiting on another, warning disabled.
104 On processs waiting on another, warning disabled.
83
105
106 $ clean_sync
84 $ echo b > b/d
107 $ echo b > b/d
85 $ hg -R b ci -A -m b --config hooks.precommit="python:`pwd`/hooks.py:sleepone" > stdout &
108 $ hg -R b ci -A -m b \
86 $ hg -R b up -q --config hooks.pre-update="python:`pwd`/hooks.py:sleephalf" \
109 > --config hooks.precommit="sh $TESTTMP/locker.sh" \
87 > --config ui.timeout.warn=-1 \
110 > > stdout &
88 > > preup-stdout 2>preup-stderr
111 $ hg -R b up -q \
112 > --config hooks.pre-update="sh $TESTTMP/waiter.sh" \
113 > --config devel.lock-wait-sync-file="$SYNC_FILE_TRYING_LOCK" \
114 > --config ui.timeout.warn=-1 \
115 > > preup-stdout 2>preup-stderr
89 $ wait
116 $ wait
90 $ cat preup-stdout
117 $ cat preup-stdout
91 $ cat preup-stderr
118 $ cat preup-stderr
@@ -96,14 +123,19 b' check we still print debug output'
96
123
97 On processs waiting on another, warning after a long time (debug output on)
124 On processs waiting on another, warning after a long time (debug output on)
98
125
126 $ clean_sync
99 $ echo b > b/e
127 $ echo b > b/e
100 $ hg -R b ci -A -m b --config hooks.precommit="python:`pwd`/hooks.py:sleepone" > stdout &
128 $ hg -R b ci -A -m b \
101 $ hg -R b up --config hooks.pre-update="python:`pwd`/hooks.py:sleephalf" \
129 > --config hooks.precommit="sh $TESTTMP/locker.sh" \
102 > --config ui.timeout.warn=250 --debug\
130 > > stdout &
103 > > preup-stdout 2>preup-stderr
131 $ hg -R b up \
132 > --config hooks.pre-update="sh $TESTTMP/waiter.sh" \
133 > --config devel.lock-wait-sync-file="$SYNC_FILE_TRYING_LOCK" \
134 > --config ui.timeout.warn=250 --debug \
135 > > preup-stdout 2>preup-stderr
104 $ wait
136 $ wait
105 $ cat preup-stdout
137 $ cat preup-stdout
106 calling hook pre-update: hghook_pre-update.sleephalf
138 running hook pre-update: sh $TESTTMP/waiter.sh
107 waiting for lock on working directory of b held by process '*' on host '*' (glob)
139 waiting for lock on working directory of b held by process '*' on host '*' (glob)
108 got lock after * seconds (glob)
140 got lock after * seconds (glob)
109 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
141 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
@@ -113,14 +145,19 b' On processs waiting on another, warning '
113
145
114 On processs waiting on another, warning disabled, (debug output on)
146 On processs waiting on another, warning disabled, (debug output on)
115
147
148 $ clean_sync
116 $ echo b > b/f
149 $ echo b > b/f
117 $ hg -R b ci -A -m b --config hooks.precommit="python:`pwd`/hooks.py:sleepone" > stdout &
150 $ hg -R b ci -A -m b \
118 $ hg -R b up --config hooks.pre-update="python:`pwd`/hooks.py:sleephalf" \
151 > --config hooks.precommit="sh $TESTTMP/locker.sh" \
119 > --config ui.timeout.warn=-1 --debug\
152 > > stdout &
120 > > preup-stdout 2>preup-stderr
153 $ hg -R b up \
154 > --config hooks.pre-update="sh $TESTTMP/waiter.sh" \
155 > --config devel.lock-wait-sync-file="$SYNC_FILE_TRYING_LOCK" \
156 > --config ui.timeout.warn=-1 --debug\
157 > > preup-stdout 2>preup-stderr
121 $ wait
158 $ wait
122 $ cat preup-stdout
159 $ cat preup-stdout
123 calling hook pre-update: hghook_pre-update.sleephalf
160 running hook pre-update: sh $TESTTMP/waiter.sh
124 waiting for lock on working directory of b held by process '*' on host '*' (glob)
161 waiting for lock on working directory of b held by process '*' on host '*' (glob)
125 got lock after * seconds (glob)
162 got lock after * seconds (glob)
126 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
163 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
General Comments 0
You need to be logged in to leave comments. Login now