changeset 2025:581d9a8b5fb9

clean up lee's windows testpid fix.
author Vadim Gelfer <vadim.gelfer@gmail.com>
date Thu, 30 Mar 2006 18:27:04 -0800
parents 6328445b0e71
children 24c604628867
files mercurial/util.py
diffstat 1 files changed, 7 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/util.py	Thu Mar 30 18:20:08 2006 -0800
+++ b/mercurial/util.py	Thu Mar 30 18:27:04 2006 -0800
@@ -536,7 +536,7 @@
         return pf
 
     try: # Mark Hammond's win32all package allows better functionality on Windows
-        import win32api, win32con, win32file, pywintypes
+        import win32api, win32con, win32file, winerror, pywintypes
 
         # create hard links using win32file module
         def os_link(src, dst): # NB will only succeed on NTFS
@@ -555,18 +555,16 @@
                 return os.stat(pathname).st_nlink
 
         def testpid(pid):
-            '''return True if pid is still running or unable to determine, False otherwise'''
+            '''return True if pid is still running or unable to
+            determine, False otherwise'''
             try:
-                handle = win32api.OpenProcess(win32con.PROCESS_QUERY_INFORMATION, False, pid) 
+                handle = win32api.OpenProcess(
+                    win32con.PROCESS_QUERY_INFORMATION, False, pid)
                 if handle:
                     status = win32process.GetExitCodeProcess(handle)
-                    if status == win32con.STILL_ACTIVE:
-                        return True
-                    else:
-                        return False
+                    return status == win32con.STILL_ACTIVE
             except pywintypes.error, details:
-                if details[0] == 87: # ERROR_INVALID_PARAMETER
-                    return False
+                return details[0] != winerror.ERROR_INVALID_PARAMETER
             return True
 
     except ImportError: