Comments
Patch
@@ -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,28 @@
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
+ match env::var("HGPLAIN") {
+ Ok(_) => true,
+ Err(_) => false,
+ }
+ }
}
/// A buffered stdout writer for faster batch printing operations.
@@ -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