602 child_nodes = &mut child_node.children; |
602 child_nodes = &mut child_node.children; |
603 } else { |
603 } else { |
604 return Ok(child_node); |
604 return Ok(child_node); |
605 } |
605 } |
606 } |
606 } |
|
607 } |
|
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) |
607 } |
653 } |
608 |
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, |
756 self.with_dmap_mut(|map| { |
802 self.with_dmap_mut(|map| { |
757 Ok(map.add_or_remove_file(filename, old_state, entry)?) |
803 Ok(map.add_or_remove_file(filename, old_state, entry)?) |
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, |
764 in_merge: bool, |
818 in_merge: bool, |
765 ) -> Result<(), DirstateError> { |
819 ) -> Result<(), DirstateError> { |