##// END OF EJS Templates
rhg: support "status FILE"...
rhg: support "status FILE" This change adds a new [file] argument to rhg status, parses them as patterns, canonicalizes the paths, and constructs a new PatternMatcher to intersect with the existing matcher being passed to the status implementation. We also make filepatterns a public module so we can access the pattern-parsing functionality we need from commands/status.rs.

File last commit:

r50534:37bc3ede default
r51759:c112cc9e default
Show More
root.rs
28 lines | 862 B | application/rls-services+xml | RustLexer
Antoine Cezar
rhg: simplify `FindRootError` handling...
r45922 use crate::error::CommandError;
Raphaël Gomès
rhg: use `format_bytes!` for error messages...
r46598 use format_bytes::format_bytes;
Simon Sapin
rhg: Don’t make repository path absolute too early...
r47474 use hg::errors::{IoErrorContext, IoResultExt};
Antoine Cezar
rhg: add RootCommand using hg-core FindRoot operation to prepare `hg root`...
r45592 use hg::utils::files::get_bytes_from_path;
pub const HELP_TEXT: &str = "
Print the root directory of the current repository.
Returns 0 on success.
";
Raphaël Gomès
rhg: upgrade `clap` dependency...
r50534 pub fn args() -> clap::Command {
clap::command!("root").about(HELP_TEXT)
Simon Sapin
rhg: Move subcommand CLI arguments definitions to respective modules...
r47251 }
Simon Sapin
rhg: Group values passed to every sub-command into a struct...
r47334 pub fn run(invocation: &crate::CliInvocation) -> Result<(), CommandError> {
Simon Sapin
rhg: Move `Repo` object creation into `main()`...
r47335 let repo = invocation.repo?;
Simon Sapin
rhg: Don’t make repository path absolute too early...
r47474 let working_directory = repo.working_directory_path();
let working_directory = std::fs::canonicalize(working_directory)
.with_context(|| {
IoErrorContext::CanonicalizingPath(working_directory.to_owned())
})?;
let bytes = get_bytes_from_path(&working_directory);
Simon Sapin
rhg: Group values passed to every sub-command into a struct...
r47334 invocation
.ui
.write_stdout(&format_bytes!(b"{}\n", bytes.as_slice()))?;
Simon Sapin
rhg: replace command structs with functions...
r47250 Ok(())
Antoine Cezar
rhg: add RootCommand using hg-core FindRoot operation to prepare `hg root`...
r45592 }