mercurial/win32.py
branchstable
changeset 11992 ccd8e592c3c5
parent 11991 50523b4407f6
child 12387 4f8067c94729
--- a/mercurial/win32.py	Thu Aug 19 22:51:09 2010 +0200
+++ b/mercurial/win32.py	Thu Aug 19 22:51:09 2010 +0200
@@ -34,20 +34,16 @@
         fh = win32file.CreateFile(pathname,
             win32file.GENERIC_READ, win32file.FILE_SHARE_READ,
             None, win32file.OPEN_EXISTING, 0, None)
-        try:
-            return win32file.GetFileInformationByHandle(fh)
-        finally:
-            fh.Close()
     except pywintypes.error:
-        return None
+        raise OSError(errno.ENOENT, 'The system cannot find the file specified')
+    try:
+        return win32file.GetFileInformationByHandle(fh)
+    finally:
+        fh.Close()
 
 def nlinks(pathname):
     """Return number of hardlinks for the given file."""
-    res = _getfileinfo(pathname)
-    if res is not None:
-        links = res[7]
-    else:
-        links = os.lstat(pathname).st_nlink
+    links = _getfileinfo(pathname)[7]
     if links < 2:
         # Known to be wrong for most network drives
         dirname = os.path.dirname(pathname)
@@ -64,21 +60,15 @@
     guaranteed to work for files, not directories."""
     res1 = _getfileinfo(fpath1)
     res2 = _getfileinfo(fpath2)
-    if res1 is not None and res2 is not None:
-        # Index 4 is the volume serial number, and 8 and 9 contain the file ID
-        return res1[4] == res2[4] and res1[8] == res2[8] and res1[9] == res2[9]
-    else:
-        return False
+    # Index 4 is the volume serial number, and 8 and 9 contain the file ID
+    return res1[4] == res2[4] and res1[8] == res2[8] and res1[9] == res2[9]
 
 def samedevice(fpath1, fpath2):
     """Returns whether fpath1 and fpath2 are on the same device. This is only
     guaranteed to work for files, not directories."""
     res1 = _getfileinfo(fpath1)
     res2 = _getfileinfo(fpath2)
-    if res1 is not None and res2 is not None:
-        return res1[4] == res2[4]
-    else:
-        return False
+    return res1[4] == res2[4]
 
 def testpid(pid):
     '''return True if pid is still running or unable to