forked from mirrors/jj
Use CommitIteratorExt to replace .map(|c| c.id().clone())
This replaces `.map(|c| c.id().clone())` with `.ids().cloned()` to use nicer syntax for getting `CommitId`s from an iterator of commits using the `CommitIteratorExt` trait. In one case we can actually call `.parent_ids()` directly. I also pluralized a variable to make it clearer that it's a vec of IDs and not a single ID.
This commit is contained in:
parent
449fc423b8
commit
3d267de53e
3 changed files with 6 additions and 9 deletions
|
@ -98,7 +98,7 @@ Please use `jj new 'all:x|y'` instead of `jj new --allow-large-revsets x y`.",
|
|||
.resolve_some_revsets_default_single(&args.revisions)?
|
||||
.into_iter()
|
||||
.collect_vec();
|
||||
let target_ids = target_commits.iter().map(|c| c.id().clone()).collect_vec();
|
||||
let target_ids = target_commits.iter().ids().cloned().collect_vec();
|
||||
let mut tx = workspace_command.start_transaction();
|
||||
let mut num_rebased;
|
||||
let new_commit;
|
||||
|
@ -128,10 +128,10 @@ Please use `jj new 'all:x|y'` instead of `jj new --allow-large-revsets x y`.",
|
|||
.commits(tx.repo().store())
|
||||
.try_collect()?;
|
||||
let merged_tree = merge_commit_trees(tx.repo(), &new_parents_commits)?;
|
||||
let new_parents_commit_id = new_parents_commits.iter().map(|c| c.id().clone()).collect();
|
||||
let new_parents_commit_ids = new_parents_commits.iter().ids().cloned().collect();
|
||||
new_commit = tx
|
||||
.mut_repo()
|
||||
.new_commit(command.settings(), new_parents_commit_id, merged_tree.id())
|
||||
.new_commit(command.settings(), new_parents_commit_ids, merged_tree.id())
|
||||
.set_description(join_message_paragraphs(&args.message_paragraphs))
|
||||
.write()?;
|
||||
num_rebased = target_ids.len();
|
||||
|
|
|
@ -387,11 +387,7 @@ fn rebase_revision(
|
|||
.iter()
|
||||
.flat_map(|c| {
|
||||
if c == &old_commit {
|
||||
old_commit
|
||||
.parents()
|
||||
.iter()
|
||||
.map(|c| c.id().clone())
|
||||
.collect()
|
||||
old_commit.parent_ids().to_vec()
|
||||
} else {
|
||||
[c.id().clone()].to_vec()
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@ use std::sync::Arc;
|
|||
|
||||
use clap::Subcommand;
|
||||
use itertools::Itertools;
|
||||
use jj_lib::commit::CommitIteratorExt;
|
||||
use jj_lib::file_util;
|
||||
use jj_lib::object_id::ObjectId;
|
||||
use jj_lib::op_store::{OpStoreError, WorkspaceId};
|
||||
|
@ -209,7 +210,7 @@ fn cmd_workspace_add(
|
|||
};
|
||||
|
||||
let tree = merge_commit_trees(tx.repo(), &parents)?;
|
||||
let parent_ids = parents.iter().map(|c| c.id().clone()).collect_vec();
|
||||
let parent_ids = parents.iter().ids().cloned().collect_vec();
|
||||
let new_wc_commit = tx
|
||||
.mut_repo()
|
||||
.new_commit(command.settings(), parent_ids, tree.id())
|
||||
|
|
Loading…
Reference in a new issue