##// END OF EJS Templates
dirstate-tree: Add add_file, remove_file, and drop_file...
Simon Sapin -
r47877:7dfc598d default
parent child Browse files
Show More
@@ -330,28 +330,61 b' impl super::dispatch::DirstateMapMethods'
330
330
331 fn add_file(
331 fn add_file(
332 &mut self,
332 &mut self,
333 _filename: &HgPath,
333 filename: &HgPath,
334 _old_state: EntryState,
334 _old_state: EntryState,
335 _entry: DirstateEntry,
335 entry: DirstateEntry,
336 ) -> Result<(), DirstateMapError> {
336 ) -> Result<(), DirstateMapError> {
337 todo!()
337 self.add_file_node(filename, entry, None);
338 Ok(())
338 }
339 }
339
340
340 fn remove_file(
341 fn remove_file(
341 &mut self,
342 &mut self,
342 _filename: &HgPath,
343 filename: &HgPath,
343 _old_state: EntryState,
344 _old_state: EntryState,
344 _size: i32,
345 size: i32,
345 ) -> Result<(), DirstateMapError> {
346 ) -> Result<(), DirstateMapError> {
346 todo!()
347 let entry = DirstateEntry {
348 state: EntryState::Removed,
349 mode: 0,
350 size,
351 mtime: 0,
352 };
353 self.add_file_node(filename, entry, None);
354 Ok(())
347 }
355 }
348
356
349 fn drop_file(
357 fn drop_file(
350 &mut self,
358 &mut self,
351 _filename: &HgPath,
359 filename: &HgPath,
352 _old_state: EntryState,
360 _old_state: EntryState,
353 ) -> Result<bool, DirstateMapError> {
361 ) -> Result<bool, DirstateMapError> {
354 todo!()
362 if let Some(node) = Self::get_node_mut(&mut self.root, filename) {
363 let was_tracked = node.is_tracked_file();
364 let had_entry = node.entry.is_some();
365 let had_copy_source = node.copy_source.is_some();
366
367 // TODO: this leaves in the tree a "non-file" node. Should we
368 // remove the node instead, together with ancestor nodes for
369 // directories that become empty?
370 node.entry = None;
371 node.copy_source = None;
372
373 if had_entry {
374 self.nodes_with_entry_count -= 1
375 }
376 if had_copy_source {
377 self.nodes_with_copy_source_count -= 1
378 }
379 if was_tracked {
380 self.for_each_ancestor_node(filename, |node| {
381 node.tracked_descendants_count -= 1
382 })
383 }
384 Ok(had_entry)
385 } else {
386 Ok(false)
387 }
355 }
388 }
356
389
357 fn clear_ambiguous_times(&mut self, filenames: Vec<HgPathBuf>, now: i32) {
390 fn clear_ambiguous_times(&mut self, filenames: Vec<HgPathBuf>, now: i32) {
General Comments 0
You need to be logged in to leave comments. Login now