rust/rhg/src/commands/debugrequirements.rs
changeset 46462 d03b0601e0eb
parent 46167 8a4914397d02
child 46484 a6e4e4650bac
equal deleted inserted replaced
46461:f3f4d1b7dc97 46462:d03b0601e0eb
     1 use crate::commands::Command;
     1 use crate::commands::Command;
     2 use crate::error::CommandError;
     2 use crate::error::CommandError;
     3 use crate::ui::Ui;
     3 use crate::ui::Ui;
     4 use hg::repo::Repo;
     4 use hg::repo::Repo;
     5 use hg::requirements;
       
     6 
     5 
     7 pub const HELP_TEXT: &str = "
     6 pub const HELP_TEXT: &str = "
     8 Print the current repo requirements.
     7 Print the current repo requirements.
     9 ";
     8 ";
    10 
     9 
    18 
    17 
    19 impl Command for DebugRequirementsCommand {
    18 impl Command for DebugRequirementsCommand {
    20     fn run(&self, ui: &Ui) -> Result<(), CommandError> {
    19     fn run(&self, ui: &Ui) -> Result<(), CommandError> {
    21         let repo = Repo::find()?;
    20         let repo = Repo::find()?;
    22         let mut output = String::new();
    21         let mut output = String::new();
    23         for req in requirements::load(&repo)? {
    22         let mut requirements: Vec<_> = repo.requirements().iter().collect();
    24             output.push_str(&req);
    23         requirements.sort();
       
    24         for req in requirements {
       
    25             output.push_str(req);
    25             output.push('\n');
    26             output.push('\n');
    26         }
    27         }
    27         ui.write_stdout(output.as_bytes())?;
    28         ui.write_stdout(output.as_bytes())?;
    28         Ok(())
    29         Ok(())
    29     }
    30     }