Mercurial > public > mercurial-scm > hg
comparison mercurial/util.py @ 25088:754df8e932d3
util: use try/except/finally
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Fri, 15 May 2015 09:58:21 -0500 |
parents | 986a5c23b1c1 |
children | 3d14c1217117 |
comparison
equal
deleted
inserted
replaced
25087:559f24e3957d | 25088:754df8e932d3 |
---|---|
1001 return False | 1001 return False |
1002 | 1002 |
1003 f2 = testfile + ".hgtmp2" | 1003 f2 = testfile + ".hgtmp2" |
1004 fd = None | 1004 fd = None |
1005 try: | 1005 try: |
1006 try: | 1006 oslink(f1, f2) |
1007 oslink(f1, f2) | |
1008 except OSError: | |
1009 return False | |
1010 | |
1011 # nlinks() may behave differently for files on Windows shares if | 1007 # nlinks() may behave differently for files on Windows shares if |
1012 # the file is open. | 1008 # the file is open. |
1013 fd = posixfile(f2) | 1009 fd = posixfile(f2) |
1014 return nlinks(f2) > 1 | 1010 return nlinks(f2) > 1 |
1011 except OSError: | |
1012 return False | |
1015 finally: | 1013 finally: |
1016 if fd is not None: | 1014 if fd is not None: |
1017 fd.close() | 1015 fd.close() |
1018 for f in (f1, f2): | 1016 for f in (f1, f2): |
1019 try: | 1017 try: |