Patchwork D10143: rhg: Exit with an error code if `files` finds nothing

login
register
mail settings
Submitter phabricator
Date March 9, 2021, 9:42 a.m.
Message ID <differential-rev-PHID-DREV-kkjcygmzxp7gwvqddosb-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/48456/
State Superseded
Headers show

Comments

phabricator - March 9, 2021, 9:42 a.m.
SimonSapin created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  rust/rhg/src/commands/files.rs

CHANGE DETAILS




To: SimonSapin, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

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
@@ -59,11 +59,17 @@ 
 
     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)
+    }
 }