Show More
@@ -1457,21 +1457,14 b' def checknlink(testfile):' | |||
|
1457 | 1457 | |
|
1458 | 1458 | # testfile may be open, so we need a separate file for checking to |
|
1459 | 1459 | # work around issue2543 (or testfile may get lost on Samba shares) |
|
1460 | f1 = testfile + ".hgtmp1" | |
|
1461 | if os.path.lexists(f1): | |
|
1462 | return False | |
|
1460 | f1, f2, fd = None, None, None | |
|
1463 | 1461 | try: |
|
1464 | posixfile(f1, 'w').close() | |
|
1465 | except IOError: | |
|
1466 | try: | |
|
1467 | os.unlink(f1) | |
|
1468 | except OSError: | |
|
1469 | pass | |
|
1470 | return False | |
|
1471 | ||
|
1472 | f2 = testfile + ".hgtmp2" | |
|
1473 | fd = None | |
|
1474 | try: | |
|
1462 | fd, f1 = tempfile.mkstemp(prefix='.%s-' % os.path.basename(testfile), | |
|
1463 | suffix='1~', dir=os.path.dirname(testfile)) | |
|
1464 | os.close(fd) | |
|
1465 | fd = None | |
|
1466 | f2 = '%s2~' % f1[:-2] | |
|
1467 | ||
|
1475 | 1468 | oslink(f1, f2) |
|
1476 | 1469 | # nlinks() may behave differently for files on Windows shares if |
|
1477 | 1470 | # the file is open. |
@@ -1484,7 +1477,8 b' def checknlink(testfile):' | |||
|
1484 | 1477 | fd.close() |
|
1485 | 1478 | for f in (f1, f2): |
|
1486 | 1479 | try: |
|
1487 | os.unlink(f) | |
|
1480 | if f is not None: | |
|
1481 | os.unlink(f) | |
|
1488 | 1482 | except OSError: |
|
1489 | 1483 | pass |
|
1490 | 1484 |
General Comments 0
You need to be logged in to leave comments.
Login now