# HG changeset patch # User Matt Mackall # Date 1167444271 21600 # Node ID 315d47991fd432d52cb0df2a5d93aaf66459d5d9 # Parent 3f0ba82c103f1c19ce239c3be013b2a7b8d7c8bc symlinks: check whether a filesystem supports symlinks diff -r 3f0ba82c103f -r 315d47991fd4 mercurial/util.py --- a/mercurial/util.py Fri Dec 29 20:04:31 2006 -0600 +++ b/mercurial/util.py Fri Dec 29 20:04:31 2006 -0600 @@ -713,6 +713,18 @@ return lambda x: is_exec(os.path.join(path, x)) return fallback +def checksymlink(path): + """check whether the given path is on a symlink-capable filesystem""" + # mktemp is not racy because symlink creation will fail if the + # file already exists + name = tempfile.mktemp(dir=path) + try: + os.symlink(".", name) + os.unlink(name) + return True + except OSError: + return False + # Platform specific variants if os.name == 'nt': import msvcrt