Mercurial > hg
changeset 44695:f87804825df5
rust-chg: indent process_message() to prepare mass rewrite to futures-0.3
I'll start upgrading the codebase to modern async/await-based implementation,
which cannot be done incrementally. This is the last non-breaking patch to
prepare for the rewrite.
Differential Revision: https://phab.mercurial-scm.org/D8403
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Fri, 10 Apr 2020 22:30:50 +0900 |
parents | 5ac5c25ea97b |
children | ed475420e0af |
files | rust/chg/src/runcommand.rs |
diffstat | 1 files changed, 25 insertions(+), 24 deletions(-) [+] |
line wrap: on
line diff
--- a/rust/chg/src/runcommand.rs Sat Apr 11 15:27:08 2020 +0900 +++ b/rust/chg/src/runcommand.rs Fri Apr 10 22:30:50 2020 +0900 @@ -140,30 +140,31 @@ C: Connection, H: SystemHandler, { - match msg { - ChannelMessage::Data(b'r', data) => { - let code = message::parse_result_code(data)?; - Ok(AsyncS::Ready((client, handler, code))) - } - ChannelMessage::Data(..) => { - // just ignores data sent to optional channel - let msg_loop = MessageLoop::resume(client); - Ok(AsyncS::PollAgain(CommandState::Running(msg_loop, handler))) - } - ChannelMessage::InputRequest(..) | ChannelMessage::LineRequest(..) => Err(io::Error::new( - io::ErrorKind::InvalidData, - "unsupported request", - )), - ChannelMessage::SystemRequest(data) => { - let (cmd_type, cmd_spec) = message::parse_command_spec(data)?; - match cmd_type { - CommandType::Pager => { - let fut = handler.spawn_pager(cmd_spec).into_future(); - Ok(AsyncS::PollAgain(CommandState::SpawningPager(client, fut))) - } - CommandType::System => { - let fut = handler.run_system(cmd_spec).into_future(); - Ok(AsyncS::PollAgain(CommandState::WaitingSystem(client, fut))) + { + match msg { + ChannelMessage::Data(b'r', data) => { + let code = message::parse_result_code(data)?; + Ok(AsyncS::Ready((client, handler, code))) + } + ChannelMessage::Data(..) => { + // just ignores data sent to optional channel + let msg_loop = MessageLoop::resume(client); + Ok(AsyncS::PollAgain(CommandState::Running(msg_loop, handler))) + } + ChannelMessage::InputRequest(..) | ChannelMessage::LineRequest(..) => Err( + io::Error::new(io::ErrorKind::InvalidData, "unsupported request"), + ), + ChannelMessage::SystemRequest(data) => { + let (cmd_type, cmd_spec) = message::parse_command_spec(data)?; + match cmd_type { + CommandType::Pager => { + let fut = handler.spawn_pager(cmd_spec).into_future(); + Ok(AsyncS::PollAgain(CommandState::SpawningPager(client, fut))) + } + CommandType::System => { + let fut = handler.run_system(cmd_spec).into_future(); + Ok(AsyncS::PollAgain(CommandState::WaitingSystem(client, fut))) + } } } }