rust/rhg/src/main.rs
changeset 48385 5b9865032533
parent 48186 9ecf802b06e0
child 48388 a2e278b5e265
equal deleted inserted replaced
48384:b7fde9237c92 48385:5b9865032533
     1 extern crate log;
     1 extern crate log;
       
     2 use crate::error::CommandError;
     2 use crate::ui::Ui;
     3 use crate::ui::Ui;
     3 use clap::App;
     4 use clap::App;
     4 use clap::AppSettings;
     5 use clap::AppSettings;
     5 use clap::Arg;
     6 use clap::Arg;
     6 use clap::ArgMatches;
     7 use clap::ArgMatches;
    18 mod error;
    19 mod error;
    19 mod ui;
    20 mod ui;
    20 pub mod utils {
    21 pub mod utils {
    21     pub mod path_utils;
    22     pub mod path_utils;
    22 }
    23 }
    23 use error::CommandError;
       
    24 
    24 
    25 fn main_with_result(
    25 fn main_with_result(
    26     process_start_time: &blackbox::ProcessStartTime,
    26     process_start_time: &blackbox::ProcessStartTime,
    27     ui: &ui::Ui,
    27     ui: &ui::Ui,
    28     repo: Result<&Repo, &NoRepoInCwdError>,
    28     repo: Result<&Repo, &NoRepoInCwdError>,
    29     config: &Config,
    29     config: &Config,
    30 ) -> Result<(), CommandError> {
    30 ) -> Result<(), CommandError> {
    31     check_extensions(config)?;
    31     check_unsupported(config)?;
    32 
    32 
    33     let app = App::new("rhg")
    33     let app = App::new("rhg")
    34         .global_setting(AppSettings::AllowInvalidUtf8)
    34         .global_setting(AppSettings::AllowInvalidUtf8)
    35         .global_setting(AppSettings::DisableVersion)
    35         .global_setting(AppSettings::DisableVersion)
    36         .setting(AppSettings::SubcommandRequired)
    36         .setting(AppSettings::SubcommandRequired)
   614                 join(unsupported, b", ")
   614                 join(unsupported, b", ")
   615             ),
   615             ),
   616         })
   616         })
   617     }
   617     }
   618 }
   618 }
       
   619 
       
   620 fn check_unsupported(config: &Config) -> Result<(), CommandError> {
       
   621     check_extensions(config)?;
       
   622 
       
   623     if std::env::var_os("HG_PENDING").is_some() {
       
   624         // TODO: only if the value is `== repo.working_directory`?
       
   625         // What about relative v.s. absolute paths?
       
   626         Err(CommandError::unsupported("$HG_PENDING"))?
       
   627     }
       
   628 
       
   629     Ok(())
       
   630 }