1use crate::client::{Client, HglibError, Runner};
6use crate::{runcommand, MkArg};
7
8pub struct Arg<'a> {
9 pub dest: &'a str,
10 pub rev: &'a [&'a str],
11 pub force: bool,
12 pub bookmark: &'a [&'a str],
13 pub branch: &'a [&'a str],
14 pub newbranch: &'a str,
15 pub ssh: &'a str,
16 pub remotecmd: &'a str,
17 pub insecure: bool,
18}
19
20impl<'a> Default for Arg<'a> {
21 fn default() -> Self {
22 Self {
23 dest: "",
24 rev: &[],
25 force: false,
26 bookmark: &[],
27 branch: &[],
28 newbranch: "",
29 ssh: "",
30 remotecmd: "",
31 insecure: false,
32 }
33 }
34}
35
36impl<'a> Arg<'a> {
37 fn run(&self, client: &mut Client) -> Result<(Vec<u8>, i32), HglibError> {
38 runcommand!(
39 client,
40 "push",
41 &[self.dest],
42 "-r",
43 self.rev,
44 "-f",
45 self.force,
46 "-B",
47 self.bookmark,
48 "-b",
49 self.branch,
50 "--new-branch",
51 self.newbranch,
52 "-e",
53 self.ssh,
54 "--remotecmd",
55 self.remotecmd,
56 "--insecure",
57 self.insecure
58 )
59 }
60}
61
62impl Client {
63 pub fn push(&mut self, x: Arg) -> Result<bool, HglibError> {
64 HglibError::handle_err(x.run(self))
65 }
66}