[PATCH 5 of 8] rust-hglib: abstract away from ExitStatus
Yuya Nishihara
yuya at tcha.org
Sun Apr 1 07:14:21 EDT 2018
# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1522484358 -32400
# Sat Mar 31 17:19:18 2018 +0900
# Node ID 6edafeebb3c1440a23bb84f24efa0ff24161890d
# Parent a3c01fe6cf0a036859f76d8c222c4ca9aa32116c
rust-hglib: abstract away from ExitStatus
Prepares for adding a connector for UNIX domain server.
diff --git a/rust/hglib/src/connection.rs b/rust/hglib/src/connection.rs
--- a/rust/hglib/src/connection.rs
+++ b/rust/hglib/src/connection.rs
@@ -22,7 +22,7 @@ use std::error::Error;
use std::fmt::{self, Display};
use std::io;
use std::io::prelude::*;
-use std::process::{Command, Stdio, Child, ChildStdin, ChildStdout, ExitStatus};
+use std::process::{Command, Stdio, Child, ChildStdin, ChildStdout};
use std::str;
use byteorder::{BigEndian, ReadBytesExt, WriteBytesExt};
@@ -151,10 +151,17 @@ impl PipeBackend {
self.child.stdin.as_mut().unwrap()
}
- fn close(&mut self) -> io::Result<ExitStatus> {
+ fn close(&mut self) -> io::Result<()> {
// This will close the command server's stdin, which signals
- // that it should exit. Returns the command server's exit code.
- self.child.wait()
+ // that it should exit.
+ let st = try!(self.child.wait());
+ if st.success() {
+ Ok(())
+ } else {
+ // TODO: add dedicated error type?
+ return Err(io::Error::new(io::ErrorKind::Other,
+ format!("server exited with error: {}", st)))
+ }
}
}
@@ -278,7 +285,7 @@ impl Connection {
}
/// Shuts down the command server process.
- pub fn close(&mut self) -> io::Result<ExitStatus> {
+ pub fn close(&mut self) -> io::Result<()> {
self.backend.close()
}
}
More information about the Mercurial-devel
mailing list