Show More
@@ -52,6 +52,22 b' impl DirstateMap {' | |||||
52 | } |
|
52 | } | |
53 | } |
|
53 | } | |
54 |
|
54 | |||
|
55 | fn get_node(&self, path: &HgPath) -> Option<&Node> { | |||
|
56 | let mut children = &self.root; | |||
|
57 | let mut components = path.components(); | |||
|
58 | let mut component = | |||
|
59 | components.next().expect("expected at least one components"); | |||
|
60 | loop { | |||
|
61 | let child = children.get(component)?; | |||
|
62 | if let Some(next_component) = components.next() { | |||
|
63 | component = next_component; | |||
|
64 | children = &child.children; | |||
|
65 | } else { | |||
|
66 | return Some(child); | |||
|
67 | } | |||
|
68 | } | |||
|
69 | } | |||
|
70 | ||||
55 | fn get_or_insert_node(&mut self, path: &HgPath) -> &mut Node { |
|
71 | fn get_or_insert_node(&mut self, path: &HgPath) -> &mut Node { | |
56 | let mut child_nodes = &mut self.root; |
|
72 | let mut child_nodes = &mut self.root; | |
57 | let mut inclusive_ancestor_paths = |
|
73 | let mut inclusive_ancestor_paths = | |
@@ -265,12 +281,16 b' impl super::dispatch::DirstateMapMethods' | |||||
265 | todo!() |
|
281 | todo!() | |
266 | } |
|
282 | } | |
267 |
|
283 | |||
268 |
fn copy_map_contains_key(&self, |
|
284 | fn copy_map_contains_key(&self, key: &HgPath) -> bool { | |
269 | todo!() |
|
285 | if let Some(node) = self.get_node(key) { | |
|
286 | node.copy_source.is_some() | |||
|
287 | } else { | |||
|
288 | false | |||
|
289 | } | |||
270 | } |
|
290 | } | |
271 |
|
291 | |||
272 |
fn copy_map_get(&self, |
|
292 | fn copy_map_get(&self, key: &HgPath) -> Option<&HgPathBuf> { | |
273 | todo!() |
|
293 | self.get_node(key)?.copy_source.as_ref() | |
274 | } |
|
294 | } | |
275 |
|
295 | |||
276 | fn copy_map_remove(&mut self, _key: &HgPath) -> Option<HgPathBuf> { |
|
296 | fn copy_map_remove(&mut self, _key: &HgPath) -> Option<HgPathBuf> { | |
@@ -289,12 +309,12 b' impl super::dispatch::DirstateMapMethods' | |||||
289 | todo!() |
|
309 | todo!() | |
290 | } |
|
310 | } | |
291 |
|
311 | |||
292 |
fn contains_key(&self, |
|
312 | fn contains_key(&self, key: &HgPath) -> bool { | |
293 | todo!() |
|
313 | self.get(key).is_some() | |
294 | } |
|
314 | } | |
295 |
|
315 | |||
296 |
fn get(&self, |
|
316 | fn get(&self, key: &HgPath) -> Option<&DirstateEntry> { | |
297 | todo!() |
|
317 | self.get_node(key)?.entry.as_ref() | |
298 | } |
|
318 | } | |
299 |
|
319 | |||
300 | fn iter(&self) -> StateMapIter<'_> { |
|
320 | fn iter(&self) -> StateMapIter<'_> { |
@@ -226,6 +226,11 b' impl HgPath {' | |||||
226 | inner.extend(other.as_ref().bytes()); |
|
226 | inner.extend(other.as_ref().bytes()); | |
227 | HgPathBuf::from_bytes(&inner) |
|
227 | HgPathBuf::from_bytes(&inner) | |
228 | } |
|
228 | } | |
|
229 | ||||
|
230 | pub fn components(&self) -> impl Iterator<Item = &HgPath> { | |||
|
231 | self.inner.split(|&byte| byte == b'/').map(HgPath::new) | |||
|
232 | } | |||
|
233 | ||||
229 | pub fn parent(&self) -> &Self { |
|
234 | pub fn parent(&self) -> &Self { | |
230 | let inner = self.as_bytes(); |
|
235 | let inner = self.as_bytes(); | |
231 | HgPath::new(match inner.iter().rposition(|b| *b == b'/') { |
|
236 | HgPath::new(match inner.iter().rposition(|b| *b == b'/') { |
General Comments 0
You need to be logged in to leave comments.
Login now