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

Method run

atomic-cli/src/commands/blame.rs:47–299  ·  view source on GitHub ↗
(&self)

Source from the content-addressed store, hash-verified

45
46impl Command for Blame {
47 fn run(&self) -> CliResult<()> {
48 let repo_root = find_repository_root()?;
49 let repo =
50 Repository::open_readonly(&repo_root).map_err(|e| CliError::InvalidRepository {
51 reason: e.to_string(),
52 })?;
53 let working_copy = repo
54 .require_working_copy_id()
55 .map_err(CliError::Repository)?;
56 let view = repo
57 .desired_view_name(working_copy)
58 .map_err(CliError::Repository)?;
59
60 let txn = repo
61 .pristine()
62 .read_txn()
63 .map_err(|e| CliError::Repository(e.into()))?;
64 let view_state = txn
65 .get_view(&view)
66 .map_err(|e| CliError::Repository(e.into()))?
67 .ok_or_else(|| CliError::InvalidRepository {
68 reason: format!("view '{view}' not found"),
69 })?;
70 let mut changes: HashMap<Hash, Change> = HashMap::new();
71 let mut lines: Vec<LineAttribution> = Vec::new();
72 let mut skipped_unbound = 0usize;
73
74 // Span histories imported from Git deliberately have no historical
75 // CRDT rows. Interpret their verified visible bytes directly instead
76 // of attributing them to a later native edit. A line can contain bytes
77 // from several changes, in which case every owner remains visible.
78 use atomic_core::pristine::{CapabilityTxnT, SPAN_RANGE_CAPABILITY};
79 let span_enabled = txn
80 .required_capability_version(SPAN_RANGE_CAPABILITY.id())
81 .map_err(|e| CliError::Repository(e.into()))?
82 .is_some();
83 let mut span_handled = false;
84 if span_enabled {
85 use atomic_core::pristine::span_patch_storage::{SpanPatchReadTxn, SpanRenderContext};
86 if self.path.as_bytes().contains(&b'%') {
87 return Err(CliError::InvalidArgument {
88 message: "span blame cannot safely resolve percent-bearing paths yet".into(),
89 });
90 }
91 let visibility = atomic_repository::graph_visibility_closure(&txn, &view_state)
92 .map_err(CliError::Repository)?;
93 let binding = repo
94 .projected_path_binding_for_visibility(&txn, &visibility, &self.path)
95 .map_err(CliError::Repository)?
96 .ok_or_else(|| CliError::InvalidArgument {
97 message: format!("'{}' is absent or conflicted on view '{}'", self.path, view),
98 })?;
99 if !binding.directory
100 && txn
101 .span_root(binding.inode)
102 .map_err(|error| CliError::InvalidArgument {
103 message: error.to_string(),
104 })?

Callers

nothing calls this directly

Calls 15

find_repository_rootFunction · 0.85
RepositoryClass · 0.85
graph_visibility_closureFunction · 0.85
project_inode_attributesFunction · 0.85
decode_branch_idFunction · 0.85
print_warningFunction · 0.85
stdoutFunction · 0.85
desired_view_nameMethod · 0.80
read_txnMethod · 0.80
pristineMethod · 0.80

Tested by

no test coverage detected