Changeset View
Changeset View
Standalone View
Standalone View
rust/hg-core/src/copy_tracing.rs
Show All 10 Lines | |||||
use std::collections::HashMap; | use std::collections::HashMap; | ||||
use std::collections::HashSet; | use std::collections::HashSet; | ||||
use std::convert::TryInto; | use std::convert::TryInto; | ||||
pub type PathCopies = HashMap<HgPathBuf, HgPathBuf>; | pub type PathCopies = HashMap<HgPathBuf, HgPathBuf>; | ||||
type PathToken = usize; | type PathToken = usize; | ||||
#[derive(Clone, Debug, PartialEq)] | #[derive(Clone, Debug)] | ||||
struct CopySource { | struct CopySource { | ||||
/// revision at which the copy information was added | /// revision at which the copy information was added | ||||
rev: Revision, | rev: Revision, | ||||
/// the copy source, (Set to None in case of deletion of the associated | /// the copy source, (Set to None in case of deletion of the associated | ||||
/// key) | /// key) | ||||
path: Option<PathToken>, | path: Option<PathToken>, | ||||
/// a set of previous `CopySource.rev` value directly or indirectly | /// a set of previous `CopySource.rev` value directly or indirectly | ||||
/// overwritten by this one. | /// overwritten by this one. | ||||
▲ Show 20 Lines • Show All 60 Lines • ▼ Show 20 Line(s) | fn mark_delete_with_pair(&mut self, rev: Revision, other: &Self) { | ||||
self.path = None; | self.path = None; | ||||
} | } | ||||
fn is_overwritten_by(&self, other: &Self) -> bool { | fn is_overwritten_by(&self, other: &Self) -> bool { | ||||
other.overwritten.contains(&self.rev) | other.overwritten.contains(&self.rev) | ||||
} | } | ||||
} | } | ||||
// For the same "dest", content generated for a given revision will always be | |||||
// the same. | |||||
impl PartialEq for CopySource { | |||||
fn eq(&self, other: &Self) -> bool { | |||||
#[cfg(debug_assertions)] | |||||
{ | |||||
if self.rev == other.rev { | |||||
debug_assert!(self.path == other.path); | |||||
debug_assert!(self.overwritten == other.overwritten); | |||||
} | |||||
} | |||||
self.rev == other.rev | |||||
} | |||||
} | |||||
/// maps CopyDestination to Copy Source (+ a "timestamp" for the operation) | /// maps CopyDestination to Copy Source (+ a "timestamp" for the operation) | ||||
type InternalPathCopies = OrdMap<PathToken, CopySource>; | type InternalPathCopies = OrdMap<PathToken, CopySource>; | ||||
/// hold parent 1, parent 2 and relevant files actions. | /// hold parent 1, parent 2 and relevant files actions. | ||||
pub type RevInfo<'a> = (Revision, Revision, ChangedFiles<'a>); | pub type RevInfo<'a> = (Revision, Revision, ChangedFiles<'a>); | ||||
/// represent the files affected by a changesets | /// represent the files affected by a changesets | ||||
/// | /// | ||||
▲ Show 20 Lines • Show All 829 Lines • Show Last 20 Lines |