##// END OF EJS Templates
checknlink: use two testfiles (issue2543)...
Adrian Buehlmann -
r13204:5b83ab61 stable
parent child Browse files
Show More
@@ -717,21 +717,37 b' def checklink(path):'
717 717
718 718 def checknlink(testfile):
719 719 '''check whether hardlink count reporting works properly'''
720 f = testfile + ".hgtmp"
721 720
721 # testfile may be open, so we need a separate file for checking to
722 # work around issue2543 (or testfile may get lost on Samba shares)
723 f1 = testfile + ".hgtmp1"
724 if os.path.lexists(f1):
725 return False
722 726 try:
723 os_link(testfile, f)
724 except OSError:
727 posixfile(f1, 'w').close()
728 except IOError:
725 729 return False
726 730
731 f2 = testfile + ".hgtmp2"
732 fd = None
727 733 try:
734 try:
735 os_link(f1, f2)
736 except OSError:
737 return False
738
728 739 # nlinks() may behave differently for files on Windows shares if
729 740 # the file is open.
730 fd = open(f)
731 return nlinks(f) > 1
741 fd = open(f2)
742 return nlinks(f2) > 1
732 743 finally:
733 fd.close()
734 os.unlink(f)
744 if fd is not None:
745 fd.close()
746 for f in (f1, f2):
747 try:
748 os.unlink(f)
749 except OSError:
750 pass
735 751
736 752 return False
737 753
General Comments 0
You need to be logged in to leave comments. Login now