Mercurial > hg > mercurial-crew-with-dirclash
view mercurial/lock.py @ 478:f1804f2e7f35
Update of doc/hg.1.txt
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Update of doc/hg.1.txt
- - set date to release date of Mercurial 0.6
- - remove trailing spaces and other trivial changes
- - add 'hg root' and $HGEDITOR.
- - add another repository in the [paths] example
manifest hash: 873f058d10bf58c1e54381715c82c1d1aeeee1e9
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
iD8DBQFCvqRXW7P1GVgWeRoRAv/NAKCeiaHsrnUFDdlMMRj1QhL4gKvi6gCgkAL4
QhH/bw/Gjs7R+9LHJW/chxs=
=G3kF
-----END PGP SIGNATURE-----
author | Thomas Arendsen Hein <thomas@intevation.de> |
---|---|
date | Sun, 26 Jun 2005 13:49:27 +0100 |
parents | 688d03d6997a |
children | c6a2e41c8c60 |
line wrap: on
line source
# lock.py - simple locking scheme for mercurial # # Copyright 2005 Matt Mackall <mpm@selenic.com> # # This software may be used and distributed according to the terms # of the GNU General Public License, incorporated herein by reference. import os, time import util class LockHeld(Exception): pass class lock: def __init__(self, file, wait = 1): self.f = file self.held = 0 self.wait = wait self.lock() def __del__(self): self.release() def lock(self): while 1: try: self.trylock() return 1 except LockHeld, inst: if self.wait: time.sleep(1) continue raise inst def trylock(self): pid = os.getpid() try: util.makelock(str(pid), self.f) self.held = 1 except: raise LockHeld(util.readlock(self.f)) def release(self): if self.held: self.held = 0 os.unlink(self.f)