Patchwork D10186: rhg: Add environment variables for fallback configuration

login
register
mail settings
Submitter phabricator
Date March 12, 2021, 10:06 p.m.
Message ID <differential-rev-PHID-DREV-p72oyvtllmr5tkbn3gy2-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/48501/
State Superseded
Headers show

Comments

phabricator - March 12, 2021, 10:06 p.m.
SimonSapin created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  For the `rust-tests.py --rhg` we want every `hg` command in tests
  to run `rhg` with fallback enabled, but other methods of setting
  configuration are limited or disruptive as discussed in code comment.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  rust/hg-core/src/config/config.rs

CHANGE DETAILS




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

Patch

diff --git a/rust/hg-core/src/config/config.rs b/rust/hg-core/src/config/config.rs
--- a/rust/hg-core/src/config/config.rs
+++ b/rust/hg-core/src/config/config.rs
@@ -78,9 +78,27 @@ 
         if opt_rc_path.is_none() {
             config.add_system_config()?
         }
+
         config.add_for_environment_variable("EDITOR", b"ui", b"editor");
         config.add_for_environment_variable("VISUAL", b"ui", b"editor");
         config.add_for_environment_variable("PAGER", b"pager", b"pager");
+
+        // These are set by `run-tests.py --rhg` to enable fallback for the
+        // entire test suite. Alternatives would be setting configuration
+        // through `$HGRCPATH` but some tests override that, or changing the
+        // `hg` shell alias to include `--config` but that disrupts tests that
+        // print command lines and check expected output.
+        config.add_for_environment_variable(
+            "RHG_ON_UNSUPPORTED",
+            b"rhg",
+            b"on-unsupported",
+        );
+        config.add_for_environment_variable(
+            "RHG_FALLBACK_EXECUTABLE",
+            b"rhg",
+            b"fallback-executable",
+        );
+
         // HGRCPATH replaces user config
         if opt_rc_path.is_none() {
             config.add_user_config()?