Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/util.py @ 13890:31eb145b50b6
util: move checklink() to posix.py and return False on Windows
Python added support for Windows 6.0 (Vista) symbolic links in 3.2 [1], but
even these symbolic links aren't what we can expect from a canonical
symbolic link, since creation requires SeCreateSymbolicLinkPrivilege,
which typically only admins have.
So we can safely assume that we don't have symbolic links on Windows.
[1] http://docs.python.org/py3k/library/os.html#os.symlink
author | Adrian Buehlmann <adrian@cadifra.com> |
---|---|
date | Tue, 05 Apr 2011 11:55:52 +0200 |
parents | 9a96efc4af8a |
children | 93452579df9e |
comparison
equal
deleted
inserted
replaced
13889:9a96efc4af8a | 13890:31eb145b50b6 |
---|---|
681 result.append(part) | 681 result.append(part) |
682 dir = os.path.join(dir, lpart) | 682 dir = os.path.join(dir, lpart) |
683 | 683 |
684 return ''.join(result) | 684 return ''.join(result) |
685 | 685 |
686 def checklink(path): | |
687 """check whether the given path is on a symlink-capable filesystem""" | |
688 # mktemp is not racy because symlink creation will fail if the | |
689 # file already exists | |
690 name = tempfile.mktemp(dir=path, prefix='hg-checklink-') | |
691 try: | |
692 os.symlink(".", name) | |
693 os.unlink(name) | |
694 return True | |
695 except (OSError, AttributeError): | |
696 return False | |
697 | |
698 def checknlink(testfile): | 686 def checknlink(testfile): |
699 '''check whether hardlink count reporting works properly''' | 687 '''check whether hardlink count reporting works properly''' |
700 | 688 |
701 # testfile may be open, so we need a separate file for checking to | 689 # testfile may be open, so we need a separate file for checking to |
702 # work around issue2543 (or testfile may get lost on Samba shares) | 690 # work around issue2543 (or testfile may get lost on Samba shares) |