Skip to content

Commit

Permalink
cli: deprecate jj split --siblings in favor of jj split --parallel
Browse files Browse the repository at this point in the history
This better matches `jj parallelize`.
  • Loading branch information
martinvonz committed Jun 15, 2024
1 parent 72438fc commit a9953b3
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 11 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

* Replacing `-l` shorthand for `--limit` with `-n` in `jj log`, `jj op log` and `jj obslog`.

* `jj split --siblings` is deprecated in favor of `jj split --parallel` (to
match `jj parallelize`).

### New features

* Show paths to config files when configuration errors occur
Expand Down
16 changes: 9 additions & 7 deletions cli/src/commands/split.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,11 @@ pub(crate) struct SplitArgs {
/// The revision to split
#[arg(long, short, default_value = "@")]
revision: RevisionArg,
/// Split the revision into two siblings instead of a parent and child.
#[arg(long, short)]
siblings: bool,
/// Split the revision into two parallel revisions instead of a parent and
/// child.
// TODO: Delete `--siblings` alias in jj 0.25+
#[arg(long, short, alias = "siblings")]
parallel: bool,
/// Put these paths in the first commit
#[arg(value_hint = clap::ValueHint::AnyPath)]
paths: Vec<String>,
Expand Down Expand Up @@ -137,15 +139,15 @@ the operation will be aborted.

// Create the second commit, which includes everything the user didn't
// select.
let (second_tree, second_base_tree) = if args.siblings {
let (second_tree, second_base_tree) = if args.parallel {
// Merge the original commit tree with its parent using the tree
// containing the user selected changes as the base for the merge.
// This results in a tree with the changes the user didn't select.
(end_tree.merge(&selected_tree, &base_tree)?, &base_tree)
} else {
(end_tree, &selected_tree)
};
let second_commit_parents = if args.siblings {
let second_commit_parents = if args.parallel {
commit.parent_ids().to_vec()
} else {
vec![first_commit.id().clone()]
Expand Down Expand Up @@ -189,11 +191,11 @@ the operation will be aborted.
vec![commit.id().clone()],
|mut rewriter| {
num_rebased += 1;
if args.siblings {
if args.parallel {
rewriter
.replace_parent(second_commit.id(), [first_commit.id(), second_commit.id()]);
}
// We don't need to do anything special for the non-siblings case
// We don't need to do anything special for the non-parallel case
// since we already marked the original commit as rewritten.
rewriter.rebase(command.settings())?.write()?;
Ok(())
Expand Down
2 changes: 1 addition & 1 deletion cli/tests/[email protected]
Original file line number Diff line number Diff line change
Expand Up @@ -1771,7 +1771,7 @@ Splitting an empty commit is not supported because the same effect can be achiev
* `-r`, `--revision <REVISION>` — The revision to split
Default value: `@`
* `-s`, `--siblings` — Split the revision into two siblings instead of a parent and child
* `-p`, `--parallel` — Split the revision into two parallel revisions instead of a parent and child
Possible values: `true`, `false`
Expand Down
6 changes: 3 additions & 3 deletions cli/tests/test_split_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ fn test_split_siblings_no_descendants() {
["dump editor1", "next invocation\n", "dump editor2"].join("\0"),
)
.unwrap();
let (stdout, stderr) = test_env.jj_cmd_ok(&workspace_path, &["split", "--siblings", "file1"]);
let (stdout, stderr) = test_env.jj_cmd_ok(&workspace_path, &["split", "--parallel", "file1"]);
insta::assert_snapshot!(stdout, @"");
insta::assert_snapshot!(stderr, @r###"
First part: qpvuntsm 8d2b7558 TESTED=TODO
Expand Down Expand Up @@ -421,7 +421,7 @@ fn test_split_siblings_with_descendants() {
.join("\0"),
)
.unwrap();
let (stdout, stderr) = test_env.jj_cmd_ok(&workspace_path, &["split", "--siblings", "file1"]);
let (stdout, stderr) = test_env.jj_cmd_ok(&workspace_path, &["split", "--parallel", "file1"]);
insta::assert_snapshot!(stdout, @"");
insta::assert_snapshot!(stderr, @r###"
Rebased 2 descendant commits
Expand Down Expand Up @@ -500,7 +500,7 @@ fn test_split_siblings_with_merge_child() {
.unwrap();
let (stdout, stderr) = test_env.jj_cmd_ok(
&workspace_path,
&["split", "-r", "description(a)", "--siblings", "file1"],
&["split", "-r", "description(a)", "--parallel", "file1"],
);
insta::assert_snapshot!(stdout, @"");
insta::assert_snapshot!(stderr, @r###"
Expand Down

0 comments on commit a9953b3

Please sign in to comment.