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

Method supersede_exclusions_for

atomic-cli/src/commands/git/parallel.rs:995–1031  ·  view source on GitHub ↗

The genuinely replaced history among `sha`'s assembly exclusions: excluded view members whose Git origin is ALSO outside this import's full target closure. These — and only these — may leave the target view when `sha` lands. An assembly exclusion whose origin IS inside the target closure is a sibling leg of the same import target: the walk reaches it (or the merge that reunifies the legs) later,

(
        &mut self,
        repo: &Repository,
        git: &GitRepository,
        sha: &str,
        target_view: &str,
        has_git_parent: bool,
    )

Source from the content-addressed store, hash-verified

993 /// import after a force-push rewrite): evicting them keeps the published
994 /// boundary equal to the commit's interpreted closure.
995 fn supersede_exclusions_for(
996 &mut self,
997 repo: &Repository,
998 git: &GitRepository,
999 sha: &str,
1000 target_view: &str,
1001 has_git_parent: bool,
1002 ) -> CliResult<Vec<ContentHash>> {
1003 let assembly = self.exclusions_for(repo, git, sha, target_view, has_git_parent)?;
1004 if assembly.is_empty() {
1005 return Ok(Vec::new());
1006 }
1007 // Clone the Arc before the mutable `origins_for` call: no borrow of
1008 // `self` may outlive it.
1009 let target = match self.target_closure.clone() {
1010 Some(target) => target,
1011 // No target closure known: the historical behavior (evict every
1012 // assembly exclusion) stays fail-safe for callers that never
1013 // establish the walk's target.
1014 None => return Ok(assembly),
1015 };
1016 let mut origins: HashMap<ContentHash, Option<String>> = HashMap::new();
1017 for (hash, origin_sha) in self.origins_for(repo, target_view)? {
1018 origins.insert(hash, origin_sha);
1019 }
1020 let mut superseded = Vec::with_capacity(assembly.len());
1021 for hash in assembly {
1022 let replaced = origins
1023 .get(&hash)
1024 .and_then(|origin| origin.as_deref())
1025 .is_some_and(|origin| !target.contains(origin));
1026 if replaced {
1027 superseded.push(hash);
1028 }
1029 }
1030 Ok(superseded)
1031 }
1032
1033 /// Record that importing `sha` introduced `hash` into `target_view`.
1034 fn record_introduced(&mut self, sha: &str, hash: ContentHash, target_view: &str) {

Calls 9

exclusions_forMethod · 0.80
origins_forMethod · 0.80
getMethod · 0.65
is_emptyMethod · 0.45
cloneMethod · 0.45
insertMethod · 0.45
lenMethod · 0.45
containsMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected