rust/rhg/src/commands/files.rs
changeset 46592 80840b651721
parent 46503 d8730ff51d5a
child 46593 5ce2aa7c2ad5
equal deleted inserted replaced
46591:21d3b40b4c0e 46592:80840b651721
     1 use crate::error::CommandError;
     1 use crate::error::CommandError;
     2 use crate::ui::Ui;
     2 use crate::ui::Ui;
     3 use clap::Arg;
     3 use clap::Arg;
     4 use clap::ArgMatches;
       
     5 use hg::config::Config;
       
     6 use hg::operations::list_rev_tracked_files;
     4 use hg::operations::list_rev_tracked_files;
     7 use hg::operations::Dirstate;
     5 use hg::operations::Dirstate;
     8 use hg::repo::Repo;
     6 use hg::repo::Repo;
     9 use hg::utils::files::{get_bytes_from_path, relativize_path};
     7 use hg::utils::files::{get_bytes_from_path, relativize_path};
    10 use hg::utils::hg_path::{HgPath, HgPathBuf};
     8 use hg::utils::hg_path::{HgPath, HgPathBuf};
    11 use std::path::Path;
       
    12 
     9 
    13 pub const HELP_TEXT: &str = "
    10 pub const HELP_TEXT: &str = "
    14 List tracked files.
    11 List tracked files.
    15 
    12 
    16 Returns 0 on success.
    13 Returns 0 on success.
    27                 .takes_value(true),
    24                 .takes_value(true),
    28         )
    25         )
    29         .about(HELP_TEXT)
    26         .about(HELP_TEXT)
    30 }
    27 }
    31 
    28 
    32 pub fn run(
    29 pub fn run(invocation: &crate::CliInvocation) -> Result<(), CommandError> {
    33     ui: &Ui,
    30     let rev = invocation.subcommand_args.value_of("rev");
    34     config: &Config,
       
    35     repo_path: Option<&Path>,
       
    36     args: &ArgMatches,
       
    37 ) -> Result<(), CommandError> {
       
    38     let rev = args.value_of("rev");
       
    39 
    31 
    40     let repo = Repo::find(config, repo_path)?;
    32     let repo = Repo::find(invocation.non_repo_config, invocation.repo_path)?;
    41     if let Some(rev) = rev {
    33     if let Some(rev) = rev {
    42         let files =
    34         let files =
    43             list_rev_tracked_files(&repo, rev).map_err(|e| (e, rev))?;
    35             list_rev_tracked_files(&repo, rev).map_err(|e| (e, rev))?;
    44         display_files(ui, &repo, files.iter())
    36         display_files(invocation.ui, &repo, files.iter())
    45     } else {
    37     } else {
    46         let distate = Dirstate::new(&repo)?;
    38         let distate = Dirstate::new(&repo)?;
    47         let files = distate.tracked_files()?;
    39         let files = distate.tracked_files()?;
    48         display_files(ui, &repo, files)
    40         display_files(invocation.ui, &repo, files)
    49     }
    41     }
    50 }
    42 }
    51 
    43 
    52 fn display_files<'a>(
    44 fn display_files<'a>(
    53     ui: &Ui,
    45     ui: &Ui,