##// END OF EJS Templates
inno: remove w9xpopen.exe...
inno: remove w9xpopen.exe w9xpopen.exe is a utility program shipped with Python <3.4 (https://bugs.python.org/issue14470 tracked its removal). The program was used by subprocess to wrap invoked processes on Windows 95 and 98 or when command.com was used in order to work around a redirect bug. The workaround is only used on ancient Windows versions - versions that we shouldn't see in 2019. While Python 2.7's subprocess module still references w9xpopen.exe, not shipping it shouldn't matter unless we're running an ancient version of Windows. Python will raise an exception if w9xpopen.exe can't be found. It's highly unlikely anyone is using current Mercurial releases on these ancient Windows versions. So remove w9xpopen.exe from the Inno installer. .. bc:: The 32-bit Windows Inno installers no longer distribute w9xpopen.exe. This should only impact people running Mercurial on Windows 95, 98, or ME. Differential Revision: https://phab.mercurial-scm.org/D6068

File last commit:

r40324:87c76e5f default
r42021:2dbdb9ab default
Show More
main.rs
98 lines | 2.9 KiB | application/rls-services+xml | RustLexer
Yuya Nishihara
rust-chg: add project skeleton...
r40003 // Copyright 2018 Yuya Nishihara <yuya@tcha.org>
//
// This software may be used and distributed according to the terms of the
// GNU General Public License version 2 or any later version.
Yuya Nishihara
rust-chg: add main program...
r40015 extern crate chg;
extern crate futures;
Yuya Nishihara
rust-chg: install logger if $CHGDEBUG is set...
r40324 extern crate log;
Yuya Nishihara
rust-chg: add main program...
r40015 extern crate tokio;
extern crate tokio_hglib;
use chg::{ChgClientExt, ChgUiHandler};
use chg::locator;
Yuya Nishihara
rust-chg: install signal handlers to forward signals to server...
r40156 use chg::procutil;
Yuya Nishihara
rust-chg: add main program...
r40015 use futures::sync::oneshot;
use std::env;
use std::io;
use std::process;
Yuya Nishihara
rust-chg: install logger if $CHGDEBUG is set...
r40324 use std::time::Instant;
Yuya Nishihara
rust-chg: add main program...
r40015 use tokio::prelude::*;
use tokio_hglib::UnixClient;
Yuya Nishihara
rust-chg: install logger if $CHGDEBUG is set...
r40324 struct DebugLogger {
start: Instant,
}
impl DebugLogger {
pub fn new() -> DebugLogger {
DebugLogger {
start: Instant::now(),
}
}
}
impl log::Log for DebugLogger {
fn enabled(&self, metadata: &log::Metadata) -> bool {
metadata.target().starts_with("chg::")
}
fn log(&self, record: &log::Record) {
if self.enabled(record.metadata()) {
// just make the output looks similar to chg of C
let l = format!("{}", record.level()).to_lowercase();
let t = self.start.elapsed();
writeln!(io::stderr(), "chg: {}: {}.{:06} {}",
l, t.as_secs(), t.subsec_micros(), record.args()).unwrap_or(());
}
}
fn flush(&self) {
}
}
Yuya Nishihara
rust-chg: add project skeleton...
r40003 fn main() {
Yuya Nishihara
rust-chg: install logger if $CHGDEBUG is set...
r40324 if env::var_os("CHGDEBUG").is_some() {
log::set_boxed_logger(Box::new(DebugLogger::new()))
.expect("any logger should not be installed yet");
log::set_max_level(log::LevelFilter::Debug);
}
Yuya Nishihara
rust-chg: add main program...
r40015 let code = run().unwrap_or_else(|err| {
Yuya Nishihara
rust-chg: suppress panic while writing chg error to stderr...
r40322 writeln!(io::stderr(), "chg: abort: {}", err).unwrap_or(());
Yuya Nishihara
rust-chg: add main program...
r40015 255
});
process::exit(code);
Yuya Nishihara
rust-chg: add project skeleton...
r40003 }
Yuya Nishihara
rust-chg: add main program...
r40015
fn run() -> io::Result<i32> {
let current_dir = env::current_dir()?;
let sock_path = locator::prepare_server_socket_path()?;
let handler = ChgUiHandler::new();
let (result_tx, result_rx) = oneshot::channel();
let fut = UnixClient::connect(sock_path)
.and_then(|client| {
client.set_current_dir(current_dir)
})
.and_then(|client| {
client.attach_io(io::stdin(), io::stdout(), io::stderr())
})
.and_then(|client| {
Yuya Nishihara
rust-chg: install signal handlers to forward signals to server...
r40156 let pid = client.server_spec().process_id.unwrap();
let pgid = client.server_spec().process_group_id;
procutil::setup_signal_handler_once(pid, pgid)?;
Ok(client)
})
.and_then(|client| {
Yuya Nishihara
rust-chg: add main program...
r40015 client.run_command_chg(handler, env::args_os().skip(1))
})
.map(|(_client, _handler, code)| {
Yuya Nishihara
rust-chg: install signal handlers to forward signals to server...
r40156 procutil::restore_signal_handler_once()?;
Yuya Nishihara
rust-chg: add main program...
r40015 Ok(code)
})
.or_else(|err| Ok(Err(err))) // pass back error to caller
.map(|res| result_tx.send(res).unwrap());
tokio::run(fut);
result_rx.wait().unwrap_or(Err(io::Error::new(io::ErrorKind::Other,
"no exit code set")))
}