use crate::{Depth, DirentField, PropertyList};
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct GetFileOptions {
pub rev: u64,
pub want_props: bool,
pub want_iprops: bool,
pub max_bytes: u64,
}
impl GetFileOptions {
pub fn new(rev: u64, max_bytes: u64) -> Self {
Self {
rev,
want_props: false,
want_iprops: false,
max_bytes,
}
}
#[must_use]
pub fn with_props(mut self) -> Self {
self.want_props = true;
self
}
#[must_use]
pub fn with_iprops(mut self) -> Self {
self.want_iprops = true;
self
}
}
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Clone, Debug, PartialEq, Eq)]
pub enum LogRevProps {
All,
Custom(Vec<String>),
}
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct LogOptions {
pub target_paths: Vec<String>,
pub start_rev: Option<u64>,
pub end_rev: Option<u64>,
pub changed_paths: bool,
pub strict_node: bool,
pub limit: u64,
pub include_merged_revisions: bool,
pub revprops: LogRevProps,
}
impl Default for LogOptions {
fn default() -> Self {
Self {
target_paths: Vec::new(),
start_rev: None,
end_rev: None,
changed_paths: true,
strict_node: true,
limit: 0,
include_merged_revisions: false,
revprops: LogRevProps::All,
}
}
}
impl LogOptions {
#[must_use]
pub fn between(start_rev: u64, end_rev: u64) -> Self {
Self {
start_rev: Some(start_rev),
end_rev: Some(end_rev),
..Self::default()
}
}
}
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct ListOptions {
pub path: String,
pub rev: Option<u64>,
pub depth: Depth,
pub fields: Vec<DirentField>,
pub patterns: Vec<String>,
}
impl ListOptions {
pub fn new(path: impl Into<String>, depth: Depth) -> Self {
Self {
path: path.into(),
rev: None,
depth,
fields: Vec::new(),
patterns: Vec::new(),
}
}
#[must_use]
pub fn with_rev(mut self, rev: u64) -> Self {
self.rev = Some(rev);
self
}
#[must_use]
pub fn with_fields(mut self, fields: Vec<DirentField>) -> Self {
self.fields = fields;
self
}
#[must_use]
pub fn with_patterns(mut self, patterns: Vec<String>) -> Self {
self.patterns = patterns;
self
}
}
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct UpdateOptions {
pub rev: Option<u64>,
pub target: String,
pub depth: Depth,
pub send_copyfrom_args: bool,
pub ignore_ancestry: bool,
}
impl UpdateOptions {
pub fn new(target: impl Into<String>, depth: Depth) -> Self {
Self {
rev: None,
target: target.into(),
depth,
send_copyfrom_args: true,
ignore_ancestry: false,
}
}
#[must_use]
pub fn with_rev(mut self, rev: u64) -> Self {
self.rev = Some(rev);
self
}
#[must_use]
pub fn without_copyfrom_args(mut self) -> Self {
self.send_copyfrom_args = false;
self
}
#[must_use]
pub fn ignore_ancestry(mut self) -> Self {
self.ignore_ancestry = true;
self
}
}
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct SwitchOptions {
pub rev: Option<u64>,
pub target: String,
pub switch_url: String,
pub depth: Depth,
pub send_copyfrom_args: bool,
pub ignore_ancestry: bool,
}
impl SwitchOptions {
pub fn new(target: impl Into<String>, switch_url: impl Into<String>, depth: Depth) -> Self {
Self {
rev: None,
target: target.into(),
switch_url: switch_url.into(),
depth,
send_copyfrom_args: true,
ignore_ancestry: false,
}
}
#[must_use]
pub fn with_rev(mut self, rev: u64) -> Self {
self.rev = Some(rev);
self
}
#[must_use]
pub fn without_copyfrom_args(mut self) -> Self {
self.send_copyfrom_args = false;
self
}
#[must_use]
pub fn ignore_ancestry(mut self) -> Self {
self.ignore_ancestry = true;
self
}
}
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct StatusOptions {
pub target: String,
pub rev: Option<u64>,
pub depth: Depth,
}
impl StatusOptions {
pub fn new(target: impl Into<String>, depth: Depth) -> Self {
Self {
target: target.into(),
rev: None,
depth,
}
}
#[must_use]
pub fn with_rev(mut self, rev: u64) -> Self {
self.rev = Some(rev);
self
}
}
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct DiffOptions {
pub rev: Option<u64>,
pub target: String,
pub ignore_ancestry: bool,
pub versus_url: String,
pub text_deltas: bool,
pub depth: Depth,
}
impl DiffOptions {
pub fn new(target: impl Into<String>, versus_url: impl Into<String>, depth: Depth) -> Self {
Self {
rev: None,
target: target.into(),
ignore_ancestry: false,
versus_url: versus_url.into(),
text_deltas: true,
depth,
}
}
#[must_use]
pub fn with_rev(mut self, rev: u64) -> Self {
self.rev = Some(rev);
self
}
#[must_use]
pub fn ignore_ancestry(mut self) -> Self {
self.ignore_ancestry = true;
self
}
#[must_use]
pub fn with_text_deltas(mut self, text_deltas: bool) -> Self {
self.text_deltas = text_deltas;
self
}
}
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct ReplayOptions {
pub revision: u64,
pub low_water_mark: u64,
pub send_deltas: bool,
}
impl ReplayOptions {
pub fn new(revision: u64) -> Self {
Self {
revision,
low_water_mark: 0,
send_deltas: true,
}
}
#[must_use]
pub fn with_low_water_mark(mut self, low_water_mark: u64) -> Self {
self.low_water_mark = low_water_mark;
self
}
#[must_use]
pub fn with_send_deltas(mut self, send_deltas: bool) -> Self {
self.send_deltas = send_deltas;
self
}
}
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct ReplayRangeOptions {
pub start_rev: u64,
pub end_rev: u64,
pub low_water_mark: u64,
pub send_deltas: bool,
}
impl ReplayRangeOptions {
pub fn new(start_rev: u64, end_rev: u64) -> Self {
Self {
start_rev,
end_rev,
low_water_mark: 0,
send_deltas: true,
}
}
#[must_use]
pub fn with_low_water_mark(mut self, low_water_mark: u64) -> Self {
self.low_water_mark = low_water_mark;
self
}
#[must_use]
pub fn with_send_deltas(mut self, send_deltas: bool) -> Self {
self.send_deltas = send_deltas;
self
}
}
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Clone, Debug, PartialEq, Eq, Default)]
pub struct LockOptions {
pub comment: Option<String>,
pub steal_lock: bool,
pub current_rev: Option<u64>,
}
impl LockOptions {
pub fn new() -> Self {
Self::default()
}
#[must_use]
pub fn with_comment(mut self, comment: impl Into<String>) -> Self {
self.comment = Some(comment.into());
self
}
#[must_use]
pub fn steal_lock(mut self) -> Self {
self.steal_lock = true;
self
}
#[must_use]
pub fn with_current_rev(mut self, current_rev: u64) -> Self {
self.current_rev = Some(current_rev);
self
}
}
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Clone, Debug, PartialEq, Eq, Default)]
pub struct LockManyOptions {
pub comment: Option<String>,
pub steal_lock: bool,
}
impl LockManyOptions {
pub fn new() -> Self {
Self::default()
}
#[must_use]
pub fn with_comment(mut self, comment: impl Into<String>) -> Self {
self.comment = Some(comment.into());
self
}
#[must_use]
pub fn steal_lock(mut self) -> Self {
self.steal_lock = true;
self
}
}
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct LockTarget {
pub path: String,
pub current_rev: Option<u64>,
}
impl LockTarget {
pub fn new(path: impl Into<String>) -> Self {
Self {
path: path.into(),
current_rev: None,
}
}
#[must_use]
pub fn with_current_rev(mut self, current_rev: u64) -> Self {
self.current_rev = Some(current_rev);
self
}
}
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Clone, Debug, PartialEq, Eq, Default)]
pub struct UnlockOptions {
pub token: Option<String>,
pub break_lock: bool,
}
impl UnlockOptions {
pub fn new() -> Self {
Self::default()
}
#[must_use]
pub fn with_token(mut self, token: impl Into<String>) -> Self {
self.token = Some(token.into());
self
}
#[must_use]
pub fn break_lock(mut self) -> Self {
self.break_lock = true;
self
}
}
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Clone, Debug, PartialEq, Eq, Default)]
pub struct UnlockManyOptions {
pub break_lock: bool,
}
impl UnlockManyOptions {
pub fn new() -> Self {
Self::default()
}
#[must_use]
pub fn break_lock(mut self) -> Self {
self.break_lock = true;
self
}
}
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct UnlockTarget {
pub path: String,
pub token: Option<String>,
}
impl UnlockTarget {
pub fn new(path: impl Into<String>) -> Self {
Self {
path: path.into(),
token: None,
}
}
#[must_use]
pub fn with_token(mut self, token: impl Into<String>) -> Self {
self.token = Some(token.into());
self
}
}
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct CommitLockToken {
pub path: String,
pub token: String,
}
impl CommitLockToken {
pub fn new(path: impl Into<String>, token: impl Into<String>) -> Self {
Self {
path: path.into(),
token: token.into(),
}
}
}
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct CommitOptions {
pub log_message: String,
pub lock_tokens: Vec<CommitLockToken>,
pub keep_locks: bool,
pub rev_props: PropertyList,
}
impl CommitOptions {
pub fn new(log_message: impl Into<String>) -> Self {
Self {
log_message: log_message.into(),
lock_tokens: Vec::new(),
keep_locks: false,
rev_props: PropertyList::new(),
}
}
#[must_use]
pub fn with_lock_tokens(mut self, lock_tokens: Vec<CommitLockToken>) -> Self {
self.lock_tokens = lock_tokens;
self
}
#[must_use]
pub fn keep_locks(mut self) -> Self {
self.keep_locks = true;
self
}
#[must_use]
pub fn with_rev_props(mut self, rev_props: PropertyList) -> Self {
self.rev_props = rev_props;
self
}
}