hglib/commands/
parents.rs1use super::common;
6use crate::client::{Client, HglibError, Runner};
7use crate::{runcommand, MkArg};
8
9pub struct Arg<'a> {
10 pub rev: &'a str,
11 pub file: &'a str,
12}
13
14impl<'a> Default for Arg<'a> {
15 fn default() -> Self {
16 Self { rev: "", file: "" }
17 }
18}
19
20impl<'a> Arg<'a> {
21 fn run(&self, client: &mut Client) -> Result<(Vec<u8>, i32), HglibError> {
22 runcommand!(
23 client,
24 "parents",
25 &[self.file],
26 "-r",
27 self.rev,
28 "--template",
29 common::CHANGESETS_TEMPLATE
30 )
31 }
32}
33
34impl Client {
35 pub fn parents(&mut self, x: Arg) -> Result<Vec<common::Revision>, HglibError> {
36 let (data, _) = x.run(self)?;
37 if data.is_empty() {
38 Ok(Vec::new())
39 } else {
40 common::parserevs(data)
41 }
42 }
43}