# HG changeset patch # User Matt Mackall # Date 2015-05-15 14:58:21 # Node ID 754df8e932d3cb317f6804008344ce2dca5192e6 # Parent 559f24e3957d9bcdd9383aaa394e4f89681a1a5d util: use try/except/finally diff --git a/mercurial/util.py b/mercurial/util.py --- a/mercurial/util.py +++ b/mercurial/util.py @@ -1003,15 +1003,13 @@ def checknlink(testfile): 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()