Show More
@@ -1302,7 +1302,7 b' def debuglocks(ui, repo, **opts):' | |||
|
1302 | 1302 | repo.svfs.unlink('lock') |
|
1303 | 1303 | if opts.get(r'force_wlock'): |
|
1304 | 1304 | repo.vfs.unlink('wlock') |
|
1305 | if opts.get(r'force_lock') or opts.get(r'force_lock'): | |
|
1305 | if opts.get(r'force_lock') or opts.get(r'force_wlock'): | |
|
1306 | 1306 | return 0 |
|
1307 | 1307 | |
|
1308 | 1308 | now = time.time() |
@@ -145,6 +145,122 b' Test max chain len' | |||
|
145 | 145 | 7 6 -1 ??? ??? ??? ??? ??? 0 ??? ???? ? 1 2 (glob) |
|
146 | 146 | 8 7 -1 ??? ??? ??? ??? ??? 0 ??? ???? ? 1 3 (glob) |
|
147 | 147 | |
|
148 | Test debuglocks command: | |
|
149 | ||
|
150 | $ hg debuglocks | |
|
151 | lock: free | |
|
152 | wlock: free | |
|
153 | ||
|
154 | * Test setting the lock | |
|
155 | ||
|
156 | waitlock <file> will wait for file to be created. If it isn't in a reasonable | |
|
157 | amount of time, displays error message and returns 1 | |
|
158 | $ waitlock() { | |
|
159 | > start=`date +%s` | |
|
160 | > timeout=1 | |
|
161 | > while [ \( ! -f $1 \) -a \( ! -L $1 \) ]; do | |
|
162 | > now=`date +%s` | |
|
163 | > if [ "`expr $now - $start`" -gt $timeout ]; then | |
|
164 | > echo "timeout: $1 was not created in $timeout seconds" | |
|
165 | > return 1 | |
|
166 | > fi | |
|
167 | > sleep 0.1 | |
|
168 | > done | |
|
169 | > } | |
|
170 | dolock [wlock] [lock] will set the locks until interrupted | |
|
171 | $ dolock() { | |
|
172 | > declare -A options | |
|
173 | > options=([${1:-nolock}]=1 [${2:-nowlock}]=1) | |
|
174 | > python <<EOF | |
|
175 | > from mercurial import hg, ui as uimod | |
|
176 | > import os | |
|
177 | > import time | |
|
178 | > | |
|
179 | > repo = hg.repository(uimod.ui.load(), path='.') | |
|
180 | > `[ -n "${options["wlock"]}" ] && echo "with repo.wlock(False):" || echo "if True:"` | |
|
181 | > `[ -n "${options["lock"]}" ] && echo "with repo.lock(False):" || echo "if True:"` | |
|
182 | > while not os.path.exists('.hg/unlock'): | |
|
183 | > time.sleep(0.1) | |
|
184 | > os.unlink('.hg/unlock') | |
|
185 | > EOF | |
|
186 | > } | |
|
187 | ||
|
188 | $ dolock lock & | |
|
189 | $ waitlock .hg/store/lock | |
|
190 | ||
|
191 | $ hg debuglocks | |
|
192 | lock: user *, process * (*s) (glob) | |
|
193 | wlock: free | |
|
194 | [1] | |
|
195 | $ touch .hg/unlock | |
|
196 | $ wait | |
|
197 | ||
|
198 | * Test setting the wlock | |
|
199 | ||
|
200 | $ dolock wlock & | |
|
201 | $ waitlock .hg/wlock | |
|
202 | ||
|
203 | $ hg debuglocks | |
|
204 | lock: free | |
|
205 | wlock: user *, process * (*s) (glob) | |
|
206 | [1] | |
|
207 | $ touch .hg/unlock | |
|
208 | $ wait | |
|
209 | ||
|
210 | * Test setting both locks | |
|
211 | ||
|
212 | $ dolock wlock lock & | |
|
213 | $ waitlock .hg/wlock && waitlock .hg/store/lock | |
|
214 | ||
|
215 | $ hg debuglocks | |
|
216 | lock: user *, process * (*s) (glob) | |
|
217 | wlock: user *, process * (*s) (glob) | |
|
218 | [2] | |
|
219 | $ touch .hg/unlock | |
|
220 | $ wait | |
|
221 | ||
|
222 | $ hg debuglocks | |
|
223 | lock: free | |
|
224 | wlock: free | |
|
225 | ||
|
226 | * Test forcing the lock | |
|
227 | ||
|
228 | $ dolock lock & | |
|
229 | $ waitlock .hg/store/lock | |
|
230 | ||
|
231 | $ hg debuglocks | |
|
232 | lock: user *, process * (*s) (glob) | |
|
233 | wlock: free | |
|
234 | [1] | |
|
235 | ||
|
236 | $ hg debuglocks -L | |
|
237 | ||
|
238 | $ hg debuglocks | |
|
239 | lock: free | |
|
240 | wlock: free | |
|
241 | ||
|
242 | $ touch .hg/unlock | |
|
243 | $ wait | |
|
244 | ||
|
245 | * Test forcing the wlock | |
|
246 | ||
|
247 | $ dolock wlock & | |
|
248 | $ waitlock .hg/wlock | |
|
249 | ||
|
250 | $ hg debuglocks | |
|
251 | lock: free | |
|
252 | wlock: user *, process * (*s) (glob) | |
|
253 | [1] | |
|
254 | ||
|
255 | $ hg debuglocks -W | |
|
256 | ||
|
257 | $ hg debuglocks | |
|
258 | lock: free | |
|
259 | wlock: free | |
|
260 | ||
|
261 | $ touch .hg/unlock | |
|
262 | $ wait | |
|
263 | ||
|
148 | 264 | Test WdirUnsupported exception |
|
149 | 265 | |
|
150 | 266 | $ hg debugdata -c ffffffffffffffffffffffffffffffffffffffff |
General Comments 0
You need to be logged in to leave comments.
Login now