Skip to content

Commit

Permalink
annotate: rename AnnotateResults to FileAnnotation
Browse files Browse the repository at this point in the history
The name "Results" was a bit misleading because Result<T, E> aliases are often
called FooResult.
  • Loading branch information
yuja committed Oct 29, 2024
1 parent ab10b7c commit e464c0e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
12 changes: 6 additions & 6 deletions cli/src/commands/file/annotate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
// limitations under the License.

use jj_lib::annotate::get_annotation_for_file;
use jj_lib::annotate::AnnotateResults;
use jj_lib::annotate::FileAnnotation;
use jj_lib::commit::Commit;
use jj_lib::repo::Repo;
use tracing::instrument;
Expand Down Expand Up @@ -69,21 +69,21 @@ pub(crate) fn cmd_file_annotate(
.get_string("templates.annotate_commit_summary")?;
let template = workspace_command.parse_commit_template(ui, &annotate_commit_summary_text)?;

let annotations = get_annotation_for_file(repo.as_ref(), &starting_commit, &file_path)?;
let annotation = get_annotation_for_file(repo.as_ref(), &starting_commit, &file_path)?;

render_annotations(repo.as_ref(), ui, &template, &annotations)?;
render_file_annotation(repo.as_ref(), ui, &template, &annotation)?;
Ok(())
}

fn render_annotations(
fn render_file_annotation(
repo: &dyn Repo,
ui: &mut Ui,
template_render: &TemplateRenderer<Commit>,
results: &AnnotateResults,
annotation: &FileAnnotation,
) -> Result<(), CommandError> {
ui.request_pager();
let mut formatter = ui.stdout_formatter();
for (line_no, (commit_id, line)) in results.lines().enumerate() {
for (line_no, (commit_id, line)) in annotation.lines().enumerate() {
let commit = repo.store().get_commit(commit_id)?;
template_render.format(&commit, formatter.as_mut())?;
write!(formatter, " {:>4}: ", line_no + 1)?;
Expand Down
8 changes: 4 additions & 4 deletions lib/src/annotate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@ use crate::store::Store;

/// Annotation results for a specific file
#[derive(Clone, Debug)]
pub struct AnnotateResults {
pub struct FileAnnotation {
line_map: OriginalLineMap,
text: BString,
}

impl AnnotateResults {
impl FileAnnotation {
/// Returns iterator over `(commit_id, line)`s.
///
/// For each line, the `commit_id` points to the originator commit of the
Expand Down Expand Up @@ -107,12 +107,12 @@ pub fn get_annotation_for_file(
repo: &dyn Repo,
starting_commit: &Commit,
file_path: &RepoPath,
) -> Result<AnnotateResults, RevsetEvaluationError> {
) -> Result<FileAnnotation, RevsetEvaluationError> {
let mut source = Source::load(starting_commit, file_path)?;
source.fill_line_map();
let text = source.text.clone();
let line_map = process_commits(repo, starting_commit.id(), source, file_path)?;
Ok(AnnotateResults { line_map, text })
Ok(FileAnnotation { line_map, text })
}

/// Starting at the starting commit, compute changes at that commit relative to
Expand Down

0 comments on commit e464c0e

Please sign in to comment.