Mercurial > hg > mercurial-crew-with-dirclash
comparison mercurial/lock.py @ 3686:4308f4cdc07b
Don't step into an endless loop when lock file is empty.
author | Thomas Arendsen Hein <thomas@intevation.de> |
---|---|
date | Mon, 20 Nov 2006 19:36:28 +0100 |
parents | 345bac2bc4ec |
children | abaee83ce0a6 |
comparison
equal
deleted
inserted
replaced
3685:193e9c6d1a6d | 3686:4308f4cdc07b |
---|---|
69 util.makelock(self.id, self.f) | 69 util.makelock(self.id, self.f) |
70 self.held = 1 | 70 self.held = 1 |
71 except (OSError, IOError), why: | 71 except (OSError, IOError), why: |
72 if why.errno == errno.EEXIST: | 72 if why.errno == errno.EEXIST: |
73 locker = self.testlock() | 73 locker = self.testlock() |
74 if locker: | 74 if locker is not None: |
75 raise LockHeld(errno.EAGAIN, self.f, self.desc, | 75 raise LockHeld(errno.EAGAIN, self.f, self.desc, |
76 locker) | 76 locker) |
77 else: | 77 else: |
78 raise LockUnavailable(why.errno, why.strerror, | 78 raise LockUnavailable(why.errno, why.strerror, |
79 why.filename, self.desc) | 79 why.filename, self.desc) |
80 | 80 |
81 def testlock(self): | 81 def testlock(self): |
82 '''return id of locker if lock is valid, else None.''' | 82 """return id of locker if lock is valid, else None. |
83 # if old-style lock, we cannot tell what machine locker is on. | 83 |
84 # with new-style lock, if locker is on this machine, we can | 84 If old-style lock, we cannot tell what machine locker is on. |
85 # see if locker is alive. if locker is on this machine but | 85 with new-style lock, if locker is on this machine, we can |
86 # not alive, we can safely break lock. | 86 see if locker is alive. If locker is on this machine but |
87 not alive, we can safely break lock. | |
88 | |
89 The lock file is only deleted when None is returned. | |
90 | |
91 """ | |
87 locker = util.readlock(self.f) | 92 locker = util.readlock(self.f) |
88 try: | 93 try: |
89 host, pid = locker.split(":", 1) | 94 host, pid = locker.split(":", 1) |
90 except ValueError: | 95 except ValueError: |
91 return locker | 96 return locker |