hglib/commands/
pull.rs

1// This Source Code Form is subject to the terms of the Mozilla Public
2// License, v. 2.0. If a copy of the MPL was not distributed with this file,
3// You can obtain one at http://mozilla.org/MPL/2.0/.
4
5use crate::client::{Client, HglibError, Runner};
6use crate::{runcommand, MkArg};
7
8pub struct Arg<'a> {
9    pub source: &'a str,
10    pub rev: &'a [&'a str],
11    pub update: bool,
12    pub force: bool,
13    pub bookmark: &'a [&'a str],
14    pub branch: &'a [&'a str],
15    pub ssh: &'a str,
16    pub remotecmd: &'a str,
17    pub insecure: bool,
18    pub tool: &'a str,
19}
20
21impl<'a> Default for Arg<'a> {
22    fn default() -> Self {
23        Self {
24            source: "",
25            rev: &[],
26            update: false,
27            force: false,
28            bookmark: &[],
29            branch: &[],
30            ssh: "",
31            remotecmd: "",
32            insecure: false,
33            tool: "",
34        }
35    }
36}
37
38impl<'a> Arg<'a> {
39    fn run(&self, client: &mut Client) -> Result<(Vec<u8>, i32), HglibError> {
40        runcommand!(
41            client,
42            "pull",
43            &[self.source],
44            "-r",
45            self.rev,
46            "-u",
47            self.update,
48            "-f",
49            self.force,
50            "-B",
51            self.bookmark,
52            "-b",
53            self.branch,
54            "-e",
55            self.ssh,
56            "--remotecmd",
57            self.remotecmd,
58            "--insecure",
59            self.insecure,
60            "-t",
61            self.tool
62        )
63    }
64}
65
66impl Client {
67    pub fn pull(&mut self, x: Arg) -> Result<bool, HglibError> {
68        HglibError::handle_err(x.run(self))
69    }
70}