Mercurial > public > mercurial-scm > hg
annotate rust/chg/src/clientext.rs @ 48178:f12a19d03d2c
fix: reduce number of tool executions
By grouping together (path, ctx) pairs according to the inputs they would
provide to fixer tools, we can deduplicate executions of fixer tools to
significantly reduce the amount of time spent running slow tools.
This change does not handle clean files in the working copy, which could still
be deduplicated against the files in the checked out commit. It's a little
harder to do that because the filerev is not available in the workingfilectx
(and it doesn't exist for added files).
Anecdotally, this change makes some real uses cases at Google 10x faster. I
think we were originally hesitant to do this because the benefits weren't
obvious, and implementing it efficiently is kind of tricky. If we simply
memoized the formatter execution function, we would be keeping tons of file
content in memory.
Also included is a regression test for a corner case that I broke with my first
attempt at optimizing this code.
Differential Revision: https://phab.mercurial-scm.org/D11280
author | Danny Hooper <hooper@google.com> |
---|---|
date | Thu, 02 Sep 2021 14:08:45 -0700 |
parents | 426294d06ddc |
children |
rev | line source |
---|---|
39977
74da9d999cd7
rust-chg: add Client extensions to run cHg-specific requests
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
1 // Copyright 2018 Yuya Nishihara <yuya@tcha.org> |
74da9d999cd7
rust-chg: add Client extensions to run cHg-specific requests
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
2 // |
74da9d999cd7
rust-chg: add Client extensions to run cHg-specific requests
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
3 // This software may be used and distributed according to the terms of the |
74da9d999cd7
rust-chg: add Client extensions to run cHg-specific requests
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
4 // GNU General Public License version 2 or any later version. |
74da9d999cd7
rust-chg: add Client extensions to run cHg-specific requests
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
5 |
74da9d999cd7
rust-chg: add Client extensions to run cHg-specific requests
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
6 //! cHg extensions to command server client. |
74da9d999cd7
rust-chg: add Client extensions to run cHg-specific requests
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
7 |
44752
d6f706929120
rust-chg: reimplement ChgClientExt as ChgClient wrapper
Yuya Nishihara <yuya@tcha.org>
parents:
44737
diff
changeset
|
8 use bytes::{BufMut, BytesMut}; |
39977
74da9d999cd7
rust-chg: add Client extensions to run cHg-specific requests
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
9 use std::ffi::OsStr; |
44680
43513444bb88
rust-chg: add interface to run "validate" request
Yuya Nishihara <yuya@tcha.org>
parents:
44675
diff
changeset
|
10 use std::io; |
44683
065048e66f32
rust-chg: send client side umask to server
Yuya Nishihara <yuya@tcha.org>
parents:
44680
diff
changeset
|
11 use std::mem; |
39978
045ea159418d
rust-chg: add interface to chdir the server
Yuya Nishihara <yuya@tcha.org>
parents:
39977
diff
changeset
|
12 use std::os::unix::ffi::OsStrExt; |
39977
74da9d999cd7
rust-chg: add Client extensions to run cHg-specific requests
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
13 use std::os::unix::io::AsRawFd; |
39978
045ea159418d
rust-chg: add interface to chdir the server
Yuya Nishihara <yuya@tcha.org>
parents:
39977
diff
changeset
|
14 use std::path::Path; |
44752
d6f706929120
rust-chg: reimplement ChgClientExt as ChgClient wrapper
Yuya Nishihara <yuya@tcha.org>
parents:
44737
diff
changeset
|
15 use tokio_hglib::UnixClient; |
39977
74da9d999cd7
rust-chg: add Client extensions to run cHg-specific requests
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
16 |
44752
d6f706929120
rust-chg: reimplement ChgClientExt as ChgClient wrapper
Yuya Nishihara <yuya@tcha.org>
parents:
44737
diff
changeset
|
17 use crate::attachio; |
d6f706929120
rust-chg: reimplement ChgClientExt as ChgClient wrapper
Yuya Nishihara <yuya@tcha.org>
parents:
44737
diff
changeset
|
18 use crate::message::{self, Instruction, ServerSpec}; |
d6f706929120
rust-chg: reimplement ChgClientExt as ChgClient wrapper
Yuya Nishihara <yuya@tcha.org>
parents:
44737
diff
changeset
|
19 use crate::runcommand; |
44689
6bef9d43cc55
rust-chg: use "crate::" to import local modules
Yuya Nishihara <yuya@tcha.org>
parents:
44684
diff
changeset
|
20 use crate::uihandler::SystemHandler; |
39977
74da9d999cd7
rust-chg: add Client extensions to run cHg-specific requests
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
21 |
44752
d6f706929120
rust-chg: reimplement ChgClientExt as ChgClient wrapper
Yuya Nishihara <yuya@tcha.org>
parents:
44737
diff
changeset
|
22 /// Command-server client that also supports cHg extensions. |
d6f706929120
rust-chg: reimplement ChgClientExt as ChgClient wrapper
Yuya Nishihara <yuya@tcha.org>
parents:
44737
diff
changeset
|
23 pub struct ChgClient { |
d6f706929120
rust-chg: reimplement ChgClientExt as ChgClient wrapper
Yuya Nishihara <yuya@tcha.org>
parents:
44737
diff
changeset
|
24 client: UnixClient, |
d6f706929120
rust-chg: reimplement ChgClientExt as ChgClient wrapper
Yuya Nishihara <yuya@tcha.org>
parents:
44737
diff
changeset
|
25 } |
d6f706929120
rust-chg: reimplement ChgClientExt as ChgClient wrapper
Yuya Nishihara <yuya@tcha.org>
parents:
44737
diff
changeset
|
26 |
d6f706929120
rust-chg: reimplement ChgClientExt as ChgClient wrapper
Yuya Nishihara <yuya@tcha.org>
parents:
44737
diff
changeset
|
27 impl ChgClient { |
d6f706929120
rust-chg: reimplement ChgClientExt as ChgClient wrapper
Yuya Nishihara <yuya@tcha.org>
parents:
44737
diff
changeset
|
28 /// Connects to a command server listening at the specified socket path. |
d6f706929120
rust-chg: reimplement ChgClientExt as ChgClient wrapper
Yuya Nishihara <yuya@tcha.org>
parents:
44737
diff
changeset
|
29 pub async fn connect(path: impl AsRef<Path>) -> io::Result<Self> { |
d6f706929120
rust-chg: reimplement ChgClientExt as ChgClient wrapper
Yuya Nishihara <yuya@tcha.org>
parents:
44737
diff
changeset
|
30 let client = UnixClient::connect(path).await?; |
d6f706929120
rust-chg: reimplement ChgClientExt as ChgClient wrapper
Yuya Nishihara <yuya@tcha.org>
parents:
44737
diff
changeset
|
31 Ok(ChgClient { client }) |
d6f706929120
rust-chg: reimplement ChgClientExt as ChgClient wrapper
Yuya Nishihara <yuya@tcha.org>
parents:
44737
diff
changeset
|
32 } |
d6f706929120
rust-chg: reimplement ChgClientExt as ChgClient wrapper
Yuya Nishihara <yuya@tcha.org>
parents:
44737
diff
changeset
|
33 |
d6f706929120
rust-chg: reimplement ChgClientExt as ChgClient wrapper
Yuya Nishihara <yuya@tcha.org>
parents:
44737
diff
changeset
|
34 /// Server capabilities, encoding, etc. |
d6f706929120
rust-chg: reimplement ChgClientExt as ChgClient wrapper
Yuya Nishihara <yuya@tcha.org>
parents:
44737
diff
changeset
|
35 pub fn server_spec(&self) -> &ServerSpec { |
d6f706929120
rust-chg: reimplement ChgClientExt as ChgClient wrapper
Yuya Nishihara <yuya@tcha.org>
parents:
44737
diff
changeset
|
36 self.client.server_spec() |
d6f706929120
rust-chg: reimplement ChgClientExt as ChgClient wrapper
Yuya Nishihara <yuya@tcha.org>
parents:
44737
diff
changeset
|
37 } |
d6f706929120
rust-chg: reimplement ChgClientExt as ChgClient wrapper
Yuya Nishihara <yuya@tcha.org>
parents:
44737
diff
changeset
|
38 |
39977
74da9d999cd7
rust-chg: add Client extensions to run cHg-specific requests
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
39 /// Attaches the client file descriptors to the server. |
44752
d6f706929120
rust-chg: reimplement ChgClientExt as ChgClient wrapper
Yuya Nishihara <yuya@tcha.org>
parents:
44737
diff
changeset
|
40 pub async fn attach_io( |
d6f706929120
rust-chg: reimplement ChgClientExt as ChgClient wrapper
Yuya Nishihara <yuya@tcha.org>
parents:
44737
diff
changeset
|
41 &mut self, |
d6f706929120
rust-chg: reimplement ChgClientExt as ChgClient wrapper
Yuya Nishihara <yuya@tcha.org>
parents:
44737
diff
changeset
|
42 stdin: &impl AsRawFd, |
d6f706929120
rust-chg: reimplement ChgClientExt as ChgClient wrapper
Yuya Nishihara <yuya@tcha.org>
parents:
44737
diff
changeset
|
43 stdout: &impl AsRawFd, |
d6f706929120
rust-chg: reimplement ChgClientExt as ChgClient wrapper
Yuya Nishihara <yuya@tcha.org>
parents:
44737
diff
changeset
|
44 stderr: &impl AsRawFd, |
d6f706929120
rust-chg: reimplement ChgClientExt as ChgClient wrapper
Yuya Nishihara <yuya@tcha.org>
parents:
44737
diff
changeset
|
45 ) -> io::Result<()> { |
45620
426294d06ddc
rust: move rustfmt.toml to repo root so it can be used by `hg fix`
Martin von Zweigbergk <martinvonz@google.com>
parents:
44752
diff
changeset
|
46 attachio::attach_io( |
426294d06ddc
rust: move rustfmt.toml to repo root so it can be used by `hg fix`
Martin von Zweigbergk <martinvonz@google.com>
parents:
44752
diff
changeset
|
47 self.client.borrow_protocol_mut(), |
426294d06ddc
rust: move rustfmt.toml to repo root so it can be used by `hg fix`
Martin von Zweigbergk <martinvonz@google.com>
parents:
44752
diff
changeset
|
48 stdin, |
426294d06ddc
rust: move rustfmt.toml to repo root so it can be used by `hg fix`
Martin von Zweigbergk <martinvonz@google.com>
parents:
44752
diff
changeset
|
49 stdout, |
426294d06ddc
rust: move rustfmt.toml to repo root so it can be used by `hg fix`
Martin von Zweigbergk <martinvonz@google.com>
parents:
44752
diff
changeset
|
50 stderr, |
426294d06ddc
rust: move rustfmt.toml to repo root so it can be used by `hg fix`
Martin von Zweigbergk <martinvonz@google.com>
parents:
44752
diff
changeset
|
51 ) |
426294d06ddc
rust: move rustfmt.toml to repo root so it can be used by `hg fix`
Martin von Zweigbergk <martinvonz@google.com>
parents:
44752
diff
changeset
|
52 .await |
44752
d6f706929120
rust-chg: reimplement ChgClientExt as ChgClient wrapper
Yuya Nishihara <yuya@tcha.org>
parents:
44737
diff
changeset
|
53 } |
39977
74da9d999cd7
rust-chg: add Client extensions to run cHg-specific requests
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
54 |
39978
045ea159418d
rust-chg: add interface to chdir the server
Yuya Nishihara <yuya@tcha.org>
parents:
39977
diff
changeset
|
55 /// Changes the working directory of the server. |
45620
426294d06ddc
rust: move rustfmt.toml to repo root so it can be used by `hg fix`
Martin von Zweigbergk <martinvonz@google.com>
parents:
44752
diff
changeset
|
56 pub async fn set_current_dir( |
426294d06ddc
rust: move rustfmt.toml to repo root so it can be used by `hg fix`
Martin von Zweigbergk <martinvonz@google.com>
parents:
44752
diff
changeset
|
57 &mut self, |
426294d06ddc
rust: move rustfmt.toml to repo root so it can be used by `hg fix`
Martin von Zweigbergk <martinvonz@google.com>
parents:
44752
diff
changeset
|
58 dir: impl AsRef<Path>, |
426294d06ddc
rust: move rustfmt.toml to repo root so it can be used by `hg fix`
Martin von Zweigbergk <martinvonz@google.com>
parents:
44752
diff
changeset
|
59 ) -> io::Result<()> { |
44752
d6f706929120
rust-chg: reimplement ChgClientExt as ChgClient wrapper
Yuya Nishihara <yuya@tcha.org>
parents:
44737
diff
changeset
|
60 let dir_bytes = dir.as_ref().as_os_str().as_bytes().to_owned(); |
d6f706929120
rust-chg: reimplement ChgClientExt as ChgClient wrapper
Yuya Nishihara <yuya@tcha.org>
parents:
44737
diff
changeset
|
61 self.client |
d6f706929120
rust-chg: reimplement ChgClientExt as ChgClient wrapper
Yuya Nishihara <yuya@tcha.org>
parents:
44737
diff
changeset
|
62 .borrow_protocol_mut() |
d6f706929120
rust-chg: reimplement ChgClientExt as ChgClient wrapper
Yuya Nishihara <yuya@tcha.org>
parents:
44737
diff
changeset
|
63 .send_command_with_args("chdir", dir_bytes) |
d6f706929120
rust-chg: reimplement ChgClientExt as ChgClient wrapper
Yuya Nishihara <yuya@tcha.org>
parents:
44737
diff
changeset
|
64 .await |
d6f706929120
rust-chg: reimplement ChgClientExt as ChgClient wrapper
Yuya Nishihara <yuya@tcha.org>
parents:
44737
diff
changeset
|
65 } |
39978
045ea159418d
rust-chg: add interface to chdir the server
Yuya Nishihara <yuya@tcha.org>
parents:
39977
diff
changeset
|
66 |
44675
97e6d435ff7e
rust-chg: send client-side environment variables to server
Yuya Nishihara <yuya@tcha.org>
parents:
43818
diff
changeset
|
67 /// Updates the environment variables of the server. |
44752
d6f706929120
rust-chg: reimplement ChgClientExt as ChgClient wrapper
Yuya Nishihara <yuya@tcha.org>
parents:
44737
diff
changeset
|
68 pub async fn set_env_vars_os( |
d6f706929120
rust-chg: reimplement ChgClientExt as ChgClient wrapper
Yuya Nishihara <yuya@tcha.org>
parents:
44737
diff
changeset
|
69 &mut self, |
44693
61fda2dbc522
rust-chg: leverage impl trait at argument position
Yuya Nishihara <yuya@tcha.org>
parents:
44689
diff
changeset
|
70 vars: impl IntoIterator<Item = (impl AsRef<OsStr>, impl AsRef<OsStr>)>, |
44752
d6f706929120
rust-chg: reimplement ChgClientExt as ChgClient wrapper
Yuya Nishihara <yuya@tcha.org>
parents:
44737
diff
changeset
|
71 ) -> io::Result<()> { |
d6f706929120
rust-chg: reimplement ChgClientExt as ChgClient wrapper
Yuya Nishihara <yuya@tcha.org>
parents:
44737
diff
changeset
|
72 self.client |
d6f706929120
rust-chg: reimplement ChgClientExt as ChgClient wrapper
Yuya Nishihara <yuya@tcha.org>
parents:
44737
diff
changeset
|
73 .borrow_protocol_mut() |
d6f706929120
rust-chg: reimplement ChgClientExt as ChgClient wrapper
Yuya Nishihara <yuya@tcha.org>
parents:
44737
diff
changeset
|
74 .send_command_with_args("setenv", message::pack_env_vars_os(vars)) |
d6f706929120
rust-chg: reimplement ChgClientExt as ChgClient wrapper
Yuya Nishihara <yuya@tcha.org>
parents:
44737
diff
changeset
|
75 .await |
d6f706929120
rust-chg: reimplement ChgClientExt as ChgClient wrapper
Yuya Nishihara <yuya@tcha.org>
parents:
44737
diff
changeset
|
76 } |
44675
97e6d435ff7e
rust-chg: send client-side environment variables to server
Yuya Nishihara <yuya@tcha.org>
parents:
43818
diff
changeset
|
77 |
44684
80d6e3415636
rust-chg: update name of the server process
Yuya Nishihara <yuya@tcha.org>
parents:
44683
diff
changeset
|
78 /// Changes the process title of the server. |
45620
426294d06ddc
rust: move rustfmt.toml to repo root so it can be used by `hg fix`
Martin von Zweigbergk <martinvonz@google.com>
parents:
44752
diff
changeset
|
79 pub async fn set_process_name( |
426294d06ddc
rust: move rustfmt.toml to repo root so it can be used by `hg fix`
Martin von Zweigbergk <martinvonz@google.com>
parents:
44752
diff
changeset
|
80 &mut self, |
426294d06ddc
rust: move rustfmt.toml to repo root so it can be used by `hg fix`
Martin von Zweigbergk <martinvonz@google.com>
parents:
44752
diff
changeset
|
81 name: impl AsRef<OsStr>, |
426294d06ddc
rust: move rustfmt.toml to repo root so it can be used by `hg fix`
Martin von Zweigbergk <martinvonz@google.com>
parents:
44752
diff
changeset
|
82 ) -> io::Result<()> { |
44752
d6f706929120
rust-chg: reimplement ChgClientExt as ChgClient wrapper
Yuya Nishihara <yuya@tcha.org>
parents:
44737
diff
changeset
|
83 let name_bytes = name.as_ref().as_bytes().to_owned(); |
d6f706929120
rust-chg: reimplement ChgClientExt as ChgClient wrapper
Yuya Nishihara <yuya@tcha.org>
parents:
44737
diff
changeset
|
84 self.client |
d6f706929120
rust-chg: reimplement ChgClientExt as ChgClient wrapper
Yuya Nishihara <yuya@tcha.org>
parents:
44737
diff
changeset
|
85 .borrow_protocol_mut() |
d6f706929120
rust-chg: reimplement ChgClientExt as ChgClient wrapper
Yuya Nishihara <yuya@tcha.org>
parents:
44737
diff
changeset
|
86 .send_command_with_args("setprocname", name_bytes) |
d6f706929120
rust-chg: reimplement ChgClientExt as ChgClient wrapper
Yuya Nishihara <yuya@tcha.org>
parents:
44737
diff
changeset
|
87 .await |
d6f706929120
rust-chg: reimplement ChgClientExt as ChgClient wrapper
Yuya Nishihara <yuya@tcha.org>
parents:
44737
diff
changeset
|
88 } |
44684
80d6e3415636
rust-chg: update name of the server process
Yuya Nishihara <yuya@tcha.org>
parents:
44683
diff
changeset
|
89 |
44683
065048e66f32
rust-chg: send client side umask to server
Yuya Nishihara <yuya@tcha.org>
parents:
44680
diff
changeset
|
90 /// Changes the umask of the server process. |
44752
d6f706929120
rust-chg: reimplement ChgClientExt as ChgClient wrapper
Yuya Nishihara <yuya@tcha.org>
parents:
44737
diff
changeset
|
91 pub async fn set_umask(&mut self, mask: u32) -> io::Result<()> { |
d6f706929120
rust-chg: reimplement ChgClientExt as ChgClient wrapper
Yuya Nishihara <yuya@tcha.org>
parents:
44737
diff
changeset
|
92 let mut mask_bytes = BytesMut::with_capacity(mem::size_of_val(&mask)); |
d6f706929120
rust-chg: reimplement ChgClientExt as ChgClient wrapper
Yuya Nishihara <yuya@tcha.org>
parents:
44737
diff
changeset
|
93 mask_bytes.put_u32(mask); |
d6f706929120
rust-chg: reimplement ChgClientExt as ChgClient wrapper
Yuya Nishihara <yuya@tcha.org>
parents:
44737
diff
changeset
|
94 self.client |
d6f706929120
rust-chg: reimplement ChgClientExt as ChgClient wrapper
Yuya Nishihara <yuya@tcha.org>
parents:
44737
diff
changeset
|
95 .borrow_protocol_mut() |
d6f706929120
rust-chg: reimplement ChgClientExt as ChgClient wrapper
Yuya Nishihara <yuya@tcha.org>
parents:
44737
diff
changeset
|
96 .send_command_with_args("setumask2", mask_bytes) |
d6f706929120
rust-chg: reimplement ChgClientExt as ChgClient wrapper
Yuya Nishihara <yuya@tcha.org>
parents:
44737
diff
changeset
|
97 .await |
d6f706929120
rust-chg: reimplement ChgClientExt as ChgClient wrapper
Yuya Nishihara <yuya@tcha.org>
parents:
44737
diff
changeset
|
98 } |
44683
065048e66f32
rust-chg: send client side umask to server
Yuya Nishihara <yuya@tcha.org>
parents:
44680
diff
changeset
|
99 |
39977
74da9d999cd7
rust-chg: add Client extensions to run cHg-specific requests
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
100 /// Runs the specified Mercurial command with cHg extension. |
44752
d6f706929120
rust-chg: reimplement ChgClientExt as ChgClient wrapper
Yuya Nishihara <yuya@tcha.org>
parents:
44737
diff
changeset
|
101 pub async fn run_command_chg( |
d6f706929120
rust-chg: reimplement ChgClientExt as ChgClient wrapper
Yuya Nishihara <yuya@tcha.org>
parents:
44737
diff
changeset
|
102 &mut self, |
d6f706929120
rust-chg: reimplement ChgClientExt as ChgClient wrapper
Yuya Nishihara <yuya@tcha.org>
parents:
44737
diff
changeset
|
103 handler: &mut impl SystemHandler, |
44693
61fda2dbc522
rust-chg: leverage impl trait at argument position
Yuya Nishihara <yuya@tcha.org>
parents:
44689
diff
changeset
|
104 args: impl IntoIterator<Item = impl AsRef<OsStr>>, |
44752
d6f706929120
rust-chg: reimplement ChgClientExt as ChgClient wrapper
Yuya Nishihara <yuya@tcha.org>
parents:
44737
diff
changeset
|
105 ) -> io::Result<i32> { |
d6f706929120
rust-chg: reimplement ChgClientExt as ChgClient wrapper
Yuya Nishihara <yuya@tcha.org>
parents:
44737
diff
changeset
|
106 runcommand::run_command( |
d6f706929120
rust-chg: reimplement ChgClientExt as ChgClient wrapper
Yuya Nishihara <yuya@tcha.org>
parents:
44737
diff
changeset
|
107 self.client.borrow_protocol_mut(), |
d6f706929120
rust-chg: reimplement ChgClientExt as ChgClient wrapper
Yuya Nishihara <yuya@tcha.org>
parents:
44737
diff
changeset
|
108 handler, |
d6f706929120
rust-chg: reimplement ChgClientExt as ChgClient wrapper
Yuya Nishihara <yuya@tcha.org>
parents:
44737
diff
changeset
|
109 message::pack_args_os(args), |
d6f706929120
rust-chg: reimplement ChgClientExt as ChgClient wrapper
Yuya Nishihara <yuya@tcha.org>
parents:
44737
diff
changeset
|
110 ) |
d6f706929120
rust-chg: reimplement ChgClientExt as ChgClient wrapper
Yuya Nishihara <yuya@tcha.org>
parents:
44737
diff
changeset
|
111 .await |
d6f706929120
rust-chg: reimplement ChgClientExt as ChgClient wrapper
Yuya Nishihara <yuya@tcha.org>
parents:
44737
diff
changeset
|
112 } |
44680
43513444bb88
rust-chg: add interface to run "validate" request
Yuya Nishihara <yuya@tcha.org>
parents:
44675
diff
changeset
|
113 |
43513444bb88
rust-chg: add interface to run "validate" request
Yuya Nishihara <yuya@tcha.org>
parents:
44675
diff
changeset
|
114 /// Validates if the server can run Mercurial commands with the expected |
43513444bb88
rust-chg: add interface to run "validate" request
Yuya Nishihara <yuya@tcha.org>
parents:
44675
diff
changeset
|
115 /// configuration. |
43513444bb88
rust-chg: add interface to run "validate" request
Yuya Nishihara <yuya@tcha.org>
parents:
44675
diff
changeset
|
116 /// |
43513444bb88
rust-chg: add interface to run "validate" request
Yuya Nishihara <yuya@tcha.org>
parents:
44675
diff
changeset
|
117 /// The `args` should contain early command arguments such as `--config` |
43513444bb88
rust-chg: add interface to run "validate" request
Yuya Nishihara <yuya@tcha.org>
parents:
44675
diff
changeset
|
118 /// and `-R`. |
43513444bb88
rust-chg: add interface to run "validate" request
Yuya Nishihara <yuya@tcha.org>
parents:
44675
diff
changeset
|
119 /// |
43513444bb88
rust-chg: add interface to run "validate" request
Yuya Nishihara <yuya@tcha.org>
parents:
44675
diff
changeset
|
120 /// Client-side environment must be sent prior to this request, by |
43513444bb88
rust-chg: add interface to run "validate" request
Yuya Nishihara <yuya@tcha.org>
parents:
44675
diff
changeset
|
121 /// `set_current_dir()` and `set_env_vars_os()`. |
44752
d6f706929120
rust-chg: reimplement ChgClientExt as ChgClient wrapper
Yuya Nishihara <yuya@tcha.org>
parents:
44737
diff
changeset
|
122 pub async fn validate( |
d6f706929120
rust-chg: reimplement ChgClientExt as ChgClient wrapper
Yuya Nishihara <yuya@tcha.org>
parents:
44737
diff
changeset
|
123 &mut self, |
44693
61fda2dbc522
rust-chg: leverage impl trait at argument position
Yuya Nishihara <yuya@tcha.org>
parents:
44689
diff
changeset
|
124 args: impl IntoIterator<Item = impl AsRef<OsStr>>, |
44752
d6f706929120
rust-chg: reimplement ChgClientExt as ChgClient wrapper
Yuya Nishihara <yuya@tcha.org>
parents:
44737
diff
changeset
|
125 ) -> io::Result<Vec<Instruction>> { |
d6f706929120
rust-chg: reimplement ChgClientExt as ChgClient wrapper
Yuya Nishihara <yuya@tcha.org>
parents:
44737
diff
changeset
|
126 let data = self |
d6f706929120
rust-chg: reimplement ChgClientExt as ChgClient wrapper
Yuya Nishihara <yuya@tcha.org>
parents:
44737
diff
changeset
|
127 .client |
d6f706929120
rust-chg: reimplement ChgClientExt as ChgClient wrapper
Yuya Nishihara <yuya@tcha.org>
parents:
44737
diff
changeset
|
128 .borrow_protocol_mut() |
d6f706929120
rust-chg: reimplement ChgClientExt as ChgClient wrapper
Yuya Nishihara <yuya@tcha.org>
parents:
44737
diff
changeset
|
129 .query_with_args("validate", message::pack_args_os(args)) |
d6f706929120
rust-chg: reimplement ChgClientExt as ChgClient wrapper
Yuya Nishihara <yuya@tcha.org>
parents:
44737
diff
changeset
|
130 .await?; |
d6f706929120
rust-chg: reimplement ChgClientExt as ChgClient wrapper
Yuya Nishihara <yuya@tcha.org>
parents:
44737
diff
changeset
|
131 message::parse_instructions(data) |
44680
43513444bb88
rust-chg: add interface to run "validate" request
Yuya Nishihara <yuya@tcha.org>
parents:
44675
diff
changeset
|
132 } |
39977
74da9d999cd7
rust-chg: add Client extensions to run cHg-specific requests
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
133 } |