Show More
@@ -247,6 +247,9 ui:: | |||
|
247 | 247 | remote command to use for clone/push/pull operations. Default is 'hg'. |
|
248 | 248 | ssh;; |
|
249 | 249 | command to use for SSH connections. Default is 'ssh'. |
|
250 | timeout;; | |
|
251 | The timeout used when a lock is held (in seconds), a negative value | |
|
252 | means no timeout. Default is 1024. | |
|
250 | 253 | username;; |
|
251 | 254 | The committer of a changeset created when running "commit". |
|
252 | 255 | Typically a person's name and email address, e.g. "Fred Widget |
@@ -261,7 +261,14 class localrepository(object): | |||
|
261 | 261 | if not wait: |
|
262 | 262 | raise inst |
|
263 | 263 | self.ui.warn(_("waiting for lock held by %s\n") % inst.args[0]) |
|
264 | l = lock.lock(self.join(lockname), wait, releasefn) | |
|
264 | try: | |
|
265 | # default to 1024 seconds timeout | |
|
266 | l = lock.lock(self.join(lockname), | |
|
267 | int(self.ui.config("ui", "timeout") or 1024), | |
|
268 | releasefn) | |
|
269 | except lock.LockHeld, inst: | |
|
270 | raise util.Abort(_("timeout while waiting for " | |
|
271 | "lock held by %s") % inst.args[0]) | |
|
265 | 272 | if acquirefn: |
|
266 | 273 | acquirefn() |
|
267 | 274 | return l |
@@ -16,10 +16,10 class LockUnavailable(LockException): | |||
|
16 | 16 | pass |
|
17 | 17 | |
|
18 | 18 | class lock(object): |
|
19 |
def __init__(self, file, |
|
|
19 | def __init__(self, file, timeout=-1, releasefn=None): | |
|
20 | 20 | self.f = file |
|
21 | 21 | self.held = 0 |
|
22 |
self. |
|
|
22 | self.timeout = timeout | |
|
23 | 23 | self.releasefn = releasefn |
|
24 | 24 | self.lock() |
|
25 | 25 | |
@@ -27,13 +27,16 class lock(object): | |||
|
27 | 27 | self.release() |
|
28 | 28 | |
|
29 | 29 | def lock(self): |
|
30 | timeout = self.timeout | |
|
30 | 31 | while 1: |
|
31 | 32 | try: |
|
32 | 33 | self.trylock() |
|
33 | 34 | return 1 |
|
34 | 35 | except LockHeld, inst: |
|
35 |
if |
|
|
36 | if timeout != 0: | |
|
36 | 37 | time.sleep(1) |
|
38 | if timeout > 0: | |
|
39 | timeout -= 1 | |
|
37 | 40 | continue |
|
38 | 41 | raise inst |
|
39 | 42 |
General Comments 0
You need to be logged in to leave comments.
Login now