# HG changeset patch # User Simon Sapin # Date 2021-03-08 18:25:33 # Node ID 63bfcddddac1d6f361ca012e31a6005793c714c6 # Parent b1f2c2b336ec792d3e7eff18e059e9c850ddca03 rhg: Exit with an error code if `files` finds nothing This matches the behavior of Python-based hg. Differential Revision: https://phab.mercurial-scm.org/D10143 diff --git a/rust/rhg/src/commands/files.rs b/rust/rhg/src/commands/files.rs --- a/rust/rhg/src/commands/files.rs +++ b/rust/rhg/src/commands/files.rs @@ -61,11 +61,17 @@ fn display_files<'a>( let mut stdout = ui.stdout_buffer(); + let mut any = false; for file in files { + any = true; let file = working_directory.join(file); stdout.write_all(relativize_path(&file, &cwd).as_ref())?; stdout.write_all(b"\n")?; } stdout.flush()?; - Ok(()) + if any { + Ok(()) + } else { + Err(CommandError::Unsuccessful) + } }