Details
Details
Diff Detail
Diff Detail
- Repository
- rHG Mercurial
- Branch
- default
- Lint
No Linters Available - Unit
No Unit Test Coverage
| No Linters Available |
| No Unit Test Coverage |
| Path | Packages | |||
|---|---|---|---|---|
| M | rust/rhg/src/commands/cat.rs (22 lines) | |||
| M | rust/rhg/src/commands/debugdata.rs (30 lines) | |||
| M | rust/rhg/src/commands/debugrequirements.rs (4 lines) | |||
| M | rust/rhg/src/commands/files.rs (14 lines) | |||
| M | rust/rhg/src/commands/root.rs (4 lines) | |||
| M | rust/rhg/src/main.rs (74 lines) |
| Commit | Parents | Author | Summary | Date |
|---|---|---|---|---|
| 72c68a65f224 | 9c4cec20317c | Simon Sapin | Feb 8 2021, 3:05 PM |
| Status | Author | Revision | |
|---|---|---|---|
| Closed | SimonSapin | ||
| Closed | SimonSapin | ||
| Closed | SimonSapin | ||
| Closed | SimonSapin | ||
| Closed | SimonSapin | ||
| Closed | SimonSapin | ||
| Closed | SimonSapin | ||
| Closed | SimonSapin | ||
| Closed | SimonSapin | ||
| Closed | SimonSapin | ||
| Closed | SimonSapin | ||
| Closed | SimonSapin | ||
| Closed | SimonSapin |
| use crate::error::CommandError; | use crate::error::CommandError; | ||||
| use crate::ui::Ui; | use crate::ui::Ui; | ||||
| use clap::Arg; | |||||
| use clap::ArgMatches; | use clap::ArgMatches; | ||||
| use hg::config::Config; | use hg::config::Config; | ||||
| use hg::operations::cat; | use hg::operations::cat; | ||||
| use hg::repo::Repo; | use hg::repo::Repo; | ||||
| use hg::utils::hg_path::HgPathBuf; | use hg::utils::hg_path::HgPathBuf; | ||||
| use micro_timer::timed; | use micro_timer::timed; | ||||
| use std::convert::TryFrom; | use std::convert::TryFrom; | ||||
| pub const HELP_TEXT: &str = " | pub const HELP_TEXT: &str = " | ||||
| Output the current or given revision of files | Output the current or given revision of files | ||||
| "; | "; | ||||
| pub fn args() -> clap::App<'static, 'static> { | |||||
| clap::SubCommand::with_name("cat") | |||||
| .arg( | |||||
| Arg::with_name("rev") | |||||
| .help("search the repository as it is in REV") | |||||
| .short("-r") | |||||
| .long("--revision") | |||||
| .value_name("REV") | |||||
| .takes_value(true), | |||||
| ) | |||||
| .arg( | |||||
| clap::Arg::with_name("files") | |||||
| .required(true) | |||||
| .multiple(true) | |||||
| .empty_values(false) | |||||
| .value_name("FILE") | |||||
| .help("Activity to start: activity@category"), | |||||
| ) | |||||
| .about(HELP_TEXT) | |||||
| } | |||||
| #[timed] | #[timed] | ||||
| pub fn run( | pub fn run( | ||||
| ui: &Ui, | ui: &Ui, | ||||
| config: &Config, | config: &Config, | ||||
| args: &ArgMatches, | args: &ArgMatches, | ||||
| ) -> Result<(), CommandError> { | ) -> Result<(), CommandError> { | ||||
| let rev = args.value_of("rev"); | let rev = args.value_of("rev"); | ||||
| let file_args = match args.values_of("files") { | let file_args = match args.values_of("files") { | ||||
| use crate::error::CommandError; | use crate::error::CommandError; | ||||
| use crate::ui::Ui; | use crate::ui::Ui; | ||||
| use clap::Arg; | |||||
| use clap::ArgGroup; | |||||
| use clap::ArgMatches; | use clap::ArgMatches; | ||||
| use hg::config::Config; | use hg::config::Config; | ||||
| use hg::operations::{debug_data, DebugDataKind}; | use hg::operations::{debug_data, DebugDataKind}; | ||||
| use hg::repo::Repo; | use hg::repo::Repo; | ||||
| use micro_timer::timed; | use micro_timer::timed; | ||||
| pub const HELP_TEXT: &str = " | pub const HELP_TEXT: &str = " | ||||
| Dump the contents of a data file revision | Dump the contents of a data file revision | ||||
| "; | "; | ||||
| pub fn args() -> clap::App<'static, 'static> { | |||||
| clap::SubCommand::with_name("debugdata") | |||||
| .arg( | |||||
| Arg::with_name("changelog") | |||||
| .help("open changelog") | |||||
| .short("-c") | |||||
| .long("--changelog"), | |||||
| ) | |||||
| .arg( | |||||
| Arg::with_name("manifest") | |||||
| .help("open manifest") | |||||
| .short("-m") | |||||
| .long("--manifest"), | |||||
| ) | |||||
| .group( | |||||
| ArgGroup::with_name("") | |||||
| .args(&["changelog", "manifest"]) | |||||
| .required(true), | |||||
| ) | |||||
| .arg( | |||||
| Arg::with_name("rev") | |||||
| .help("revision") | |||||
| .required(true) | |||||
| .value_name("REV"), | |||||
| ) | |||||
| .about(HELP_TEXT) | |||||
| } | |||||
| #[timed] | #[timed] | ||||
| pub fn run( | pub fn run( | ||||
| ui: &Ui, | ui: &Ui, | ||||
| config: &Config, | config: &Config, | ||||
| args: &ArgMatches, | args: &ArgMatches, | ||||
| ) -> Result<(), CommandError> { | ) -> Result<(), CommandError> { | ||||
| let rev = args | let rev = args | ||||
| .value_of("rev") | .value_of("rev") | ||||
| use crate::error::CommandError; | use crate::error::CommandError; | ||||
| use crate::ui::Ui; | use crate::ui::Ui; | ||||
| use clap::ArgMatches; | use clap::ArgMatches; | ||||
| use hg::config::Config; | use hg::config::Config; | ||||
| use hg::repo::Repo; | use hg::repo::Repo; | ||||
| pub const HELP_TEXT: &str = " | pub const HELP_TEXT: &str = " | ||||
| Print the current repo requirements. | Print the current repo requirements. | ||||
| "; | "; | ||||
| pub fn args() -> clap::App<'static, 'static> { | |||||
| clap::SubCommand::with_name("debugrequirements").about(HELP_TEXT) | |||||
| } | |||||
| pub fn run( | pub fn run( | ||||
| ui: &Ui, | ui: &Ui, | ||||
| config: &Config, | config: &Config, | ||||
| _args: &ArgMatches, | _args: &ArgMatches, | ||||
| ) -> Result<(), CommandError> { | ) -> Result<(), CommandError> { | ||||
| let repo = Repo::find(config)?; | let repo = Repo::find(config)?; | ||||
| let mut output = String::new(); | let mut output = String::new(); | ||||
| let mut requirements: Vec<_> = repo.requirements().iter().collect(); | let mut requirements: Vec<_> = repo.requirements().iter().collect(); | ||||
| requirements.sort(); | requirements.sort(); | ||||
| for req in requirements { | for req in requirements { | ||||
| output.push_str(req); | output.push_str(req); | ||||
| output.push('\n'); | output.push('\n'); | ||||
| } | } | ||||
| ui.write_stdout(output.as_bytes())?; | ui.write_stdout(output.as_bytes())?; | ||||
| Ok(()) | Ok(()) | ||||
| } | } | ||||
| use crate::error::CommandError; | use crate::error::CommandError; | ||||
| use crate::ui::Ui; | use crate::ui::Ui; | ||||
| use clap::Arg; | |||||
| use clap::ArgMatches; | use clap::ArgMatches; | ||||
| use hg::config::Config; | use hg::config::Config; | ||||
| use hg::operations::list_rev_tracked_files; | use hg::operations::list_rev_tracked_files; | ||||
| use hg::operations::Dirstate; | use hg::operations::Dirstate; | ||||
| use hg::repo::Repo; | use hg::repo::Repo; | ||||
| use hg::utils::files::{get_bytes_from_path, relativize_path}; | use hg::utils::files::{get_bytes_from_path, relativize_path}; | ||||
| use hg::utils::hg_path::{HgPath, HgPathBuf}; | use hg::utils::hg_path::{HgPath, HgPathBuf}; | ||||
| pub const HELP_TEXT: &str = " | pub const HELP_TEXT: &str = " | ||||
| List tracked files. | List tracked files. | ||||
| Returns 0 on success. | Returns 0 on success. | ||||
| "; | "; | ||||
| pub fn args() -> clap::App<'static, 'static> { | |||||
| clap::SubCommand::with_name("files") | |||||
| .arg( | |||||
| Arg::with_name("rev") | |||||
| .help("search the repository as it is in REV") | |||||
| .short("-r") | |||||
| .long("--revision") | |||||
| .value_name("REV") | |||||
| .takes_value(true), | |||||
| ) | |||||
| .about(HELP_TEXT) | |||||
| } | |||||
| pub fn run( | pub fn run( | ||||
| ui: &Ui, | ui: &Ui, | ||||
| config: &Config, | config: &Config, | ||||
| args: &ArgMatches, | args: &ArgMatches, | ||||
| ) -> Result<(), CommandError> { | ) -> Result<(), CommandError> { | ||||
| let rev = args.value_of("rev"); | let rev = args.value_of("rev"); | ||||
| let repo = Repo::find(config)?; | let repo = Repo::find(config)?; | ||||
| use crate::error::CommandError; | use crate::error::CommandError; | ||||
| use crate::ui::Ui; | use crate::ui::Ui; | ||||
| use clap::ArgMatches; | use clap::ArgMatches; | ||||
| use format_bytes::format_bytes; | use format_bytes::format_bytes; | ||||
| use hg::config::Config; | use hg::config::Config; | ||||
| use hg::repo::Repo; | use hg::repo::Repo; | ||||
| use hg::utils::files::get_bytes_from_path; | use hg::utils::files::get_bytes_from_path; | ||||
| pub const HELP_TEXT: &str = " | pub const HELP_TEXT: &str = " | ||||
| Print the root directory of the current repository. | Print the root directory of the current repository. | ||||
| Returns 0 on success. | Returns 0 on success. | ||||
| "; | "; | ||||
| pub fn args() -> clap::App<'static, 'static> { | |||||
| clap::SubCommand::with_name("root").about(HELP_TEXT) | |||||
| } | |||||
| pub fn run( | pub fn run( | ||||
| ui: &Ui, | ui: &Ui, | ||||
| config: &Config, | config: &Config, | ||||
| _args: &ArgMatches, | _args: &ArgMatches, | ||||
| ) -> Result<(), CommandError> { | ) -> Result<(), CommandError> { | ||||
| let repo = Repo::find(config)?; | let repo = Repo::find(config)?; | ||||
| let bytes = get_bytes_from_path(repo.working_directory_path()); | let bytes = get_bytes_from_path(repo.working_directory_path()); | ||||
| ui.write_stdout(&format_bytes!(b"{}\n", bytes.as_slice()))?; | ui.write_stdout(&format_bytes!(b"{}\n", bytes.as_slice()))?; | ||||
| Ok(()) | Ok(()) | ||||
| } | } | ||||
| extern crate log; | extern crate log; | ||||
| use clap::App; | use clap::App; | ||||
| use clap::AppSettings; | use clap::AppSettings; | ||||
| use clap::Arg; | |||||
| use clap::ArgGroup; | |||||
| use clap::ArgMatches; | use clap::ArgMatches; | ||||
| use clap::SubCommand; | |||||
| use format_bytes::format_bytes; | use format_bytes::format_bytes; | ||||
| mod commands; | mod commands; | ||||
| mod error; | mod error; | ||||
| mod exitcode; | mod exitcode; | ||||
| mod ui; | mod ui; | ||||
| use error::CommandError; | use error::CommandError; | ||||
| fn main() { | fn main() { | ||||
| env_logger::init(); | env_logger::init(); | ||||
| let app = App::new("rhg") | let app = App::new("rhg") | ||||
| .setting(AppSettings::AllowInvalidUtf8) | .setting(AppSettings::AllowInvalidUtf8) | ||||
| .setting(AppSettings::SubcommandRequired) | .setting(AppSettings::SubcommandRequired) | ||||
| .setting(AppSettings::VersionlessSubcommands) | .setting(AppSettings::VersionlessSubcommands) | ||||
| .version("0.0.1") | .version("0.0.1") | ||||
| .subcommand( | .subcommand(commands::root::args()) | ||||
| SubCommand::with_name("root").about(commands::root::HELP_TEXT), | .subcommand(commands::files::args()) | ||||
| ) | .subcommand(commands::cat::args()) | ||||
| .subcommand( | .subcommand(commands::debugdata::args()) | ||||
| SubCommand::with_name("files") | .subcommand(commands::debugrequirements::args()); | ||||
| .arg( | |||||
| Arg::with_name("rev") | |||||
| .help("search the repository as it is in REV") | |||||
| .short("-r") | |||||
| .long("--revision") | |||||
| .value_name("REV") | |||||
| .takes_value(true), | |||||
| ) | |||||
| .about(commands::files::HELP_TEXT), | |||||
| ) | |||||
| .subcommand( | |||||
| SubCommand::with_name("cat") | |||||
| .arg( | |||||
| Arg::with_name("rev") | |||||
| .help("search the repository as it is in REV") | |||||
| .short("-r") | |||||
| .long("--revision") | |||||
| .value_name("REV") | |||||
| .takes_value(true), | |||||
| ) | |||||
| .arg( | |||||
| clap::Arg::with_name("files") | |||||
| .required(true) | |||||
| .multiple(true) | |||||
| .empty_values(false) | |||||
| .value_name("FILE") | |||||
| .help("Activity to start: activity@category"), | |||||
| ) | |||||
| .about(commands::cat::HELP_TEXT), | |||||
| ) | |||||
| .subcommand( | |||||
| SubCommand::with_name("debugdata") | |||||
| .about(commands::debugdata::HELP_TEXT) | |||||
| .arg( | |||||
| Arg::with_name("changelog") | |||||
| .help("open changelog") | |||||
| .short("-c") | |||||
| .long("--changelog"), | |||||
| ) | |||||
| .arg( | |||||
| Arg::with_name("manifest") | |||||
| .help("open manifest") | |||||
| .short("-m") | |||||
| .long("--manifest"), | |||||
| ) | |||||
| .group( | |||||
| ArgGroup::with_name("") | |||||
| .args(&["changelog", "manifest"]) | |||||
| .required(true), | |||||
| ) | |||||
| .arg( | |||||
| Arg::with_name("rev") | |||||
| .help("revision") | |||||
| .required(true) | |||||
| .value_name("REV"), | |||||
| ), | |||||
| ) | |||||
| .subcommand( | |||||
| SubCommand::with_name("debugrequirements") | |||||
| .about(commands::debugrequirements::HELP_TEXT), | |||||
| ); | |||||
| let matches = app.clone().get_matches_safe().unwrap_or_else(|err| { | let matches = app.clone().get_matches_safe().unwrap_or_else(|err| { | ||||
| let _ = ui::Ui::new().writeln_stderr_str(&err.message); | let _ = ui::Ui::new().writeln_stderr_str(&err.message); | ||||
| std::process::exit(exitcode::UNIMPLEMENTED) | std::process::exit(exitcode::UNIMPLEMENTED) | ||||
| }); | }); | ||||
| let ui = ui::Ui::new(); | let ui = ui::Ui::new(); | ||||