Show More
@@ -717,21 +717,37 b' def checklink(path):' | |||||
717 |
|
717 | |||
718 | def checknlink(testfile): |
|
718 | def checknlink(testfile): | |
719 | '''check whether hardlink count reporting works properly''' |
|
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 | try: |
|
726 | try: | |
723 | os_link(testfile, f) |
|
727 | posixfile(f1, 'w').close() | |
724 |
except O |
|
728 | except IOError: | |
725 | return False |
|
729 | return False | |
726 |
|
730 | |||
|
731 | f2 = testfile + ".hgtmp2" | |||
|
732 | fd = None | |||
727 | try: |
|
733 | try: | |
|
734 | try: | |||
|
735 | os_link(f1, f2) | |||
|
736 | except OSError: | |||
|
737 | return False | |||
|
738 | ||||
728 | # nlinks() may behave differently for files on Windows shares if |
|
739 | # nlinks() may behave differently for files on Windows shares if | |
729 | # the file is open. |
|
740 | # the file is open. | |
730 | fd = open(f) |
|
741 | fd = open(f2) | |
731 | return nlinks(f) > 1 |
|
742 | return nlinks(f2) > 1 | |
732 | finally: |
|
743 | finally: | |
733 | fd.close() |
|
744 | if fd is not None: | |
734 | os.unlink(f) |
|
745 | fd.close() | |
|
746 | for f in (f1, f2): | |||
|
747 | try: | |||
|
748 | os.unlink(f) | |||
|
749 | except OSError: | |||
|
750 | pass | |||
735 |
|
751 | |||
736 | return False |
|
752 | return False | |
737 |
|
753 |
General Comments 0
You need to be logged in to leave comments.
Login now