comparison rust/chg/src/clientext.rs @ 44683:065048e66f32

rust-chg: send client side umask to server This is equivalent to forwardumask() of hgclient.c. Differential Revision: https://phab.mercurial-scm.org/D8382
author Yuya Nishihara <yuya@tcha.org>
date Thu, 04 Oct 2018 22:44:37 +0900
parents 43513444bb88
children 80d6e3415636
comparison
equal deleted inserted replaced
44682:9ce613d648de 44683:065048e66f32
3 // This software may be used and distributed according to the terms of the 3 // This software may be used and distributed according to the terms of the
4 // GNU General Public License version 2 or any later version. 4 // GNU General Public License version 2 or any later version.
5 5
6 //! cHg extensions to command server client. 6 //! cHg extensions to command server client.
7 7
8 use bytes::Bytes; 8 use bytes::{BufMut, Bytes, BytesMut};
9 use std::ffi::OsStr; 9 use std::ffi::OsStr;
10 use std::io; 10 use std::io;
11 use std::mem;
11 use std::os::unix::ffi::OsStrExt; 12 use std::os::unix::ffi::OsStrExt;
12 use std::os::unix::io::AsRawFd; 13 use std::os::unix::io::AsRawFd;
13 use std::path::Path; 14 use std::path::Path;
14 use tokio_hglib::protocol::{OneShotQuery, OneShotRequest}; 15 use tokio_hglib::protocol::{OneShotQuery, OneShotRequest};
15 use tokio_hglib::{Client, Connection}; 16 use tokio_hglib::{Client, Connection};
38 /// Updates the environment variables of the server. 39 /// Updates the environment variables of the server.
39 fn set_env_vars_os<I, P>(self, vars: I) -> OneShotRequest<C> 40 fn set_env_vars_os<I, P>(self, vars: I) -> OneShotRequest<C>
40 where 41 where
41 I: IntoIterator<Item = (P, P)>, 42 I: IntoIterator<Item = (P, P)>,
42 P: AsRef<OsStr>; 43 P: AsRef<OsStr>;
44
45 /// Changes the umask of the server process.
46 fn set_umask(self, mask: u32) -> OneShotRequest<C>;
43 47
44 /// Runs the specified Mercurial command with cHg extension. 48 /// Runs the specified Mercurial command with cHg extension.
45 fn run_command_chg<I, P, H>(self, handler: H, args: I) -> ChgRunCommand<C, H> 49 fn run_command_chg<I, P, H>(self, handler: H, args: I) -> ChgRunCommand<C, H>
46 where 50 where
47 I: IntoIterator<Item = P>, 51 I: IntoIterator<Item = P>,
88 P: AsRef<OsStr>, 92 P: AsRef<OsStr>,
89 { 93 {
90 OneShotRequest::start_with_args(self, b"setenv", message::pack_env_vars_os(vars)) 94 OneShotRequest::start_with_args(self, b"setenv", message::pack_env_vars_os(vars))
91 } 95 }
92 96
97 fn set_umask(self, mask: u32) -> OneShotRequest<C> {
98 let mut args = BytesMut::with_capacity(mem::size_of_val(&mask));
99 args.put_u32_be(mask);
100 OneShotRequest::start_with_args(self, b"setumask2", args)
101 }
102
93 fn run_command_chg<I, P, H>(self, handler: H, args: I) -> ChgRunCommand<C, H> 103 fn run_command_chg<I, P, H>(self, handler: H, args: I) -> ChgRunCommand<C, H>
94 where 104 where
95 I: IntoIterator<Item = P>, 105 I: IntoIterator<Item = P>,
96 P: AsRef<OsStr>, 106 P: AsRef<OsStr>,
97 H: SystemHandler, 107 H: SystemHandler,