Patchwork [1,of,6] rust-chg: suppress panic while writing chg error to stderr

login
register
mail settings
Submitter Yuya Nishihara
Date Oct. 14, 2018, 8:18 a.m.
Message ID <4a4f95df41de64fb472c.1539505098@mimosa>
Download mbox | patch
Permalink /patch/35954/
State Accepted
Headers show

Comments

Yuya Nishihara - Oct. 14, 2018, 8:18 a.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1538913351 -32400
#      Sun Oct 07 20:55:51 2018 +0900
# Node ID 4a4f95df41de64fb472cb131d5ff4eeb8e846870
# Parent  3b275f5497771d8a71336273a77575dbf4882798
rust-chg: suppress panic while writing chg error to stderr

Otherwise "chg >/dev/full 2>&1" would exit with 101. Spotted by test-basic.t.
Gregory Szorc - Oct. 14, 2018, 11:47 a.m.
On Sun, Oct 14, 2018 at 10:24 AM Yuya Nishihara <yuya@tcha.org> wrote:

> # HG changeset patch
> # User Yuya Nishihara <yuya@tcha.org>
> # Date 1538913351 -32400
> #      Sun Oct 07 20:55:51 2018 +0900
> # Node ID 4a4f95df41de64fb472cb131d5ff4eeb8e846870
> # Parent  3b275f5497771d8a71336273a77575dbf4882798
> rust-chg: suppress panic while writing chg error to stderr
>

Queued parts 1-4. Didn't review parts 5 and 6 because I want to pay
attention to something IRL.


>
> Otherwise "chg >/dev/full 2>&1" would exit with 101. Spotted by
> test-basic.t.
>
> diff --git a/rust/chg/src/main.rs b/rust/chg/src/main.rs
> --- a/rust/chg/src/main.rs
> +++ b/rust/chg/src/main.rs
> @@ -20,7 +20,7 @@ use tokio_hglib::UnixClient;
>
>  fn main() {
>      let code = run().unwrap_or_else(|err| {
> -        eprintln!("chg: abort: {}", err);
> +        writeln!(io::stderr(), "chg: abort: {}", err).unwrap_or(());
>          255
>      });
>      process::exit(code);
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
>

Patch

diff --git a/rust/chg/src/main.rs b/rust/chg/src/main.rs
--- a/rust/chg/src/main.rs
+++ b/rust/chg/src/main.rs
@@ -20,7 +20,7 @@  use tokio_hglib::UnixClient;
 
 fn main() {
     let code = run().unwrap_or_else(|err| {
-        eprintln!("chg: abort: {}", err);
+        writeln!(io::stderr(), "chg: abort: {}", err).unwrap_or(());
         255
     });
     process::exit(code);