MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / triage_candidate_set

Method triage_candidate_set

atomic-repository/src/repository/triage.rs:79–170  ·  view source on GitHub ↗

Compute the triage candidate set for `feature` relative to `target`. See the module documentation for the semantics of each field. # Errors Returns [`RepositoryError::ViewNotFound`] if either view does not exist, or [`RepositoryError::Database`] on any pristine access failure.

(
        &self,
        feature: &str,
        target: &str,
    )

Source from the content-addressed store, hash-verified

77 /// Returns [`RepositoryError::ViewNotFound`] if either view does not exist,
78 /// or [`RepositoryError::Database`] on any pristine access failure.
79 pub fn triage_candidate_set(
80 &self,
81 feature: &str,
82 target: &str,
83 ) -> Result<CandidateSet, RepositoryError> {
84 // Step 1: the raw change-level diff. `.0` is only-in-feature.
85 let (only_in_feature_hashes, _only_in_target, _common) =
86 self.diff_views(feature, target)?;
87
88 let txn = self
89 .pristine
90 .read_txn()
91 .map_err(|e| RepositoryError::Database(e.to_string()))?;
92
93 // The target view's full visible set (with dependency closure). Any
94 // closure addition already visible to the target is not an "addition".
95 let target_view = txn
96 .get_view(target)
97 .map_err(|e| RepositoryError::Database(e.to_string()))?
98 .ok_or_else(|| RepositoryError::ViewNotFound {
99 name: target.to_string(),
100 })?;
101 let target_visible = graph_visibility_closure(&txn, &target_view)?;
102
103 // Seed the closure with the only-in-feature node ids, remembering the
104 // seed set so we can subtract it from the additions later.
105 let mut feature_node_ids = Vec::new();
106 for hash in &only_in_feature_hashes {
107 let id = txn
108 .get_internal(hash)
109 .map_err(|e| RepositoryError::Database(e.to_string()))?
110 .ok_or_else(|| RepositoryError::ChangeNotFound {
111 hash: hash.to_base32(),
112 })?;
113 feature_node_ids.push(id);
114 }
115 let feature_membership = ViewMembershipSet::from_ordered(feature_node_ids);
116
117 // Step 2: validate and complete the transitive dependency closure.
118 let closure = graph_visibility_from_membership(&txn, &feature_membership)?;
119
120 // Closure additions = closure minus the seed minus the target's set.
121 let mut addition_hashes: Vec<Hash> = Vec::new();
122 for id in closure.iter_dependency_first().copied() {
123 if feature_membership.contains(id) || target_visible.contains(id) {
124 continue;
125 }
126 let hash = txn
127 .get_external(id)
128 .map_err(|e| RepositoryError::Database(e.to_string()))?
129 .ok_or_else(|| {
130 RepositoryError::Database(format!(
131 "validated closure change {} has no external hash",
132 id.get()
133 ))
134 })?;
135 addition_hashes.push(hash);
136 }

Calls 15

graph_visibility_closureFunction · 0.85
diff_viewsMethod · 0.80
read_txnMethod · 0.80
iter_dependency_firstMethod · 0.80
sortMethod · 0.80
change_coverageMethod · 0.80
get_viewMethod · 0.45
get_internalMethod · 0.45
to_base32Method · 0.45
pushMethod · 0.45
containsMethod · 0.45