Patchwork D11723: rhg: make it possible to opt out of [rhg cat]

login
register
mail settings
Submitter phabricator
Date Oct. 27, 2021, 6:38 p.m.
Message ID <differential-rev-PHID-DREV-agrdumzn35tk2gkxald3-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/50048/
State Superseded
Headers show

Comments

phabricator - Oct. 27, 2021, 6:38 p.m.
aalekseyev created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REPOSITORY
  rHG Mercurial

BRANCH
  stable

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

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

CHANGE DETAILS




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

Patch

diff --git a/rust/rhg/src/commands/cat.rs b/rust/rhg/src/commands/cat.rs
--- a/rust/rhg/src/commands/cat.rs
+++ b/rust/rhg/src/commands/cat.rs
@@ -33,6 +33,15 @@ 
 
 #[timed]
 pub fn run(invocation: &crate::CliInvocation) -> Result<(), CommandError> {
+    let cat_enabled_default = true;
+    let cat_enabled = invocation.config.get_option(b"rhg", b"cat")?;
+    if !cat_enabled.unwrap_or(cat_enabled_default) {
+        return Err(CommandError::unsupported(
+            "cat is disabled in rhg (enable it with 'rhg.cat = true' \
+            or enable fallback with 'rhg.on-unsupported = fallback')",
+        ));
+    }
+
     let rev = invocation.subcommand_args.value_of("rev");
     let file_args = match invocation.subcommand_args.values_of("files") {
         Some(files) => files.collect(),