Mercurial > public > mercurial-scm > hg-stable
comparison rust/rhg/src/commands/files.rs @ 46632:5ce2aa7c2ad5
rhg: Move `Repo` object creation into `main()`
? rather than in each sub-command that needs a local repository.
This will allow accessing e.g. `.hg/blackbox.log` before dispatching
to sub-commands.
Differential Revision: https://phab.mercurial-scm.org/D10004
author | Simon Sapin <simon.sapin@octobus.net> |
---|---|
date | Mon, 15 Feb 2021 20:13:09 +0100 |
parents | 80840b651721 |
children | c184b490da37 |
comparison
equal
deleted
inserted
replaced
46631:80840b651721 | 46632:5ce2aa7c2ad5 |
---|---|
27 } | 27 } |
28 | 28 |
29 pub fn run(invocation: &crate::CliInvocation) -> Result<(), CommandError> { | 29 pub fn run(invocation: &crate::CliInvocation) -> Result<(), CommandError> { |
30 let rev = invocation.subcommand_args.value_of("rev"); | 30 let rev = invocation.subcommand_args.value_of("rev"); |
31 | 31 |
32 let repo = Repo::find(invocation.non_repo_config, invocation.repo_path)?; | 32 let repo = invocation.repo?; |
33 if let Some(rev) = rev { | 33 if let Some(rev) = rev { |
34 let files = | 34 let files = list_rev_tracked_files(repo, rev).map_err(|e| (e, rev))?; |
35 list_rev_tracked_files(&repo, rev).map_err(|e| (e, rev))?; | 35 display_files(invocation.ui, repo, files.iter()) |
36 display_files(invocation.ui, &repo, files.iter()) | |
37 } else { | 36 } else { |
38 let distate = Dirstate::new(&repo)?; | 37 let distate = Dirstate::new(repo)?; |
39 let files = distate.tracked_files()?; | 38 let files = distate.tracked_files()?; |
40 display_files(invocation.ui, &repo, files) | 39 display_files(invocation.ui, repo, files) |
41 } | 40 } |
42 } | 41 } |
43 | 42 |
44 fn display_files<'a>( | 43 fn display_files<'a>( |
45 ui: &Ui, | 44 ui: &Ui, |