mercurial/posix.py
branchstable
changeset 19514 cfdae231ba78
parent 19131 af3b651505e2
child 20202 a6014018ec28
equal deleted inserted replaced
19513:9e8298a324ac 19514:cfdae231ba78
   152     """check whether the given path is on a symlink-capable filesystem"""
   152     """check whether the given path is on a symlink-capable filesystem"""
   153     # mktemp is not racy because symlink creation will fail if the
   153     # mktemp is not racy because symlink creation will fail if the
   154     # file already exists
   154     # file already exists
   155     name = tempfile.mktemp(dir=path, prefix='hg-checklink-')
   155     name = tempfile.mktemp(dir=path, prefix='hg-checklink-')
   156     try:
   156     try:
   157         os.symlink(".", name)
   157         fd = tempfile.NamedTemporaryFile(dir=path, prefix='hg-checklink-')
       
   158         os.symlink(os.path.basename(fd.name), name)
   158         os.unlink(name)
   159         os.unlink(name)
   159         return True
   160         return True
   160     except (OSError, AttributeError):
   161     except AttributeError:
       
   162         return False
       
   163     except OSError, inst:
       
   164         # sshfs might report failure while successfully creating the link
       
   165         if inst[0] == errno.EIO and os.path.exists(name):
       
   166             os.unlink(name)
   161         return False
   167         return False
   162 
   168 
   163 def checkosfilename(path):
   169 def checkosfilename(path):
   164     '''Check that the base-relative path is a valid filename on this platform.
   170     '''Check that the base-relative path is a valid filename on this platform.
   165     Returns None if the path is ok, or a UI string describing the problem.'''
   171     Returns None if the path is ok, or a UI string describing the problem.'''