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

Method ancestry_of

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

Complete Git ancestry of `sha` (the commit itself and every transitive parent), memoized. The walk uses the live Git object database, so it stays exact across batch boundaries and incremental imports.

(
        &mut self,
        git: &GitRepository,
        sha: &str,
    )

Source from the content-addressed store, hash-verified

830 /// database, so it stays exact across batch boundaries and incremental
831 /// imports.
832 fn ancestry_of(
833 &mut self,
834 git: &GitRepository,
835 sha: &str,
836 ) -> CliResult<std::sync::Arc<HashSet<String>>> {
837 if let Some(cached) = self.ancestry.get(sha) {
838 return Ok(cached.clone());
839 }
840 let oid = git2::Oid::from_str(sha)
841 .map_err(|e| git_error(format!("cannot parse commit oid '{sha}': {e}")))?;
842 let commit = git.find_commit(oid).map_err(|e| CliError::GitError {
843 message: format!("cannot read commit {sha} for ancestry: {e}"),
844 })?;
845 let mut set: HashSet<String> = HashSet::new();
846 set.insert(sha.to_string());
847 for parent in commit.parent_ids() {
848 let parent_ancestry = self.ancestry_of(git, &parent.to_string())?;
849 set.extend(parent_ancestry.iter().cloned());
850 }
851 let shared = std::sync::Arc::new(set);
852 self.ancestry.insert(sha.to_string(), shared.clone());
853 Ok(shared)
854 }
855
856 /// The complete interpreted closure of one Git commit (CB-9B review R1):
857 /// every Atomic change whose content makes up the commit's interpreted

Callers 5

interpreted_closureMethod · 0.80
exclusions_forMethod · 0.80
phase2_writeMethod · 0.80

Calls 6

extendMethod · 0.80
git_errorFunction · 0.70
getMethod · 0.65
cloneMethod · 0.45
insertMethod · 0.45
iterMethod · 0.45

Tested by

no test coverage detected