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

Method view_log_up_to

atomic-cli/src/commands/git/import.rs:413–450  ·  view source on GitHub ↗

The first view whose effective log holds `hash`, with that log's prefix up to and including it (root to leaf). The checkpoint view the shim names is searched first.

(
        &self,
        repo: &Repository,
        hash: &atomic_core::types::Hash,
    )

Source from the content-addressed store, hash-verified

411 /// prefix up to and including it (root to leaf). The checkpoint view the
412 /// shim names is searched first.
413 fn view_log_up_to(
414 &self,
415 repo: &Repository,
416 hash: &atomic_core::types::Hash,
417 ) -> CliResult<Option<(String, Vec<atomic_core::types::Hash>)>> {
418 let mut candidates: Vec<String> = Vec::new();
419 candidates.extend(self.seed_source_view.iter().cloned());
420 for view in repo.list_views().map_err(CliError::from)? {
421 if !candidates.contains(&view) {
422 candidates.push(view);
423 }
424 }
425 for view in candidates {
426 if !repo.view_exists(&view).map_err(CliError::from)? {
427 continue;
428 }
429 let entries = repo
430 .effective_history(Some(&view))
431 .map_err(CliError::from)?;
432 if let Some(position) = entries.iter().position(|entry| entry.hash == *hash) {
433 let mut prefix: Vec<atomic_core::types::Hash> = entries[..=position]
434 .iter()
435 .map(|entry| entry.hash)
436 .collect();
437 // The view's Atomic-private members (the initialization change
438 // tracking `.atomicignore`) may sit after the ancestor's change
439 // in the log; without them the new view reports those files
440 // untracked.
441 for member in super::shim::atomic_private_members(repo, &view)? {
442 if !prefix.contains(&member) {
443 prefix.push(member);
444 }
445 }
446 return Ok(Some((view, prefix)));
447 }
448 }
449 Ok(None)
450 }
451
452 /// Get repository name from remote URL or working directory.
453 fn get_repo_name(&self, git_repo: &GitRepository) -> String {

Calls 10

atomic_private_membersFunction · 0.85
extendMethod · 0.80
view_existsMethod · 0.80
effective_historyMethod · 0.80
iterMethod · 0.45
list_viewsMethod · 0.45
containsMethod · 0.45
pushMethod · 0.45
positionMethod · 0.45
collectMethod · 0.45

Tested by

no test coverage detected