MCPcopy Index your code
hub / github.com/emwalker/digraph / handle_cycle

Method handle_cycle

backend/src/git/topic.rs:687–724  ·  view source on GitHub ↗
(
        &self,
        mutation: Mutation,
        topic_id: &ExternalId,
        parent: RepoTopic,
        mut matches: BTreeSet<SynonymMatch>,
    )

Source from the content-addressed store, hash-verified

685 }
686
687 fn handle_cycle(
688 &self,
689 mutation: Mutation,
690 topic_id: &ExternalId,
691 parent: RepoTopic,
692 mut matches: BTreeSet<SynonymMatch>,
693 ) -> Result<UpsertTopicResult> {
694 let ancestor = mutation.fetch_topic(self.repo_id, topic_id);
695 if ancestor.is_none() {
696 return Err(Error::NotFound(format!("not found: {topic_id}")));
697 }
698 let ancestor = ancestor.unwrap();
699
700 log::info!("a cycle was found");
701 let alerts = vec![Alert::Warning(format!(
702 "{} is a subtopic of {}",
703 &parent.name(Locale::EN),
704 &ancestor.name(Locale::EN),
705 ))];
706
707 matches.replace(SynonymMatch {
708 cycle: true,
709 entry: SynonymEntry {
710 name: self.name.to_owned(),
711 id: topic_id.to_owned(),
712 },
713 name: self.name.to_owned(),
714 repo_id: self.repo_id,
715 repo_topic: ancestor,
716 });
717
718 Ok(UpsertTopicResult {
719 alerts,
720 matching_repo_topics: matches,
721 repo_topic: None,
722 saved: false,
723 })
724 }
725
726 fn change(
727 &self,

Callers 1

update_repo_topicMethod · 0.80

Calls 1

fetch_topicMethod · 0.45

Tested by

no test coverage detected