hglib/commands/
tip.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 super::common;
6use crate::client::{Client, HglibError, Runner};
7use crate::{runcommand, MkArg};
8
9pub struct Arg {}
10
11impl Default for Arg {
12    fn default() -> Self {
13        Self {}
14    }
15}
16
17impl Arg {
18    fn run(&self, client: &mut Client) -> Result<(Vec<u8>, i32), HglibError> {
19        runcommand!(
20            client,
21            "tip",
22            &[""],
23            "--template",
24            common::CHANGESETS_TEMPLATE
25        )
26    }
27}
28
29impl Client {
30    pub fn tip(&mut self, x: Arg) -> Result<common::Revision, HglibError> {
31        let (data, _) = x.run(self)?;
32        let mut rev = common::parserevs(data)?;
33        let rev = rev.pop().unwrap();
34
35        Ok(rev)
36    }
37}