##// END OF EJS Templates
[PATCH] Enables lock work under the other 'OS'...
mpm@selenic.com -
r422:10c43444 default
parent child Browse files
Show More
@@ -6,6 +6,7 b''
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
@@ -34,10 +35,10 b' class lock:'
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:
@@ -18,7 +18,22 b' def rename(src, dst):'
18 if os.name == 'nt':
18 if os.name == 'nt':
19 def pconvert(path):
19 def pconvert(path):
20 return path.replace("\\", "/")
20 return path.replace("\\", "/")
21
22 def makelock(info, pathname):
23 ld = os.open(pathname, os.O_CREAT | os.O_WRONLY | os.O_EXCL)
24 os.write(ld, info)
25 os.close(ld)
26
27 def readlock(pathname):
28 return file(pathname).read()
21 else:
29 else:
22 def pconvert(path):
30 def pconvert(path):
23 return path
31 return path
24
32
33 def makelock(info, pathname):
34 os.symlink(info, pathname)
35
36 def readlock(pathname):
37 return os.readlink(pathname)
38
39
General Comments 0
You need to be logged in to leave comments. Login now