Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/util.py @ 6884:11229144aa01
merge with crew-stable
author | Dirkjan Ochtman <dirkjan@ochtman.nl> |
---|---|
date | Tue, 12 Aug 2008 17:47:08 +0200 |
parents | 01db3e101362 202d178ec706 |
children | 4674706b5b95 |
comparison
equal
deleted
inserted
replaced
6876:077f1e637cd8 | 6884:11229144aa01 |
---|---|
1067 | 1067 |
1068 def testpid(pid): | 1068 def testpid(pid): |
1069 '''return False if pid dead, True if running or not known''' | 1069 '''return False if pid dead, True if running or not known''' |
1070 return True | 1070 return True |
1071 | 1071 |
1072 def set_flags(f, flags): | 1072 def set_flags(f, l, x): |
1073 pass | 1073 pass |
1074 | 1074 |
1075 def set_binary(fd): | 1075 def set_binary(fd): |
1076 # When run without console, pipes may expose invalid | 1076 # When run without console, pipes may expose invalid |
1077 # fileno(), usually set to -1. | 1077 # fileno(), usually set to -1. |
1214 | 1214 |
1215 def is_exec(f): | 1215 def is_exec(f): |
1216 """check whether a file is executable""" | 1216 """check whether a file is executable""" |
1217 return (os.lstat(f).st_mode & 0100 != 0) | 1217 return (os.lstat(f).st_mode & 0100 != 0) |
1218 | 1218 |
1219 def set_flags(f, flags): | 1219 def set_flags(f, l, x): |
1220 s = os.lstat(f).st_mode | 1220 s = os.lstat(f).st_mode |
1221 x = "x" in flags | |
1222 l = "l" in flags | |
1223 if l: | 1221 if l: |
1224 if not stat.S_ISLNK(s): | 1222 if not stat.S_ISLNK(s): |
1225 # switch file to link | 1223 # switch file to link |
1226 data = file(f).read() | 1224 data = file(f).read() |
1227 os.unlink(f) | 1225 os.unlink(f) |
1228 os.symlink(data, f) | 1226 try: |
1227 os.symlink(data, f) | |
1228 except: | |
1229 # failed to make a link, rewrite file | |
1230 file(f, "w").write(data) | |
1229 # no chmod needed at this point | 1231 # no chmod needed at this point |
1230 return | 1232 return |
1231 if stat.S_ISLNK(s): | 1233 if stat.S_ISLNK(s): |
1232 # switch link to file | 1234 # switch link to file |
1233 data = os.readlink(f) | 1235 data = os.readlink(f) |