Mercurial > hg
view rust/rhg/src/commands/root.rs @ 52038:b7d99348ea36
rust-files: also return filenode and flags when listing a revision's files
This is going to be useful when implementing parts of `update` and makes it
so we don't have to fetch the manifest and each entry twice.
author | Raphaël Gomès <rgomes@octobus.net> |
---|---|
date | Mon, 30 Sep 2024 12:10:35 +0200 |
parents | 532e74ad3ff6 |
children |
line wrap: on
line source
use crate::error::CommandError; use format_bytes::format_bytes; use hg::errors::{IoErrorContext, IoResultExt}; 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. "; pub fn args() -> clap::Command { clap::command!("root").about(HELP_TEXT) } pub fn run(invocation: &crate::CliInvocation) -> Result<(), CommandError> { let repo = invocation.repo?; 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); invocation .ui .write_stdout(&format_bytes!(b"{}\n", bytes.as_slice()))?; Ok(()) }