| 4034 | } |
| 4035 | |
| 4036 | fn apply_line_index_updates( |
| 4037 | line_index: &mut ImportLineIndex, |
| 4038 | change_hash: ContentHash, |
| 4039 | pending: Vec<PendingLineIndexUpdate>, |
| 4040 | ) { |
| 4041 | for update in pending { |
| 4042 | match update { |
| 4043 | PendingLineIndexUpdate::DirectoryAdd { path, inode_pos } => { |
| 4044 | line_index.directories.insert( |
| 4045 | path, |
| 4046 | Position { |
| 4047 | change: Some(change_hash), |
| 4048 | pos: inode_pos.pos, |
| 4049 | }, |
| 4050 | ); |
| 4051 | } |
| 4052 | PendingLineIndexUpdate::Add { |
| 4053 | path, |
| 4054 | inode_pos, |
| 4055 | new_ranges, |
| 4056 | new_lines, |
| 4057 | } => { |
| 4058 | let inode_pos = Position { |
| 4059 | change: Some(change_hash), |
| 4060 | pos: inode_pos.pos, |
| 4061 | }; |
| 4062 | let lines = new_ranges |
| 4063 | .iter() |
| 4064 | .zip(new_lines) |
| 4065 | .enumerate() |
| 4066 | .map(|(index, (&(start, end), content))| ImportLine { |
| 4067 | change: change_hash, |
| 4068 | start, |
| 4069 | end, |
| 4070 | incoming_by: change_hash, |
| 4071 | incoming_from: if index == 0 { |
| 4072 | inode_pos |
| 4073 | } else { |
| 4074 | Position { |
| 4075 | change: Some(change_hash), |
| 4076 | pos: new_ranges[index - 1].1, |
| 4077 | } |
| 4078 | }, |
| 4079 | content, |
| 4080 | }) |
| 4081 | .collect(); |
| 4082 | line_index.files.insert( |
| 4083 | path, |
| 4084 | ImportIndexedFile { |
| 4085 | inode_pos, |
| 4086 | lines, |
| 4087 | imported_commits: 1, |
| 4088 | }, |
| 4089 | ); |
| 4090 | } |
| 4091 | PendingLineIndexUpdate::Modify { path, replacements } => { |
| 4092 | let Some(indexed) = line_index.files.get_mut(&path) else { |
| 4093 | continue; |