mirror of
https://github.com/martinvonz/jj.git
synced 2025-01-30 16:10:23 +00:00
annotate: inline mark_lines_from_original()
This function was short, and this change makes it clear that !.is_empty() was redundant. Duplicated doc comment is also removed. I feel the inline comment is easier to follow here.
This commit is contained in:
parent
52d842b8df
commit
db239536da
1 changed files with 8 additions and 23 deletions
|
@ -87,19 +87,6 @@ impl Source {
|
||||||
/// that line
|
/// that line
|
||||||
type OriginalLineMap = HashMap<usize, CommitId>;
|
type OriginalLineMap = HashMap<usize, CommitId>;
|
||||||
|
|
||||||
/// Once we've looked at all parents of a commit, any leftover lines must be
|
|
||||||
/// original to the current commit, so we save this information in
|
|
||||||
/// original_line_map.
|
|
||||||
fn mark_lines_from_original(
|
|
||||||
original_line_map: &mut OriginalLineMap,
|
|
||||||
commit_id: &CommitId,
|
|
||||||
commit_lines: HashMap<usize, usize>,
|
|
||||||
) {
|
|
||||||
for (_, original_line_number) in commit_lines {
|
|
||||||
original_line_map.insert(original_line_number, commit_id.clone());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Takes in an original line map and the original contents and annotates each
|
/// Takes in an original line map and the original contents and annotates each
|
||||||
/// line according to the contents of the provided OriginalLineMap
|
/// line according to the contents of the provided OriginalLineMap
|
||||||
fn convert_to_results(
|
fn convert_to_results(
|
||||||
|
@ -173,9 +160,7 @@ fn process_commits(
|
||||||
/// For a given commit, for each parent, we compare the version in the parent
|
/// For a given commit, for each parent, we compare the version in the parent
|
||||||
/// tree with the current version, updating the mappings for any lines in
|
/// tree with the current version, updating the mappings for any lines in
|
||||||
/// common. If the parent doesn't have the file, we skip it.
|
/// common. If the parent doesn't have the file, we skip it.
|
||||||
/// After iterating through all the parents, any leftover lines unmapped means
|
///
|
||||||
/// that those lines are original in the current commit. In that case,
|
|
||||||
/// original_line_map is updated for the leftover lines.
|
|
||||||
/// We return the lines that are the same in the child commit and
|
/// We return the lines that are the same in the child commit and
|
||||||
/// any parent. Namely, if line x is found in parent Y, we record the mapping
|
/// any parent. Namely, if line x is found in parent Y, we record the mapping
|
||||||
/// that parent Y has line x. The line mappings for all parents are returned
|
/// that parent Y has line x. The line mappings for all parents are returned
|
||||||
|
@ -183,7 +168,7 @@ fn process_commits(
|
||||||
fn process_commit(
|
fn process_commit(
|
||||||
repo: &dyn Repo,
|
repo: &dyn Repo,
|
||||||
file_name: &RepoPath,
|
file_name: &RepoPath,
|
||||||
original_line_map: &mut HashMap<usize, CommitId>,
|
original_line_map: &mut OriginalLineMap,
|
||||||
commit_source_map: &mut CommitSourceMap,
|
commit_source_map: &mut CommitSourceMap,
|
||||||
current_commit_id: &CommitId,
|
current_commit_id: &CommitId,
|
||||||
edges: &[GraphEdge<CommitId>],
|
edges: &[GraphEdge<CommitId>],
|
||||||
|
@ -220,12 +205,12 @@ fn process_commit(
|
||||||
commit_source_map.remove(parent_commit_id);
|
commit_source_map.remove(parent_commit_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !current_source.line_map.is_empty() {
|
|
||||||
mark_lines_from_original(
|
// Once we've looked at all parents of a commit, any leftover lines must be
|
||||||
original_line_map,
|
// original to the current commit, so we save this information in
|
||||||
current_commit_id,
|
// original_line_map.
|
||||||
current_source.line_map,
|
for &original_line_number in current_source.line_map.values() {
|
||||||
);
|
original_line_map.insert(original_line_number, current_commit_id.clone());
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
Loading…
Reference in a new issue