Mercurial > hg
comparison mercurial/lock.py @ 422:10c43444a38e
[PATCH] Enables lock work under the other 'OS'
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
[PATCH] Enables lock work under the other 'OS'
From: K Thananchayan <thananck@yahoo.com>
os.symlink is not supported under Windows. This patch
introduces util.mklockf, util.getlowner that use
regular files under Winodws but symlink under unix.
tweaked by mpm:
- changed function names
- fixed to work on UNIX
manifest hash: 6f650a78a3b203dcad2f861582500b6b4036599a
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (GNU/Linux)
iD8DBQFCuN5sywK+sNU5EO8RAva8AJ9L9z/JHRAJS1bix48ZzSpn9ZUyPwCffhmg
UfLSFBmd5tPDDi3mgsrdDEA=
=ZYS9
-----END PGP SIGNATURE-----
author | mpm@selenic.com |
---|---|
date | Tue, 21 Jun 2005 19:43:40 -0800 |
parents | 0b4c5cb953d9 |
children | 688d03d6997a |
comparison
equal
deleted
inserted
replaced
421:43b8da7420a9 | 422:10c43444a38e |
---|---|
4 # | 4 # |
5 # This software may be used and distributed according to the terms | 5 # This software may be used and distributed according to the terms |
6 # of the GNU General Public License, incorporated herein by reference. | 6 # of the GNU General Public License, incorporated herein by reference. |
7 | 7 |
8 import os, time | 8 import os, time |
9 import util | |
9 | 10 |
10 class LockHeld(Exception): | 11 class LockHeld(Exception): |
11 pass | 12 pass |
12 | 13 |
13 class lock: | 14 class lock: |
32 raise inst | 33 raise inst |
33 | 34 |
34 def trylock(self): | 35 def trylock(self): |
35 pid = os.getpid() | 36 pid = os.getpid() |
36 try: | 37 try: |
37 os.symlink(str(pid), self.f) | 38 util.makelock(str(pid), self.f) |
38 self.held = 1 | 39 self.held = 1 |
39 except: | 40 except: |
40 raise LockHeld(os.readlink(self.f)) | 41 raise LockHeld(util.readlock(self.f)) |
41 | 42 |
42 def release(self): | 43 def release(self): |
43 if self.held: | 44 if self.held: |
44 self.held = 0 | 45 self.held = 0 |
45 os.unlink(self.f) | 46 os.unlink(self.f) |