Patchwork D10839: rhg: propogate error coming from HgError::Abort to CommandError

login
register
mail settings
Submitter phabricator
Date June 7, 2021, 12:01 p.m.
Message ID <differential-rev-PHID-DREV-dki4atknnt3hlbx24fzn-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/49159/
State Superseded
Headers show

Comments

phabricator - June 7, 2021, 12:01 p.m.
pulkit 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/D10839

AFFECTED FILES
  rust/rhg/src/error.rs
  tests/test-globalopts.t

CHANGE DETAILS




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

Patch

diff --git a/tests/test-globalopts.t b/tests/test-globalopts.t
--- a/tests/test-globalopts.t
+++ b/tests/test-globalopts.t
@@ -220,7 +220,6 @@ 
   $ hg --cwd c --config paths.quuxfoo=bar paths | grep quuxfoo > /dev/null && echo quuxfoo
   quuxfoo
 TODO: add rhg support for detailed exit codes
-#if no-rhg
   $ hg --cwd c --config '' tip -q
   abort: malformed --config option: '' (use --config section.name=value)
   [10]
@@ -236,7 +235,6 @@ 
   $ hg --cwd c --config .b= tip -q
   abort: malformed --config option: '.b=' (use --config section.name=value)
   [10]
-#endif
 
 Testing --debug:
 
diff --git a/rust/rhg/src/error.rs b/rust/rhg/src/error.rs
--- a/rust/rhg/src/error.rs
+++ b/rust/rhg/src/error.rs
@@ -69,6 +69,9 @@ 
             HgError::UnsupportedFeature(message) => {
                 CommandError::unsupported(message)
             }
+            HgError::Abort(message, exit_code) => {
+                CommandError::abort_with_exit_code(message, exit_code)
+            }
             _ => CommandError::abort(error.to_string()),
         }
     }
@@ -125,7 +128,10 @@ 
     fn from(error: ConfigError) -> Self {
         match error {
             ConfigError::Parse(error) => error.into(),
-            ConfigError::Other(error) => error.into(),
+            ConfigError::Other(HgError::Abort(message, exit_code)) => {
+                CommandError::abort_with_exit_code(message, exit_code)
+            }
+            ConfigError::Other(_) => error.into(),
         }
     }
 }