use std::collections::BTreeMap;
use std::fmt::{Display, Formatter};
pub type PropertyList = BTreeMap<String, Vec<u8>>;
pub type MergeInfoCatalog = BTreeMap<String, String>;
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct InheritedProps {
pub path: String,
pub props: PropertyList,
}
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct RepositoryInfo {
pub uuid: String,
pub root_url: String,
pub capabilities: Vec<String>,
}
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct ServerInfo {
pub server_caps: Vec<String>,
pub repository: RepositoryInfo,
}
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct CommitInfo {
pub new_rev: u64,
pub date: Option<String>,
pub author: Option<String>,
pub post_commit_err: Option<String>,
}
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct GetFileResult {
pub rev: u64,
pub checksum: Option<String>,
pub props: PropertyList,
pub inherited_props: Vec<InheritedProps>,
pub bytes_written: u64,
}
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct LocationEntry {
pub rev: u64,
pub path: String,
}
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct LocationSegment {
pub range_start: u64,
pub range_end: u64,
pub path: Option<String>,
}
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum MergeInfoInheritance {
Explicit,
Inherited,
NearestAncestor,
}
impl MergeInfoInheritance {
pub(crate) fn as_word(self) -> &'static str {
match self {
Self::Explicit => "explicit",
Self::Inherited => "inherited",
Self::NearestAncestor => "nearest-ancestor",
}
}
}
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct PropDelta {
pub name: String,
pub value: Option<Vec<u8>>,
}
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct FileRev {
pub path: String,
pub rev: u64,
pub rev_props: PropertyList,
pub prop_deltas: Vec<PropDelta>,
pub merged_revision: bool,
pub delta_chunks: Vec<Vec<u8>>,
}
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct FileRevContents {
pub file_rev: FileRev,
pub contents: Vec<u8>,
}
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct BlameLine {
pub rev: u64,
pub author: Option<String>,
pub date: Option<String>,
pub line: String,
}
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct LockDesc {
pub path: String,
pub token: String,
pub owner: String,
pub comment: Option<String>,
pub created: String,
pub expires: Option<String>,
}
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct LogEntry {
pub rev: u64,
pub changed_paths: Vec<ChangedPath>,
pub author: Option<String>,
pub date: Option<String>,
pub message: Option<String>,
pub rev_props: PropertyList,
pub has_children: bool,
pub invalid_revnum: bool,
pub subtractive_merge: bool,
}
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct ChangedPath {
pub action: String,
pub path: String,
pub copy_from_path: Option<String>,
pub copy_from_rev: Option<u64>,
pub node_kind: Option<NodeKind>,
pub text_mods: Option<bool>,
pub prop_mods: Option<bool>,
}
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum NodeKind {
None,
File,
Dir,
Unknown,
}
impl NodeKind {
pub(crate) fn from_word(word: &str) -> Self {
match word {
"none" => Self::None,
"file" => Self::File,
"dir" => Self::Dir,
_ => Self::Unknown,
}
}
pub fn as_str(self) -> &'static str {
match self {
Self::None => "none",
Self::File => "file",
Self::Dir => "dir",
Self::Unknown => "unknown",
}
}
}
impl Display for NodeKind {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", self.as_str())
}
}
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct DirEntry {
pub name: String,
pub path: String,
pub kind: NodeKind,
pub size: Option<u64>,
pub has_props: Option<bool>,
pub created_rev: Option<u64>,
pub created_date: Option<String>,
pub last_author: Option<String>,
}
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct DirListing {
pub rev: u64,
pub entries: Vec<DirEntry>,
}
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum Depth {
Empty,
Files,
Immediates,
Infinity,
}
impl Depth {
pub(crate) fn as_word(self) -> &'static str {
match self {
Self::Empty => "empty",
Self::Files => "files",
Self::Immediates => "immediates",
Self::Infinity => "infinity",
}
}
}
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum DirentField {
Kind,
Size,
HasProps,
CreatedRev,
Time,
LastAuthor,
Word,
}
impl DirentField {
pub(crate) fn as_word(self) -> &'static str {
match self {
Self::Kind => "kind",
Self::Size => "size",
Self::HasProps => "has-props",
Self::CreatedRev => "created-rev",
Self::Time => "time",
Self::LastAuthor => "last-author",
Self::Word => "word",
}
}
}
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct StatEntry {
pub kind: NodeKind,
pub size: Option<u64>,
pub has_props: Option<bool>,
pub created_rev: Option<u64>,
pub created_date: Option<String>,
pub last_author: Option<String>,
}
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub enum Capability {
EditPipeline,
Svndiff1,
AcceptsSvndiff2,
AbsentEntries,
CommitRevProps,
MergeInfo,
Depth,
AtomicRevProps,
InheritedProps,
LogRevProps,
PartialReplay,
EphemeralTxnProps,
GetFileRevsReverse,
List,
}
impl Capability {
pub fn as_wire_word(self) -> &'static str {
match self {
Self::EditPipeline => "edit-pipeline",
Self::Svndiff1 => "svndiff1",
Self::AcceptsSvndiff2 => "accepts-svndiff2",
Self::AbsentEntries => "absent-entries",
Self::CommitRevProps => "commit-revprops",
Self::MergeInfo => "mergeinfo",
Self::Depth => "depth",
Self::AtomicRevProps => "atomic-revprops",
Self::InheritedProps => "inherited-props",
Self::LogRevProps => "log-revprops",
Self::PartialReplay => "partial-replay",
Self::EphemeralTxnProps => "ephemeral-txnprops",
Self::GetFileRevsReverse => "get-file-revs-reverse",
Self::List => "list",
}
}
}