[Commented On] D10912: rhg: add ui.plain() and check it before showing relative paths in status

baymax (Baymax, Your Personal Patch-care Companion) phabricator at mercurial-scm.org
Fri Jun 25 11:59:16 UTC 2021


baymax added a comment.
baymax updated this revision to Diff 28698.


  ✅ refresh by Heptapod after a successful CI run (🐙 💚)

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D10912?vs=28697&id=28698

BRANCH
  default

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D10912/new/

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

AFFECTED FILES
  rust/rhg/src/commands/status.rs
  rust/rhg/src/ui.rs

CHANGE DETAILS

diff --git a/rust/rhg/src/ui.rs b/rust/rhg/src/ui.rs
--- a/rust/rhg/src/ui.rs
+++ b/rust/rhg/src/ui.rs
@@ -1,5 +1,6 @@
 use format_bytes::format_bytes;
 use std::borrow::Cow;
+use std::env;
 use std::io;
 use std::io::{ErrorKind, Write};
 
@@ -49,6 +50,25 @@
 
         stderr.flush().or_else(handle_stderr_error)
     }
+
+    /// is plain mode active
+    ///
+    /// Plain mode means that all configuration variables which affect
+    /// the behavior and output of Mercurial should be
+    /// ignored. Additionally, the output should be stable,
+    /// reproducible and suitable for use in scripts or applications.
+    ///
+    /// The only way to trigger plain mode is by setting either the
+    /// `HGPLAIN' or `HGPLAINEXCEPT' environment variables.
+    ///
+    /// The return value can either be
+    /// - False if HGPLAIN is not set, or feature is in HGPLAINEXCEPT
+    /// - False if feature is disabled by default and not included in HGPLAIN
+    /// - True otherwise
+    pub fn plain(&self) -> bool {
+        // TODO: add support for HGPLAINEXCEPT
+        env::var_os("HGPLAIN").is_some()
+    }
 }
 
 /// A buffered stdout writer for faster batch printing operations.
diff --git a/rust/rhg/src/commands/status.rs b/rust/rhg/src/commands/status.rs
--- a/rust/rhg/src/commands/status.rs
+++ b/rust/rhg/src/commands/status.rs
@@ -290,7 +290,7 @@
     relative = config
         .get_bool(b"commands", b"status.relative")
         .unwrap_or(relative);
-    if relative {
+    if relative && !ui.plain() {
         let cwd = current_dir()?;
         let working_directory = repo.working_directory_path();
         let working_directory = cwd.join(working_directory); // Make it absolute



To: pulkit, #hg-reviewers
Cc: SimonSapin, mercurial-patches
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurial-scm.org/pipermail/mercurial-patches/attachments/20210625/edc6715a/attachment-0002.html>


More information about the Mercurial-patches mailing list