I feel it's easier to follow to resolve modules from the crate root than
relative path from self module.
Details
Details
Diff Detail
Diff Detail
- Repository
- rHG Mercurial
- Branch
- default
- Lint
No Linters Available - Unit
No Unit Test Coverage
I feel it's easier to follow to resolve modules from the crate root than
relative path from self module.
| No Linters Available |
| No Unit Test Coverage |
| Path | Packages | |||
|---|---|---|---|---|
| M | rust/chg/src/attachio.rs (4 lines) | |||
| M | rust/chg/src/clientext.rs (8 lines) | |||
| M | rust/chg/src/locator.rs (6 lines) | |||
| M | rust/chg/src/runcommand.rs (6 lines) | |||
| M | rust/chg/src/uihandler.rs (4 lines) |
| Commit | Parents | Author | Summary | Date |
|---|---|---|---|---|
| 257259a63adc | 97e68b041686 | Yuya Nishihara | Apr 10 2020, 8:38 AM |
| // Copyright 2018 Yuya Nishihara <yuya@tcha.org> | // Copyright 2018 Yuya Nishihara <yuya@tcha.org> | ||||
| // | // | ||||
| // This software may be used and distributed according to the terms of the | // This software may be used and distributed according to the terms of the | ||||
| // GNU General Public License version 2 or any later version. | // GNU General Public License version 2 or any later version. | ||||
| //! Functions to send client-side fds over the command server channel. | //! Functions to send client-side fds over the command server channel. | ||||
| use futures::{try_ready, Async, Future, Poll}; | use futures::{try_ready, Async, Future, Poll}; | ||||
| use std::io; | use std::io; | ||||
| use std::os::unix::io::AsRawFd; | use std::os::unix::io::AsRawFd; | ||||
| use tokio_hglib::codec::ChannelMessage; | use tokio_hglib::codec::ChannelMessage; | ||||
| use tokio_hglib::protocol::MessageLoop; | use tokio_hglib::protocol::MessageLoop; | ||||
| use tokio_hglib::{Client, Connection}; | use tokio_hglib::{Client, Connection}; | ||||
| use super::message; | use crate::message; | ||||
| use super::procutil; | use crate::procutil; | ||||
| /// Future to send client-side fds over the command server channel. | /// Future to send client-side fds over the command server channel. | ||||
| /// | /// | ||||
| /// This works as follows: | /// This works as follows: | ||||
| /// 1. Client sends "attachio" request. | /// 1. Client sends "attachio" request. | ||||
| /// 2. Server sends back 1-byte input request. | /// 2. Server sends back 1-byte input request. | ||||
| /// 3. Client sends fds with 1-byte dummy payload in response. | /// 3. Client sends fds with 1-byte dummy payload in response. | ||||
| /// 4. Server returns the number of the fds received. | /// 4. Server returns the number of the fds received. | ||||
| use std::io; | use std::io; | ||||
| use std::mem; | use std::mem; | ||||
| use std::os::unix::ffi::OsStrExt; | use std::os::unix::ffi::OsStrExt; | ||||
| use std::os::unix::io::AsRawFd; | use std::os::unix::io::AsRawFd; | ||||
| use std::path::Path; | use std::path::Path; | ||||
| use tokio_hglib::protocol::{OneShotQuery, OneShotRequest}; | use tokio_hglib::protocol::{OneShotQuery, OneShotRequest}; | ||||
| use tokio_hglib::{Client, Connection}; | use tokio_hglib::{Client, Connection}; | ||||
| use super::attachio::AttachIo; | use crate::attachio::AttachIo; | ||||
| use super::message::{self, Instruction}; | use crate::message::{self, Instruction}; | ||||
| use super::runcommand::ChgRunCommand; | use crate::runcommand::ChgRunCommand; | ||||
| use super::uihandler::SystemHandler; | use crate::uihandler::SystemHandler; | ||||
| pub trait ChgClientExt<C> | pub trait ChgClientExt<C> | ||||
| where | where | ||||
| C: Connection + AsRawFd, | C: Connection + AsRawFd, | ||||
| { | { | ||||
| /// Attaches the client file descriptors to the server. | /// Attaches the client file descriptors to the server. | ||||
| fn attach_io<I, O, E>(self, stdin: I, stdout: O, stderr: E) -> AttachIo<C, I, O, E> | fn attach_io<I, O, E>(self, stdin: I, stdout: O, stderr: E) -> AttachIo<C, I, O, E> | ||||
| where | where | ||||
| use std::path::{Path, PathBuf}; | use std::path::{Path, PathBuf}; | ||||
| use std::process::{self, Command}; | use std::process::{self, Command}; | ||||
| use std::time::Duration; | use std::time::Duration; | ||||
| use tokio::prelude::*; | use tokio::prelude::*; | ||||
| use tokio_hglib::UnixClient; | use tokio_hglib::UnixClient; | ||||
| use tokio_process::{Child, CommandExt}; | use tokio_process::{Child, CommandExt}; | ||||
| use tokio_timer; | use tokio_timer; | ||||
| use super::clientext::ChgClientExt; | use crate::clientext::ChgClientExt; | ||||
| use super::message::{Instruction, ServerSpec}; | use crate::message::{Instruction, ServerSpec}; | ||||
| use super::procutil; | use crate::procutil; | ||||
| const REQUIRED_SERVER_CAPABILITIES: &[&str] = &[ | const REQUIRED_SERVER_CAPABILITIES: &[&str] = &[ | ||||
| "attachio", | "attachio", | ||||
| "chdir", | "chdir", | ||||
| "runcommand", | "runcommand", | ||||
| "setenv", | "setenv", | ||||
| "setumask2", | "setumask2", | ||||
| "validate", | "validate", | ||||
| use futures::{Async, Future, Poll}; | use futures::{Async, Future, Poll}; | ||||
| use std::io; | use std::io; | ||||
| use std::mem; | use std::mem; | ||||
| use std::os::unix::io::AsRawFd; | use std::os::unix::io::AsRawFd; | ||||
| use tokio_hglib::codec::ChannelMessage; | use tokio_hglib::codec::ChannelMessage; | ||||
| use tokio_hglib::protocol::MessageLoop; | use tokio_hglib::protocol::MessageLoop; | ||||
| use tokio_hglib::{Client, Connection}; | use tokio_hglib::{Client, Connection}; | ||||
| use super::attachio::AttachIo; | use crate::attachio::AttachIo; | ||||
| use super::message::{self, CommandType}; | use crate::message::{self, CommandType}; | ||||
| use super::uihandler::SystemHandler; | use crate::uihandler::SystemHandler; | ||||
| enum AsyncS<R, S> { | enum AsyncS<R, S> { | ||||
| Ready(R), | Ready(R), | ||||
| NotReady(S), | NotReady(S), | ||||
| PollAgain(S), | PollAgain(S), | ||||
| } | } | ||||
| enum CommandState<C, H> | enum CommandState<C, H> | ||||
| // Copyright 2018 Yuya Nishihara <yuya@tcha.org> | // Copyright 2018 Yuya Nishihara <yuya@tcha.org> | ||||
| // | // | ||||
| // This software may be used and distributed according to the terms of the | // This software may be used and distributed according to the terms of the | ||||
| // GNU General Public License version 2 or any later version. | // GNU General Public License version 2 or any later version. | ||||
| use futures::future::IntoFuture; | use futures::future::IntoFuture; | ||||
| use futures::Future; | use futures::Future; | ||||
| use std::io; | use std::io; | ||||
| use std::os::unix::io::AsRawFd; | use std::os::unix::io::AsRawFd; | ||||
| use std::os::unix::process::ExitStatusExt; | use std::os::unix::process::ExitStatusExt; | ||||
| use std::process::{Command, Stdio}; | use std::process::{Command, Stdio}; | ||||
| use tokio; | use tokio; | ||||
| use tokio_process::{ChildStdin, CommandExt}; | use tokio_process::{ChildStdin, CommandExt}; | ||||
| use super::message::CommandSpec; | use crate::message::CommandSpec; | ||||
| use super::procutil; | use crate::procutil; | ||||
| /// Callback to process shell command requests received from server. | /// Callback to process shell command requests received from server. | ||||
| pub trait SystemHandler: Sized { | pub trait SystemHandler: Sized { | ||||
| type PagerStdin: AsRawFd; | type PagerStdin: AsRawFd; | ||||
| type SpawnPagerResult: IntoFuture<Item = (Self, Self::PagerStdin), Error = io::Error>; | type SpawnPagerResult: IntoFuture<Item = (Self, Self::PagerStdin), Error = io::Error>; | ||||
| type RunSystemResult: IntoFuture<Item = (Self, i32), Error = io::Error>; | type RunSystemResult: IntoFuture<Item = (Self, i32), Error = io::Error>; | ||||
| /// Handles pager command request. | /// Handles pager command request. | ||||