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

Method update_from_added_change

atomic-cli/src/commands/git/parallel.rs:2267–2341  ·  view source on GitHub ↗
(&mut self, change_hash: ContentHash, change: &Change)

Source from the content-addressed store, hash-verified

2265
2266impl ImportLineIndex {
2267 fn update_from_added_change(&mut self, change_hash: ContentHash, change: &Change) {
2268 for graph_op in change.hunks() {
2269 match graph_op {
2270 GraphOp::FileAdd {
2271 add_inode,
2272 contents,
2273 path,
2274 ..
2275 } => {
2276 let inode_pos = Position {
2277 change: Some(change_hash),
2278 pos: add_inode.start,
2279 };
2280 let mut lines = Vec::new();
2281 if let Some(contents) = contents {
2282 lines.push(ImportLine {
2283 change: change_hash,
2284 start: contents.start,
2285 end: contents.end,
2286 incoming_by: change_hash,
2287 incoming_from: inode_pos,
2288 content: change.contents
2289 [contents.start.as_usize()..contents.end.as_usize()]
2290 .to_vec(),
2291 });
2292 }
2293 self.files.insert(
2294 path.clone(),
2295 ImportIndexedFile {
2296 inode_pos,
2297 lines,
2298 imported_commits: 1,
2299 },
2300 );
2301 }
2302 GraphOp::DirAdd {
2303 add_inode, path, ..
2304 } => {
2305 self.directories.insert(
2306 path.clone(),
2307 Position {
2308 change: Some(change_hash),
2309 pos: add_inode.start,
2310 },
2311 );
2312 }
2313 GraphOp::Edit {
2314 change: Atom::Insertion(insertion),
2315 local,
2316 ..
2317 } => {
2318 if let Some(indexed) = self.files.get_mut(&local.path) {
2319 indexed.lines.push(ImportLine {
2320 change: change_hash,
2321 start: insertion.start,
2322 end: insertion.end,
2323 incoming_by: change_hash,
2324 incoming_from: stream_position(

Callers

nothing calls this directly

Calls 7

stream_positionFunction · 0.85
as_usizeMethod · 0.80
get_mutMethod · 0.80
hunksMethod · 0.45
pushMethod · 0.45
insertMethod · 0.45
cloneMethod · 0.45

Tested by

no test coverage detected