hglib/commands/
backout.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 rev: &'a str,
10    pub merge: bool,
11    pub parent: &'a str,
12    pub tool: &'a str,
13    pub message: &'a str,
14    pub logfile: &'a str,
15    pub date: &'a str,
16    pub user: &'a str,
17}
18
19impl<'a> Default for Arg<'a> {
20    fn default() -> Self {
21        Self {
22            rev: "",
23            merge: false,
24            parent: "",
25            tool: "",
26            message: "",
27            logfile: "",
28            date: "",
29            user: "",
30        }
31    }
32}
33
34impl<'a> Arg<'a> {
35    fn run(&self, client: &mut Client) -> Result<(Vec<u8>, i32), HglibError> {
36        runcommand!(
37            client,
38            "backout",
39            &[self.rev],
40            "--merge",
41            self.merge,
42            "--parent",
43            self.parent,
44            "-t",
45            self.tool,
46            "-m",
47            self.message,
48            "-l",
49            self.logfile,
50            "-d",
51            self.date,
52            "-u",
53            self.user
54        )
55    }
56}
57
58impl Client {
59    pub fn backout(&mut self, x: Arg) -> Result<(), HglibError> {
60        x.run(self)?;
61        Ok(())
62    }
63}