Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/util.py @ 6878:202d178ec706
util: set_flags should survive failure to create link
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Sun, 10 Aug 2008 21:55:23 -0500 |
parents | 1d38f3605b20 |
children | 11229144aa01 b340cb536893 |
comparison
equal
deleted
inserted
replaced
6877:1d38f3605b20 | 6878:202d178ec706 |
---|---|
1148 if l: | 1148 if l: |
1149 if not stat.S_ISLNK(s): | 1149 if not stat.S_ISLNK(s): |
1150 # switch file to link | 1150 # switch file to link |
1151 data = file(f).read() | 1151 data = file(f).read() |
1152 os.unlink(f) | 1152 os.unlink(f) |
1153 os.symlink(data, f) | 1153 try: |
1154 os.symlink(data, f) | |
1155 except: | |
1156 # failed to make a link, rewrite file | |
1157 file(f, "w").write(data) | |
1154 # no chmod needed at this point | 1158 # no chmod needed at this point |
1155 return | 1159 return |
1156 if stat.S_ISLNK(s): | 1160 if stat.S_ISLNK(s): |
1157 # switch link to file | 1161 # switch link to file |
1158 data = os.readlink(f) | 1162 data = os.readlink(f) |