Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/util.py @ 13342:2dc7a2a96cfd
opener: use posixfile to hold file open when calling nlinks()
Mercurial's posixfile is less intrusive on Windows than Python's open
author | Adrian Buehlmann <adrian@cadifra.com> |
---|---|
date | Wed, 02 Feb 2011 13:51:22 +0100 |
parents | d119403fd266 |
children | f1fa8f481c7c |
comparison
equal
deleted
inserted
replaced
13341:4e33ef68b1f8 | 13342:2dc7a2a96cfd |
---|---|
740 except OSError: | 740 except OSError: |
741 return False | 741 return False |
742 | 742 |
743 # nlinks() may behave differently for files on Windows shares if | 743 # nlinks() may behave differently for files on Windows shares if |
744 # the file is open. | 744 # the file is open. |
745 fd = open(f2) | 745 fd = posixfile(f2) |
746 return nlinks(f2) > 1 | 746 return nlinks(f2) > 1 |
747 finally: | 747 finally: |
748 if fd is not None: | 748 if fd is not None: |
749 fd.close() | 749 fd.close() |
750 for f in (f1, f2): | 750 for f in (f1, f2): |
914 unlink(f) | 914 unlink(f) |
915 nlink = 0 | 915 nlink = 0 |
916 else: | 916 else: |
917 # nlinks() may behave differently for files on Windows | 917 # nlinks() may behave differently for files on Windows |
918 # shares if the file is open. | 918 # shares if the file is open. |
919 fd = open(f) | 919 fd = posixfile(f) |
920 nlink = nlinks(f) | 920 nlink = nlinks(f) |
921 if nlink < 1: | 921 if nlink < 1: |
922 nlink = 2 # force mktempcopy (issue1922) | 922 nlink = 2 # force mktempcopy (issue1922) |
923 fd.close() | 923 fd.close() |
924 except (OSError, IOError), e: | 924 except (OSError, IOError), e: |