util: use try/except/finally
authorMatt Mackall <mpm@selenic.com>
Fri, 15 May 2015 09:58:21 -0500
changeset 25088 754df8e932d3
parent 25087 559f24e3957d
child 25089 c6427cd45760
util: use try/except/finally
mercurial/util.py
--- a/mercurial/util.py	Fri May 15 09:58:02 2015 -0500
+++ b/mercurial/util.py	Fri May 15 09:58:21 2015 -0500
@@ -1003,15 +1003,13 @@
     f2 = testfile + ".hgtmp2"
     fd = None
     try:
-        try:
-            oslink(f1, f2)
-        except OSError:
-            return False
-
+        oslink(f1, f2)
         # nlinks() may behave differently for files on Windows shares if
         # the file is open.
         fd = posixfile(f2)
         return nlinks(f2) > 1
+    except OSError:
+        return False
     finally:
         if fd is not None:
             fd.close()