##// END OF EJS Templates
util: use try/except/finally
Matt Mackall -
r25088:754df8e9 default
parent child Browse files
Show More
@@ -1003,15 +1003,13 b' def checknlink(testfile):'
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()
General Comments 0
You need to be logged in to leave comments. Login now