##// END OF EJS Templates
rust-dirstatemap: add `set_tracked` method...
Raphaël Gomès -
r49988:791430b0 default
parent child Browse files
Show More
@@ -367,6 +367,10 b' impl DirstateEntry {'
367 Self::from_v1_data(EntryState::Removed, 0, size, 0)
367 Self::from_v1_data(EntryState::Removed, 0, size, 0)
368 }
368 }
369
369
370 pub fn new_tracked() -> Self {
371 Self::from_v2_data(true, false, false, None, None, None, None)
372 }
373
370 pub fn tracked(&self) -> bool {
374 pub fn tracked(&self) -> bool {
371 self.flags.contains(Flags::WDIR_TRACKED)
375 self.flags.contains(Flags::WDIR_TRACKED)
372 }
376 }
@@ -606,6 +606,52 b" impl<'on_disk> DirstateMap<'on_disk> {"
606 }
606 }
607 }
607 }
608
608
609 fn set_tracked(
610 &mut self,
611 filename: &HgPath,
612 old_entry_opt: Option<DirstateEntry>,
613 ) -> Result<bool, DirstateV2ParseError> {
614 let was_tracked = old_entry_opt.map_or(false, |e| e.tracked());
615 let had_entry = old_entry_opt.is_some();
616 let tracked_count_increment = if was_tracked { 0 } else { 1 };
617 let mut new = false;
618
619 let node = Self::get_or_insert_node(
620 self.on_disk,
621 &mut self.unreachable_bytes,
622 &mut self.root,
623 filename,
624 WithBasename::to_cow_owned,
625 |ancestor| {
626 if !had_entry {
627 ancestor.descendants_with_entry_count += 1;
628 }
629
630 ancestor.tracked_descendants_count += tracked_count_increment;
631 },
632 )?;
633 let new_entry = if let Some(old_entry) = old_entry_opt {
634 let mut e = old_entry.clone();
635 if e.tracked() {
636 // XXX
637 // This is probably overkill for more case, but we need this to
638 // fully replace the `normallookup` call with `set_tracked`
639 // one. Consider smoothing this in the future.
640 e.set_possibly_dirty();
641 } else {
642 new = true;
643 e.set_tracked();
644 }
645 e
646 } else {
647 self.nodes_with_entry_count += 1;
648 new = true;
649 DirstateEntry::new_tracked()
650 };
651 node.data = NodeData::Entry(new_entry);
652 Ok(new)
653 }
654
609 fn add_or_remove_file(
655 fn add_or_remove_file(
610 &mut self,
656 &mut self,
611 path: &HgPath,
657 path: &HgPath,
@@ -758,6 +804,14 b' impl OwningDirstateMap {'
758 })
804 })
759 }
805 }
760
806
807 pub fn set_tracked(
808 &mut self,
809 filename: &HgPath,
810 ) -> Result<bool, DirstateV2ParseError> {
811 let old_entry_opt = self.get(filename)?;
812 self.with_dmap_mut(|map| map.set_tracked(filename, old_entry_opt))
813 }
814
761 pub fn remove_file(
815 pub fn remove_file(
762 &mut self,
816 &mut self,
763 filename: &HgPath,
817 filename: &HgPath,
General Comments 0
You need to be logged in to leave comments. Login now