equal
deleted
inserted
replaced
217 def checklink(path): |
217 def checklink(path): |
218 """check whether the given path is on a symlink-capable filesystem""" |
218 """check whether the given path is on a symlink-capable filesystem""" |
219 # mktemp is not racy because symlink creation will fail if the |
219 # mktemp is not racy because symlink creation will fail if the |
220 # file already exists |
220 # file already exists |
221 while True: |
221 while True: |
222 name = tempfile.mktemp(dir=path, prefix='hg-checklink-') |
222 cachedir = os.path.join(path, '.hg', 'cache') |
|
223 if os.path.isdir(cachedir): |
|
224 checkdir = cachedir |
|
225 else: |
|
226 checkdir = path |
|
227 cachedir = None |
|
228 name = tempfile.mktemp(dir=checkdir, prefix='checklink-') |
223 try: |
229 try: |
224 fd = tempfile.NamedTemporaryFile(dir=path, prefix='hg-checklink-') |
230 fd = tempfile.NamedTemporaryFile(dir=checkdir, |
|
231 prefix='hg-checklink-') |
225 try: |
232 try: |
226 os.symlink(os.path.basename(fd.name), name) |
233 os.symlink(os.path.basename(fd.name), name) |
227 os.unlink(name) |
234 os.unlink(name) |
228 return True |
235 return True |
229 except OSError as inst: |
236 except OSError as inst: |