mercurial/posix.py
changeset 22946 77c121da6143
parent 22781 70624fda193d
child 23597 7a5bcd471f2e
equal deleted inserted replaced
22945:3232f92360d4 22946:77c121da6143
   154     # mktemp is not racy because symlink creation will fail if the
   154     # mktemp is not racy because symlink creation will fail if the
   155     # file already exists
   155     # file already exists
   156     name = tempfile.mktemp(dir=path, prefix='hg-checklink-')
   156     name = tempfile.mktemp(dir=path, prefix='hg-checklink-')
   157     try:
   157     try:
   158         fd = tempfile.NamedTemporaryFile(dir=path, prefix='hg-checklink-')
   158         fd = tempfile.NamedTemporaryFile(dir=path, prefix='hg-checklink-')
   159         os.symlink(os.path.basename(fd.name), name)
   159         try:
   160         os.unlink(name)
   160             os.symlink(os.path.basename(fd.name), name)
   161         return True
   161             os.unlink(name)
       
   162             return True
       
   163         finally:
       
   164             fd.close()
   162     except AttributeError:
   165     except AttributeError:
   163         return False
   166         return False
   164     except OSError, inst:
   167     except OSError, inst:
   165         # sshfs might report failure while successfully creating the link
   168         # sshfs might report failure while successfully creating the link
   166         if inst[0] == errno.EIO and os.path.exists(name):
   169         if inst[0] == errno.EIO and os.path.exists(name):