changeset 38602:af8d8513d7de

merge with stable
author Augie Fackler <augie@google.com>
date Mon, 09 Jul 2018 09:50:23 -0400
parents a936d1368fc5 (current diff) 3a0f322af192 (diff)
children 44f5acfb9ad2
files mercurial/windows.py
diffstat 2 files changed, 9 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/win32.py	Fri Jul 06 17:57:46 2018 +0200
+++ b/mercurial/win32.py	Mon Jul 09 09:50:23 2018 -0400
@@ -44,6 +44,7 @@
 _ERROR_INVALID_PARAMETER = 87
 _ERROR_BROKEN_PIPE = 109
 _ERROR_INSUFFICIENT_BUFFER = 122
+_ERROR_NO_DATA = 232
 
 # WPARAM is defined as UINT_PTR (unsigned type)
 # LPARAM is defined as LONG_PTR (signed type)
@@ -406,6 +407,12 @@
 
     return avail.value
 
+def lasterrorwaspipeerror(err):
+    if err.errno != errno.EINVAL:
+        return False
+    err = _kernel32.GetLastError()
+    return err == _ERROR_BROKEN_PIPE or err == _ERROR_NO_DATA
+
 def testpid(pid):
     '''return True if pid is still running or unable to
     determine, False otherwise'''
--- a/mercurial/windows.py	Fri Jul 06 17:57:46 2018 +0200
+++ b/mercurial/windows.py	Mon Jul 09 09:50:23 2018 -0400
@@ -173,7 +173,7 @@
                 self.fp.write(s[start:end])
                 start = end
         except IOError as inst:
-            if inst.errno != 0:
+            if inst.errno != 0 and not win32.lasterrorwaspipeerror(inst):
                 raise
             self.close()
             raise IOError(errno.EPIPE, 'Broken pipe')
@@ -182,7 +182,7 @@
         try:
             return self.fp.flush()
         except IOError as inst:
-            if inst.errno != errno.EINVAL:
+            if not win32.lasterrorwaspipeerror(inst):
                 raise
             raise IOError(errno.EPIPE, 'Broken pipe')