[Updated] D8871: rhg: handle broken pipe error for stderr

acezar (Antoine Cezar) phabricator at mercurial-scm.org
Sat Aug 8 20:32:24 UTC 2020


Closed by commit rHG53af26aa5951: rhg: handle broken pipe error for stderr (authored by acezar).
This revision was automatically updated to reflect the committed changes.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D8871?vs=22254&id=22366

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D8871/new/

REVISION DETAIL
  https://phab.mercurial-scm.org/D8871

AFFECTED FILES
  rust/rhg/src/ui.rs

CHANGE DETAILS

diff --git a/rust/rhg/src/ui.rs b/rust/rhg/src/ui.rs
--- a/rust/rhg/src/ui.rs
+++ b/rust/rhg/src/ui.rs
@@ -49,7 +49,7 @@
             .write_all(bytes)
             .or_else(|e| handle_stderr_error(e))?;
 
-        stderr.flush().or_else(|e| Err(UiError::StderrError(e)))
+        stderr.flush().or_else(|e| handle_stderr_error(e))
     }
 }
 
@@ -94,3 +94,13 @@
 
     Err(UiError::StdoutError(error))
 }
+
+/// Sometimes writing to stderr is not possible.
+fn handle_stderr_error(error: io::Error) -> Result<(), UiError> {
+    // A broken pipe should not result in a error
+    // like with `| head` for example
+    if let ErrorKind::BrokenPipe = error.kind() {
+        return Ok(());
+    }
+    Err(UiError::StdoutError(error))
+}



To: acezar, #hg-reviewers, Alphare, indygreg
Cc: mercurial-patches
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurial-scm.org/pipermail/mercurial-patches/attachments/20200808/43dc2cf4/attachment-0002.html>


More information about the Mercurial-patches mailing list