Details
Details
Diff Detail
Diff Detail
- Repository
- rHG Mercurial
- Branch
- default
- Lint
No Linters Available - Unit
No Unit Test Coverage
( )
No Linters Available |
No Unit Test Coverage |
Path | Packages | |||
---|---|---|---|---|
M | rust/hg-core/src/dirstate_tree/dirstate_map.rs (36 lines) | |||
M | rust/hg-core/src/utils/hg_path.rs (5 lines) |
Commit | Parents | Author | Summary | Date |
---|---|---|---|---|
eae24101ea28 | 3c3a92f6c885 | Simon Sapin | Apr 6 2021, 8:35 AM |
Status | Author | Revision | |
---|---|---|---|
Closed | SimonSapin | ||
Closed | SimonSapin | ||
Closed | SimonSapin | ||
Closed | SimonSapin | ||
Closed | SimonSapin | ||
Closed | SimonSapin | ||
Closed | SimonSapin | ||
Closed | SimonSapin | ||
Closed | SimonSapin | ||
Closed | SimonSapin | ||
Closed | SimonSapin | ||
Closed | SimonSapin | ||
Closed | SimonSapin | ||
Closed | SimonSapin | ||
Closed | SimonSapin | ||
Closed | SimonSapin | ||
Closed | SimonSapin | ||
Closed | SimonSapin | ||
Closed | SimonSapin | ||
Closed | SimonSapin | ||
Closed | SimonSapin | ||
Closed | SimonSapin | ||
Closed | SimonSapin | ||
Closed | SimonSapin | ||
Closed | SimonSapin | ||
Closed | SimonSapin | ||
Closed | SimonSapin | ||
Closed | SimonSapin | ||
Closed | SimonSapin | ||
Closed | SimonSapin | ||
Abandoned | SimonSapin | ||
Closed | SimonSapin | ||
Closed | SimonSapin | ||
Closed | SimonSapin | ||
Closed | SimonSapin |
pub fn new() -> Self { | pub fn new() -> Self { | ||||
Self { | Self { | ||||
parents: None, | parents: None, | ||||
dirty_parents: false, | dirty_parents: false, | ||||
root: ChildNodes::new(), | root: ChildNodes::new(), | ||||
} | } | ||||
} | } | ||||
fn get_node(&self, path: &HgPath) -> Option<&Node> { | |||||
let mut children = &self.root; | |||||
let mut components = path.components(); | |||||
let mut component = | |||||
components.next().expect("expected at least one components"); | |||||
loop { | |||||
let child = children.get(component)?; | |||||
if let Some(next_component) = components.next() { | |||||
component = next_component; | |||||
children = &child.children; | |||||
} else { | |||||
return Some(child); | |||||
} | |||||
} | |||||
} | |||||
fn get_or_insert_node(&mut self, path: &HgPath) -> &mut Node { | fn get_or_insert_node(&mut self, path: &HgPath) -> &mut Node { | ||||
let mut child_nodes = &mut self.root; | let mut child_nodes = &mut self.root; | ||||
let mut inclusive_ancestor_paths = | let mut inclusive_ancestor_paths = | ||||
WithBasename::inclusive_ancestors_of(path); | WithBasename::inclusive_ancestors_of(path); | ||||
let mut ancestor_path = inclusive_ancestor_paths | let mut ancestor_path = inclusive_ancestor_paths | ||||
.next() | .next() | ||||
.expect("expected at least one inclusive ancestor"); | .expect("expected at least one inclusive ancestor"); | ||||
loop { | loop { | ||||
fn copy_map_len(&self) -> usize { | fn copy_map_len(&self) -> usize { | ||||
todo!() | todo!() | ||||
} | } | ||||
fn copy_map_iter(&self) -> CopyMapIter<'_> { | fn copy_map_iter(&self) -> CopyMapIter<'_> { | ||||
todo!() | todo!() | ||||
} | } | ||||
fn copy_map_contains_key(&self, _key: &HgPath) -> bool { | fn copy_map_contains_key(&self, key: &HgPath) -> bool { | ||||
todo!() | if let Some(node) = self.get_node(key) { | ||||
node.copy_source.is_some() | |||||
} else { | |||||
false | |||||
} | |||||
} | } | ||||
fn copy_map_get(&self, _key: &HgPath) -> Option<&HgPathBuf> { | fn copy_map_get(&self, key: &HgPath) -> Option<&HgPathBuf> { | ||||
todo!() | self.get_node(key)?.copy_source.as_ref() | ||||
} | } | ||||
fn copy_map_remove(&mut self, _key: &HgPath) -> Option<HgPathBuf> { | fn copy_map_remove(&mut self, _key: &HgPath) -> Option<HgPathBuf> { | ||||
todo!() | todo!() | ||||
} | } | ||||
fn copy_map_insert( | fn copy_map_insert( | ||||
&mut self, | &mut self, | ||||
_key: HgPathBuf, | _key: HgPathBuf, | ||||
_value: HgPathBuf, | _value: HgPathBuf, | ||||
) -> Option<HgPathBuf> { | ) -> Option<HgPathBuf> { | ||||
todo!() | todo!() | ||||
} | } | ||||
fn len(&self) -> usize { | fn len(&self) -> usize { | ||||
todo!() | todo!() | ||||
} | } | ||||
fn contains_key(&self, _key: &HgPath) -> bool { | fn contains_key(&self, key: &HgPath) -> bool { | ||||
todo!() | self.get(key).is_some() | ||||
} | } | ||||
fn get(&self, _key: &HgPath) -> Option<&DirstateEntry> { | fn get(&self, key: &HgPath) -> Option<&DirstateEntry> { | ||||
todo!() | self.get_node(key)?.entry.as_ref() | ||||
} | } | ||||
fn iter(&self) -> StateMapIter<'_> { | fn iter(&self) -> StateMapIter<'_> { | ||||
todo!() | todo!() | ||||
} | } | ||||
} | } |
pub fn join<T: ?Sized + AsRef<Self>>(&self, other: &T) -> HgPathBuf { | pub fn join<T: ?Sized + AsRef<Self>>(&self, other: &T) -> HgPathBuf { | ||||
let mut inner = self.inner.to_owned(); | let mut inner = self.inner.to_owned(); | ||||
if !inner.is_empty() && inner.last() != Some(&b'/') { | if !inner.is_empty() && inner.last() != Some(&b'/') { | ||||
inner.push(b'/'); | inner.push(b'/'); | ||||
} | } | ||||
inner.extend(other.as_ref().bytes()); | inner.extend(other.as_ref().bytes()); | ||||
HgPathBuf::from_bytes(&inner) | HgPathBuf::from_bytes(&inner) | ||||
} | } | ||||
pub fn components(&self) -> impl Iterator<Item = &HgPath> { | |||||
self.inner.split(|&byte| byte == b'/').map(HgPath::new) | |||||
} | |||||
pub fn parent(&self) -> &Self { | pub fn parent(&self) -> &Self { | ||||
let inner = self.as_bytes(); | let inner = self.as_bytes(); | ||||
HgPath::new(match inner.iter().rposition(|b| *b == b'/') { | HgPath::new(match inner.iter().rposition(|b| *b == b'/') { | ||||
Some(pos) => &inner[..pos], | Some(pos) => &inner[..pos], | ||||
None => &[], | None => &[], | ||||
}) | }) | ||||
} | } | ||||
/// Given a base directory, returns the slice of `self` relative to the | /// Given a base directory, returns the slice of `self` relative to the |