Mercurial > hg
comparison rust/rhg/src/commands/debugrequirements.rs @ 46593: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 | 37bc3edef76f |
comparison
equal
deleted
inserted
replaced
46592:80840b651721 | 46593:5ce2aa7c2ad5 |
---|---|
1 use crate::error::CommandError; | 1 use crate::error::CommandError; |
2 use hg::repo::Repo; | |
3 | 2 |
4 pub const HELP_TEXT: &str = " | 3 pub const HELP_TEXT: &str = " |
5 Print the current repo requirements. | 4 Print the current repo requirements. |
6 "; | 5 "; |
7 | 6 |
8 pub fn args() -> clap::App<'static, 'static> { | 7 pub fn args() -> clap::App<'static, 'static> { |
9 clap::SubCommand::with_name("debugrequirements").about(HELP_TEXT) | 8 clap::SubCommand::with_name("debugrequirements").about(HELP_TEXT) |
10 } | 9 } |
11 | 10 |
12 pub fn run(invocation: &crate::CliInvocation) -> Result<(), CommandError> { | 11 pub fn run(invocation: &crate::CliInvocation) -> Result<(), CommandError> { |
13 let repo = Repo::find(invocation.non_repo_config, invocation.repo_path)?; | 12 let repo = invocation.repo?; |
14 let mut output = String::new(); | 13 let mut output = String::new(); |
15 let mut requirements: Vec<_> = repo.requirements().iter().collect(); | 14 let mut requirements: Vec<_> = repo.requirements().iter().collect(); |
16 requirements.sort(); | 15 requirements.sort(); |
17 for req in requirements { | 16 for req in requirements { |
18 output.push_str(req); | 17 output.push_str(req); |