comparison rust/rhg/src/commands/files.rs @ 46592:80840b651721

rhg: Group values passed to every sub-command into a struct The set of which values this is is evidently not stable yet, so this will make changes easier. Also it is growing, and the function signatures are getting out hand. Differential Revision: https://phab.mercurial-scm.org/D10003
author Simon Sapin <simon.sapin@octobus.net>
date Mon, 15 Feb 2021 20:05:32 +0100
parents d8730ff51d5a
children 5ce2aa7c2ad5
comparison
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,