2023-01-21 23:07:42 +00:00
|
|
|
|
// Copyright 2023 The Jujutsu Authors
|
|
|
|
|
//
|
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
|
//
|
|
|
|
|
// https://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
//
|
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
|
// limitations under the License.
|
|
|
|
|
//
|
|
|
|
|
|
2024-04-02 21:27:02 +00:00
|
|
|
|
use std::path::Path;
|
|
|
|
|
|
2024-01-19 17:49:13 +00:00
|
|
|
|
use crate::common::{get_stderr_string, get_stdout_string, TestEnvironment};
|
2023-01-21 23:07:42 +00:00
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn test_next_simple() {
|
|
|
|
|
// Move from first => second.
|
|
|
|
|
// first
|
|
|
|
|
// |
|
|
|
|
|
// second
|
|
|
|
|
// |
|
|
|
|
|
// third
|
|
|
|
|
//
|
|
|
|
|
let test_env = TestEnvironment::default();
|
2024-05-17 19:49:25 +00:00
|
|
|
|
test_env.jj_cmd_ok(test_env.env_root(), &["git", "init", "repo"]);
|
2023-01-21 23:07:42 +00:00
|
|
|
|
let repo_path = test_env.env_root().join("repo");
|
|
|
|
|
// Create a simple linear history, which we'll traverse.
|
2023-10-10 11:59:18 +00:00
|
|
|
|
test_env.jj_cmd_ok(&repo_path, &["commit", "-m", "first"]);
|
|
|
|
|
test_env.jj_cmd_ok(&repo_path, &["commit", "-m", "second"]);
|
|
|
|
|
test_env.jj_cmd_ok(&repo_path, &["commit", "-m", "third"]);
|
2023-01-21 23:07:42 +00:00
|
|
|
|
// Move to `first`
|
2023-10-10 11:59:18 +00:00
|
|
|
|
test_env.jj_cmd_ok(&repo_path, &["new", "@--"]);
|
|
|
|
|
let (stdout, stderr) = test_env.jj_cmd_ok(&repo_path, &["next"]);
|
2023-10-10 11:07:06 +00:00
|
|
|
|
insta::assert_snapshot!(stdout, @"");
|
|
|
|
|
insta::assert_snapshot!(stderr, @r###"
|
2024-06-23 22:20:33 +00:00
|
|
|
|
Working copy now at: royxmykx fb00d619 (empty) (no description set)
|
|
|
|
|
Parent commit : kkmpptxz 30056b0c (empty) third
|
2023-10-10 11:07:06 +00:00
|
|
|
|
"###);
|
2023-01-21 23:07:42 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn test_next_multiple() {
|
|
|
|
|
// Move from first => fourth.
|
|
|
|
|
let test_env = TestEnvironment::default();
|
2024-05-17 19:49:25 +00:00
|
|
|
|
test_env.jj_cmd_ok(test_env.env_root(), &["git", "init", "repo"]);
|
2023-01-21 23:07:42 +00:00
|
|
|
|
let repo_path = test_env.env_root().join("repo");
|
2023-10-10 11:59:18 +00:00
|
|
|
|
test_env.jj_cmd_ok(&repo_path, &["commit", "-m", "first"]);
|
|
|
|
|
test_env.jj_cmd_ok(&repo_path, &["commit", "-m", "second"]);
|
|
|
|
|
test_env.jj_cmd_ok(&repo_path, &["commit", "-m", "third"]);
|
|
|
|
|
test_env.jj_cmd_ok(&repo_path, &["commit", "-m", "fourth"]);
|
|
|
|
|
test_env.jj_cmd_ok(&repo_path, &["new", "@---"]);
|
|
|
|
|
let (stdout, stderr) = test_env.jj_cmd_ok(&repo_path, &["next", "2"]);
|
2023-01-21 23:07:42 +00:00
|
|
|
|
// We should now be the child of the fourth commit.
|
2023-10-10 11:07:06 +00:00
|
|
|
|
insta::assert_snapshot!(stdout, @"");
|
|
|
|
|
insta::assert_snapshot!(stderr, @r###"
|
2024-06-23 22:20:33 +00:00
|
|
|
|
Working copy now at: yqosqzyt 50168682 (empty) (no description set)
|
|
|
|
|
Parent commit : zsuskuln 9d7e5e99 (empty) fourth
|
2023-10-10 11:07:06 +00:00
|
|
|
|
"###);
|
2023-01-21 23:07:42 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn test_prev_simple() {
|
2024-04-02 21:27:02 +00:00
|
|
|
|
// Move @- from third to second.
|
2023-01-21 23:07:42 +00:00
|
|
|
|
let test_env = TestEnvironment::default();
|
2024-05-17 19:49:25 +00:00
|
|
|
|
test_env.jj_cmd_ok(test_env.env_root(), &["git", "init", "repo"]);
|
2023-01-21 23:07:42 +00:00
|
|
|
|
let repo_path = test_env.env_root().join("repo");
|
2023-10-10 11:59:18 +00:00
|
|
|
|
test_env.jj_cmd_ok(&repo_path, &["commit", "-m", "first"]);
|
|
|
|
|
test_env.jj_cmd_ok(&repo_path, &["commit", "-m", "second"]);
|
|
|
|
|
test_env.jj_cmd_ok(&repo_path, &["commit", "-m", "third"]);
|
2024-04-02 21:27:02 +00:00
|
|
|
|
insta::assert_snapshot!(get_log_output(&test_env, &repo_path), @r###"
|
|
|
|
|
@ zsuskulnrvyr
|
2024-07-15 22:20:10 +00:00
|
|
|
|
○ kkmpptxzrspx third
|
|
|
|
|
○ rlvkpnrzqnoo second
|
|
|
|
|
○ qpvuntsmwlqt first
|
|
|
|
|
◆ zzzzzzzzzzzz
|
2024-04-02 21:27:02 +00:00
|
|
|
|
"###);
|
|
|
|
|
|
2023-10-10 11:59:18 +00:00
|
|
|
|
let (stdout, stderr) = test_env.jj_cmd_ok(&repo_path, &["prev"]);
|
2023-10-10 11:07:06 +00:00
|
|
|
|
insta::assert_snapshot!(stdout, @"");
|
|
|
|
|
insta::assert_snapshot!(stderr, @r###"
|
2024-06-23 22:20:33 +00:00
|
|
|
|
Working copy now at: royxmykx 6db74f64 (empty) (no description set)
|
|
|
|
|
Parent commit : rlvkpnrz 9ed53a4a (empty) second
|
2023-10-10 11:07:06 +00:00
|
|
|
|
"###);
|
2023-01-21 23:07:42 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn test_prev_multiple_without_root() {
|
2024-04-02 21:27:02 +00:00
|
|
|
|
// Move @- from fourth to second.
|
2023-01-21 23:07:42 +00:00
|
|
|
|
let test_env = TestEnvironment::default();
|
2024-05-17 19:49:25 +00:00
|
|
|
|
test_env.jj_cmd_ok(test_env.env_root(), &["git", "init", "repo"]);
|
2023-01-21 23:07:42 +00:00
|
|
|
|
let repo_path = test_env.env_root().join("repo");
|
2023-10-10 11:59:18 +00:00
|
|
|
|
test_env.jj_cmd_ok(&repo_path, &["commit", "-m", "first"]);
|
|
|
|
|
test_env.jj_cmd_ok(&repo_path, &["commit", "-m", "second"]);
|
|
|
|
|
test_env.jj_cmd_ok(&repo_path, &["commit", "-m", "third"]);
|
|
|
|
|
test_env.jj_cmd_ok(&repo_path, &["commit", "-m", "fourth"]);
|
2024-04-02 21:27:02 +00:00
|
|
|
|
insta::assert_snapshot!(get_log_output(&test_env, &repo_path), @r###"
|
|
|
|
|
@ mzvwutvlkqwt
|
2024-07-15 22:20:10 +00:00
|
|
|
|
○ zsuskulnrvyr fourth
|
|
|
|
|
○ kkmpptxzrspx third
|
|
|
|
|
○ rlvkpnrzqnoo second
|
|
|
|
|
○ qpvuntsmwlqt first
|
|
|
|
|
◆ zzzzzzzzzzzz
|
2024-04-02 21:27:02 +00:00
|
|
|
|
"###);
|
|
|
|
|
|
2023-10-10 11:59:18 +00:00
|
|
|
|
let (stdout, stderr) = test_env.jj_cmd_ok(&repo_path, &["prev", "2"]);
|
2023-10-10 11:07:06 +00:00
|
|
|
|
insta::assert_snapshot!(stdout, @"");
|
|
|
|
|
insta::assert_snapshot!(stderr, @r###"
|
2024-06-23 22:20:33 +00:00
|
|
|
|
Working copy now at: yqosqzyt 794ffd20 (empty) (no description set)
|
|
|
|
|
Parent commit : rlvkpnrz 9ed53a4a (empty) second
|
2023-10-10 11:07:06 +00:00
|
|
|
|
"###);
|
2023-01-21 23:07:42 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn test_next_exceeding_history() {
|
|
|
|
|
// Try to step beyond the current repos history.
|
|
|
|
|
let test_env = TestEnvironment::default();
|
2024-05-17 19:49:25 +00:00
|
|
|
|
test_env.jj_cmd_ok(test_env.env_root(), &["git", "init", "repo"]);
|
2023-01-21 23:07:42 +00:00
|
|
|
|
let repo_path = test_env.env_root().join("repo");
|
2023-10-10 11:59:18 +00:00
|
|
|
|
test_env.jj_cmd_ok(&repo_path, &["commit", "-m", "first"]);
|
|
|
|
|
test_env.jj_cmd_ok(&repo_path, &["commit", "-m", "second"]);
|
|
|
|
|
test_env.jj_cmd_ok(&repo_path, &["commit", "-m", "third"]);
|
|
|
|
|
test_env.jj_cmd_ok(&repo_path, &["edit", "-r", "@--"]);
|
2023-01-21 23:07:42 +00:00
|
|
|
|
let stderr = test_env.jj_cmd_failure(&repo_path, &["next", "3"]);
|
|
|
|
|
// `jj next` beyond existing history fails.
|
|
|
|
|
insta::assert_snapshot!(stderr, @r###"
|
|
|
|
|
Error: No descendant found 3 commits forward
|
|
|
|
|
"###);
|
|
|
|
|
}
|
|
|
|
|
|
2024-04-08 00:46:33 +00:00
|
|
|
|
// The working copy commit is a child of a "fork" with two children on each
|
|
|
|
|
// branch.
|
2024-01-19 18:54:38 +00:00
|
|
|
|
#[test]
|
2024-04-08 00:46:33 +00:00
|
|
|
|
fn test_next_parent_has_multiple_descendants() {
|
2024-01-19 18:54:38 +00:00
|
|
|
|
let test_env = TestEnvironment::default();
|
2024-05-17 19:49:25 +00:00
|
|
|
|
test_env.jj_cmd_ok(test_env.env_root(), &["git", "init", "repo"]);
|
2024-01-19 18:54:38 +00:00
|
|
|
|
let repo_path = test_env.env_root().join("repo");
|
2024-04-08 00:46:33 +00:00
|
|
|
|
// Setup.
|
|
|
|
|
test_env.jj_cmd_ok(&repo_path, &["desc", "-m", "1"]);
|
|
|
|
|
test_env.jj_cmd_ok(&repo_path, &["new", "-m", "2"]);
|
|
|
|
|
test_env.jj_cmd_ok(&repo_path, &["new", "root()", "-m", "3"]);
|
|
|
|
|
test_env.jj_cmd_ok(&repo_path, &["new", "-m", "4"]);
|
|
|
|
|
test_env.jj_cmd_ok(&repo_path, &["edit", "description(3)"]);
|
|
|
|
|
insta::assert_snapshot!(get_log_output(&test_env, &repo_path), @r###"
|
2024-07-15 22:20:10 +00:00
|
|
|
|
○ mzvwutvlkqwt 4
|
2024-04-08 00:46:33 +00:00
|
|
|
|
@ zsuskulnrvyr 3
|
2024-07-15 22:20:10 +00:00
|
|
|
|
│ ○ kkmpptxzrspx 2
|
|
|
|
|
│ ○ qpvuntsmwlqt 1
|
2024-04-08 00:46:33 +00:00
|
|
|
|
├─╯
|
2024-07-15 22:20:10 +00:00
|
|
|
|
◆ zzzzzzzzzzzz
|
2024-04-08 00:46:33 +00:00
|
|
|
|
"###);
|
|
|
|
|
|
|
|
|
|
// --edit is implied since the working copy isn't a leaf commit.
|
|
|
|
|
let (stdout, stderr) = test_env.jj_cmd_ok(&repo_path, &["next"]);
|
|
|
|
|
insta::assert_snapshot!(stdout,@r###""###);
|
2024-01-19 18:54:38 +00:00
|
|
|
|
insta::assert_snapshot!(stderr,@r###"
|
2024-04-08 00:46:33 +00:00
|
|
|
|
Working copy now at: mzvwutvl 1b8531ce (empty) 4
|
|
|
|
|
Parent commit : zsuskuln b1394455 (empty) 3
|
|
|
|
|
"###);
|
|
|
|
|
insta::assert_snapshot!(get_log_output(&test_env, &repo_path), @r###"
|
|
|
|
|
@ mzvwutvlkqwt 4
|
2024-07-15 22:20:10 +00:00
|
|
|
|
○ zsuskulnrvyr 3
|
|
|
|
|
│ ○ kkmpptxzrspx 2
|
|
|
|
|
│ ○ qpvuntsmwlqt 1
|
2024-04-08 00:46:33 +00:00
|
|
|
|
├─╯
|
2024-07-15 22:20:10 +00:00
|
|
|
|
◆ zzzzzzzzzzzz
|
2024-04-08 00:46:33 +00:00
|
|
|
|
"###);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn test_next_with_merge_commit_parent() {
|
|
|
|
|
let test_env = TestEnvironment::default();
|
2024-05-17 19:49:25 +00:00
|
|
|
|
test_env.jj_cmd_ok(test_env.env_root(), &["git", "init", "repo"]);
|
2024-04-08 00:46:33 +00:00
|
|
|
|
let repo_path = test_env.env_root().join("repo");
|
|
|
|
|
// Setup.
|
|
|
|
|
test_env.jj_cmd_ok(&repo_path, &["desc", "-m", "1"]);
|
|
|
|
|
test_env.jj_cmd_ok(&repo_path, &["new", "root()", "-m", "2"]);
|
|
|
|
|
test_env.jj_cmd_ok(
|
|
|
|
|
&repo_path,
|
|
|
|
|
&["new", "description(1)", "description(2)", "-m", "3"],
|
|
|
|
|
);
|
|
|
|
|
test_env.jj_cmd_ok(&repo_path, &["new", "-m", "4"]);
|
|
|
|
|
test_env.jj_cmd_ok(&repo_path, &["prev", "0"]);
|
|
|
|
|
insta::assert_snapshot!(get_log_output(&test_env, &repo_path), @r###"
|
|
|
|
|
@ royxmykxtrkr
|
2024-07-15 22:20:10 +00:00
|
|
|
|
│ ○ mzvwutvlkqwt 4
|
2024-04-08 00:46:33 +00:00
|
|
|
|
├─╯
|
2024-07-15 22:20:10 +00:00
|
|
|
|
○ zsuskulnrvyr 3
|
2024-04-08 00:46:33 +00:00
|
|
|
|
├─╮
|
2024-07-15 22:20:10 +00:00
|
|
|
|
│ ○ kkmpptxzrspx 2
|
|
|
|
|
○ │ qpvuntsmwlqt 1
|
2024-04-08 00:46:33 +00:00
|
|
|
|
├─╯
|
2024-07-15 22:20:10 +00:00
|
|
|
|
◆ zzzzzzzzzzzz
|
2024-04-08 00:46:33 +00:00
|
|
|
|
"###);
|
|
|
|
|
|
|
|
|
|
let (stdout, stderr) = test_env.jj_cmd_ok(&repo_path, &["next"]);
|
|
|
|
|
insta::assert_snapshot!(stdout,@r###""###);
|
|
|
|
|
insta::assert_snapshot!(stderr,@r###"
|
2024-06-23 22:20:33 +00:00
|
|
|
|
Working copy now at: vruxwmqv e2cefcb7 (empty) (no description set)
|
|
|
|
|
Parent commit : mzvwutvl b54bbdea (empty) 4
|
2024-04-08 00:46:33 +00:00
|
|
|
|
"###);
|
|
|
|
|
insta::assert_snapshot!(get_log_output(&test_env, &repo_path), @r###"
|
|
|
|
|
@ vruxwmqvtpmx
|
2024-07-15 22:20:10 +00:00
|
|
|
|
○ mzvwutvlkqwt 4
|
|
|
|
|
○ zsuskulnrvyr 3
|
2024-04-08 00:46:33 +00:00
|
|
|
|
├─╮
|
2024-07-15 22:20:10 +00:00
|
|
|
|
│ ○ kkmpptxzrspx 2
|
|
|
|
|
○ │ qpvuntsmwlqt 1
|
2024-04-08 00:46:33 +00:00
|
|
|
|
├─╯
|
2024-07-15 22:20:10 +00:00
|
|
|
|
◆ zzzzzzzzzzzz
|
2024-04-08 00:46:33 +00:00
|
|
|
|
"###);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn test_next_on_merge_commit() {
|
|
|
|
|
let test_env = TestEnvironment::default();
|
2024-05-17 19:49:25 +00:00
|
|
|
|
test_env.jj_cmd_ok(test_env.env_root(), &["git", "init", "repo"]);
|
2024-04-08 00:46:33 +00:00
|
|
|
|
let repo_path = test_env.env_root().join("repo");
|
|
|
|
|
// Setup.
|
|
|
|
|
test_env.jj_cmd_ok(&repo_path, &["desc", "-m", "1"]);
|
|
|
|
|
test_env.jj_cmd_ok(&repo_path, &["new", "root()", "-m", "2"]);
|
|
|
|
|
test_env.jj_cmd_ok(
|
|
|
|
|
&repo_path,
|
|
|
|
|
&["new", "description(1)", "description(2)", "-m", "3"],
|
|
|
|
|
);
|
|
|
|
|
test_env.jj_cmd_ok(&repo_path, &["new", "-m", "4"]);
|
|
|
|
|
test_env.jj_cmd_ok(&repo_path, &["edit", "description(3)"]);
|
|
|
|
|
insta::assert_snapshot!(get_log_output(&test_env, &repo_path), @r###"
|
2024-07-15 22:20:10 +00:00
|
|
|
|
○ mzvwutvlkqwt 4
|
2024-04-08 00:46:33 +00:00
|
|
|
|
@ zsuskulnrvyr 3
|
|
|
|
|
├─╮
|
2024-07-15 22:20:10 +00:00
|
|
|
|
│ ○ kkmpptxzrspx 2
|
|
|
|
|
○ │ qpvuntsmwlqt 1
|
2024-04-08 00:46:33 +00:00
|
|
|
|
├─╯
|
2024-07-15 22:20:10 +00:00
|
|
|
|
◆ zzzzzzzzzzzz
|
2024-04-08 00:46:33 +00:00
|
|
|
|
"###);
|
|
|
|
|
|
|
|
|
|
// --edit is implied since the working copy is not a leaf commit.
|
|
|
|
|
let (stdout, stderr) = test_env.jj_cmd_ok(&repo_path, &["next"]);
|
|
|
|
|
insta::assert_snapshot!(stdout,@r###""###);
|
|
|
|
|
insta::assert_snapshot!(stderr,@r###"
|
2024-06-23 22:20:33 +00:00
|
|
|
|
Working copy now at: mzvwutvl b54bbdea (empty) 4
|
|
|
|
|
Parent commit : zsuskuln 5542f0b4 (empty) 3
|
2024-04-08 00:46:33 +00:00
|
|
|
|
"###);
|
|
|
|
|
insta::assert_snapshot!(get_log_output(&test_env, &repo_path), @r###"
|
|
|
|
|
@ mzvwutvlkqwt 4
|
2024-07-15 22:20:10 +00:00
|
|
|
|
○ zsuskulnrvyr 3
|
2024-04-08 00:46:33 +00:00
|
|
|
|
├─╮
|
2024-07-15 22:20:10 +00:00
|
|
|
|
│ ○ kkmpptxzrspx 2
|
|
|
|
|
○ │ qpvuntsmwlqt 1
|
2024-04-08 00:46:33 +00:00
|
|
|
|
├─╯
|
2024-07-15 22:20:10 +00:00
|
|
|
|
◆ zzzzzzzzzzzz
|
2024-01-19 18:54:38 +00:00
|
|
|
|
"###);
|
|
|
|
|
}
|
|
|
|
|
|
2023-01-21 23:07:42 +00:00
|
|
|
|
#[test]
|
2024-01-19 17:49:13 +00:00
|
|
|
|
fn test_next_fails_on_branching_children_no_stdin() {
|
2023-01-21 23:07:42 +00:00
|
|
|
|
let test_env = TestEnvironment::default();
|
2024-05-17 19:49:25 +00:00
|
|
|
|
test_env.jj_cmd_ok(test_env.env_root(), &["git", "init", "repo"]);
|
2023-01-21 23:07:42 +00:00
|
|
|
|
let repo_path = test_env.env_root().join("repo");
|
2023-10-10 11:59:18 +00:00
|
|
|
|
test_env.jj_cmd_ok(&repo_path, &["commit", "-m", "first"]);
|
|
|
|
|
test_env.jj_cmd_ok(&repo_path, &["commit", "-m", "second"]);
|
2024-03-05 05:26:31 +00:00
|
|
|
|
test_env.jj_cmd_ok(&repo_path, &["new", "@--"]);
|
2023-10-10 11:59:18 +00:00
|
|
|
|
test_env.jj_cmd_ok(&repo_path, &["commit", "-m", "third"]);
|
2024-03-05 05:26:31 +00:00
|
|
|
|
test_env.jj_cmd_ok(&repo_path, &["new", "@--"]);
|
2024-01-19 17:49:13 +00:00
|
|
|
|
|
2023-01-21 23:07:42 +00:00
|
|
|
|
// Try to advance the working copy commit.
|
2024-01-31 14:57:35 +00:00
|
|
|
|
let assert = test_env.jj_cmd(&repo_path, &["next"]).assert().code(1);
|
2024-01-19 17:49:13 +00:00
|
|
|
|
let stderr = test_env.normalize_output(&get_stderr_string(&assert));
|
|
|
|
|
insta::assert_snapshot!(stderr,@r###"
|
2024-02-01 08:28:53 +00:00
|
|
|
|
Error: Cannot prompt for input since the output is not connected to a terminal
|
2024-01-19 17:49:13 +00:00
|
|
|
|
"###);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn test_next_fails_on_branching_children_quit_prompt() {
|
|
|
|
|
let test_env = TestEnvironment::default();
|
2024-05-17 19:49:25 +00:00
|
|
|
|
test_env.jj_cmd_ok(test_env.env_root(), &["git", "init", "repo"]);
|
2024-01-19 17:49:13 +00:00
|
|
|
|
let repo_path = test_env.env_root().join("repo");
|
|
|
|
|
test_env.jj_cmd_ok(&repo_path, &["commit", "-m", "first"]);
|
|
|
|
|
test_env.jj_cmd_ok(&repo_path, &["commit", "-m", "second"]);
|
2024-03-05 05:26:31 +00:00
|
|
|
|
test_env.jj_cmd_ok(&repo_path, &["new", "@--"]);
|
2024-01-19 17:49:13 +00:00
|
|
|
|
test_env.jj_cmd_ok(&repo_path, &["commit", "-m", "third"]);
|
2024-03-05 05:26:31 +00:00
|
|
|
|
test_env.jj_cmd_ok(&repo_path, &["new", "@--"]);
|
2024-01-19 17:49:13 +00:00
|
|
|
|
|
|
|
|
|
// Try to advance the working copy commit.
|
|
|
|
|
let assert = test_env
|
|
|
|
|
.jj_cmd_stdin(&repo_path, &["next"], "q\n")
|
|
|
|
|
.assert()
|
|
|
|
|
.code(1);
|
|
|
|
|
let stdout = test_env.normalize_output(&get_stdout_string(&assert));
|
|
|
|
|
let stderr = test_env.normalize_output(&get_stderr_string(&assert));
|
|
|
|
|
insta::assert_snapshot!(stdout,@r###"
|
|
|
|
|
ambiguous next commit, choose one to target:
|
2024-06-23 22:20:33 +00:00
|
|
|
|
1: zsuskuln 5f24490d (empty) third
|
|
|
|
|
2: rlvkpnrz 9ed53a4a (empty) second
|
2024-01-19 17:49:13 +00:00
|
|
|
|
q: quit the prompt
|
|
|
|
|
enter the index of the commit you want to target:
|
|
|
|
|
"###);
|
2023-01-21 23:07:42 +00:00
|
|
|
|
insta::assert_snapshot!(stderr,@r###"
|
2024-01-19 17:49:13 +00:00
|
|
|
|
Error: ambiguous target commit
|
|
|
|
|
"###);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn test_next_choose_branching_child() {
|
|
|
|
|
let test_env = TestEnvironment::default();
|
2024-05-17 19:49:25 +00:00
|
|
|
|
test_env.jj_cmd_ok(test_env.env_root(), &["git", "init", "repo"]);
|
2024-01-19 17:49:13 +00:00
|
|
|
|
let repo_path = test_env.env_root().join("repo");
|
|
|
|
|
test_env.jj_cmd_ok(&repo_path, &["commit", "-m", "first"]);
|
|
|
|
|
test_env.jj_cmd_ok(&repo_path, &["commit", "-m", "second"]);
|
2024-03-05 05:26:31 +00:00
|
|
|
|
test_env.jj_cmd_ok(&repo_path, &["new", "@--"]);
|
2024-01-19 17:49:13 +00:00
|
|
|
|
test_env.jj_cmd_ok(&repo_path, &["commit", "-m", "third"]);
|
2024-03-05 05:26:31 +00:00
|
|
|
|
test_env.jj_cmd_ok(&repo_path, &["new", "@--"]);
|
2024-03-25 08:44:00 +00:00
|
|
|
|
test_env.jj_cmd_ok(&repo_path, &["commit", "-m", "fourth"]);
|
|
|
|
|
test_env.jj_cmd_ok(&repo_path, &["new", "@--"]);
|
2024-01-19 17:49:13 +00:00
|
|
|
|
// Advance the working copy commit.
|
2024-03-25 08:44:00 +00:00
|
|
|
|
let (stdout, stderr) = test_env.jj_cmd_stdin_ok(&repo_path, &["next"], "2\n");
|
2024-01-19 17:49:13 +00:00
|
|
|
|
insta::assert_snapshot!(stdout,@r###"
|
|
|
|
|
ambiguous next commit, choose one to target:
|
2024-06-23 22:20:33 +00:00
|
|
|
|
1: royxmykx d00fe885 (empty) fourth
|
|
|
|
|
2: zsuskuln 5f24490d (empty) third
|
|
|
|
|
3: rlvkpnrz 9ed53a4a (empty) second
|
2024-01-19 17:49:13 +00:00
|
|
|
|
q: quit the prompt
|
|
|
|
|
enter the index of the commit you want to target:
|
|
|
|
|
"###);
|
|
|
|
|
insta::assert_snapshot!(stderr,@r###"
|
2024-06-23 22:20:33 +00:00
|
|
|
|
Working copy now at: yostqsxw 5c8fa96d (empty) (no description set)
|
|
|
|
|
Parent commit : zsuskuln 5f24490d (empty) third
|
2024-01-19 18:54:38 +00:00
|
|
|
|
"###);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
2024-04-02 21:27:02 +00:00
|
|
|
|
fn test_prev_on_merge_commit() {
|
2024-01-19 18:54:38 +00:00
|
|
|
|
let test_env = TestEnvironment::default();
|
2024-05-17 19:49:25 +00:00
|
|
|
|
test_env.jj_cmd_ok(test_env.env_root(), &["git", "init", "repo"]);
|
2024-01-19 18:54:38 +00:00
|
|
|
|
let repo_path = test_env.env_root().join("repo");
|
2024-04-02 21:27:02 +00:00
|
|
|
|
test_env.jj_cmd_ok(&repo_path, &["desc", "-m", "first"]);
|
2024-01-19 18:54:38 +00:00
|
|
|
|
test_env.jj_cmd_ok(&repo_path, &["branch", "c", "left"]);
|
2024-04-02 21:27:02 +00:00
|
|
|
|
test_env.jj_cmd_ok(&repo_path, &["new", "root()", "-m", "second"]);
|
2024-01-19 18:54:38 +00:00
|
|
|
|
test_env.jj_cmd_ok(&repo_path, &["branch", "c", "right"]);
|
|
|
|
|
test_env.jj_cmd_ok(&repo_path, &["new", "left", "right"]);
|
2024-04-02 21:27:02 +00:00
|
|
|
|
|
|
|
|
|
// Check that the graph looks the way we expect.
|
|
|
|
|
insta::assert_snapshot!(get_log_output(&test_env, &repo_path), @r###"
|
|
|
|
|
@ royxmykxtrkr
|
|
|
|
|
├─╮
|
2024-07-15 22:20:10 +00:00
|
|
|
|
│ ○ zsuskulnrvyr right second
|
|
|
|
|
○ │ qpvuntsmwlqt left first
|
2024-04-02 21:27:02 +00:00
|
|
|
|
├─╯
|
2024-07-15 22:20:10 +00:00
|
|
|
|
◆ zzzzzzzzzzzz
|
2024-04-02 21:27:02 +00:00
|
|
|
|
"###);
|
|
|
|
|
|
2024-04-02 21:27:02 +00:00
|
|
|
|
let (stdout, stderr) = test_env.jj_cmd_ok(&repo_path, &["prev"]);
|
|
|
|
|
insta::assert_snapshot!(stdout, @"");
|
|
|
|
|
insta::assert_snapshot!(stderr,@r###"
|
|
|
|
|
Working copy now at: vruxwmqv 41658cf4 (empty) (no description set)
|
|
|
|
|
Parent commit : zzzzzzzz 00000000 (empty) (no description set)
|
|
|
|
|
"###);
|
|
|
|
|
|
|
|
|
|
test_env.jj_cmd_ok(&repo_path, &["undo"]);
|
|
|
|
|
let (stdout, stderr) = test_env.jj_cmd_stdin_ok(&repo_path, &["prev", "--edit"], "2\n");
|
|
|
|
|
insta::assert_snapshot!(stdout, @r###"
|
|
|
|
|
ambiguous prev commit, choose one to target:
|
|
|
|
|
1: zsuskuln b0d21db3 right | (empty) second
|
2024-06-23 22:20:33 +00:00
|
|
|
|
2: qpvuntsm fa15625b left | (empty) first
|
2024-04-02 21:27:02 +00:00
|
|
|
|
q: quit the prompt
|
|
|
|
|
enter the index of the commit you want to target:
|
|
|
|
|
"###);
|
|
|
|
|
insta::assert_snapshot!(stderr,@r###"
|
2024-06-23 22:20:33 +00:00
|
|
|
|
Working copy now at: qpvuntsm fa15625b left | (empty) first
|
2024-04-02 21:27:02 +00:00
|
|
|
|
Parent commit : zzzzzzzz 00000000 (empty) (no description set)
|
|
|
|
|
"###);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn test_prev_on_merge_commit_with_parent_merge() {
|
|
|
|
|
let test_env = TestEnvironment::default();
|
2024-05-17 19:49:25 +00:00
|
|
|
|
test_env.jj_cmd_ok(test_env.env_root(), &["git", "init", "repo"]);
|
2024-04-02 21:27:02 +00:00
|
|
|
|
let repo_path = test_env.env_root().join("repo");
|
|
|
|
|
test_env.jj_cmd_ok(&repo_path, &["desc", "-m", "x"]);
|
|
|
|
|
test_env.jj_cmd_ok(&repo_path, &["new", "root()", "-m", "y"]);
|
|
|
|
|
test_env.jj_cmd_ok(
|
|
|
|
|
&repo_path,
|
|
|
|
|
&["new", "description(x)", "description(y)", "-m", "z"],
|
|
|
|
|
);
|
|
|
|
|
test_env.jj_cmd_ok(&repo_path, &["new", "root()", "-m", "1"]);
|
|
|
|
|
test_env.jj_cmd_ok(
|
|
|
|
|
&repo_path,
|
|
|
|
|
&["new", "description(z)", "description(1)", "-m", "M"],
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
// Check that the graph looks the way we expect.
|
|
|
|
|
insta::assert_snapshot!(get_log_output(&test_env, &repo_path), @r###"
|
|
|
|
|
@ royxmykxtrkr M
|
|
|
|
|
├─╮
|
2024-07-15 22:20:10 +00:00
|
|
|
|
│ ○ mzvwutvlkqwt 1
|
|
|
|
|
○ │ zsuskulnrvyr z
|
2024-04-02 21:27:02 +00:00
|
|
|
|
├───╮
|
2024-07-15 22:20:10 +00:00
|
|
|
|
│ │ ○ kkmpptxzrspx y
|
2024-04-02 21:27:02 +00:00
|
|
|
|
│ ├─╯
|
2024-07-15 22:20:10 +00:00
|
|
|
|
○ │ qpvuntsmwlqt x
|
2024-04-02 21:27:02 +00:00
|
|
|
|
├─╯
|
2024-07-15 22:20:10 +00:00
|
|
|
|
◆ zzzzzzzzzzzz
|
2024-04-02 21:27:02 +00:00
|
|
|
|
"###);
|
|
|
|
|
|
|
|
|
|
let (stdout, stderr) = test_env.jj_cmd_stdin_ok(&repo_path, &["prev"], "2\n");
|
|
|
|
|
insta::assert_snapshot!(stdout, @r###"
|
|
|
|
|
ambiguous prev commit, choose one to target:
|
|
|
|
|
1: kkmpptxz 146d5c67 (empty) y
|
2024-06-23 22:20:33 +00:00
|
|
|
|
2: qpvuntsm 6799aaa2 (empty) x
|
2024-04-02 21:27:02 +00:00
|
|
|
|
3: zzzzzzzz 00000000 (empty) (no description set)
|
|
|
|
|
q: quit the prompt
|
|
|
|
|
enter the index of the commit you want to target:
|
|
|
|
|
"###);
|
|
|
|
|
insta::assert_snapshot!(stderr,@r###"
|
2024-06-23 22:20:33 +00:00
|
|
|
|
Working copy now at: vruxwmqv e5a6794c (empty) (no description set)
|
|
|
|
|
Parent commit : qpvuntsm 6799aaa2 (empty) x
|
2024-04-02 21:27:02 +00:00
|
|
|
|
"###);
|
|
|
|
|
|
|
|
|
|
test_env.jj_cmd_ok(&repo_path, &["undo"]);
|
|
|
|
|
let (stdout, stderr) = test_env.jj_cmd_stdin_ok(&repo_path, &["prev", "--edit"], "2\n");
|
|
|
|
|
insta::assert_snapshot!(stdout, @r###"
|
|
|
|
|
ambiguous prev commit, choose one to target:
|
|
|
|
|
1: mzvwutvl 89b8a355 (empty) 1
|
2024-06-23 22:20:33 +00:00
|
|
|
|
2: zsuskuln a83fc061 (empty) z
|
2024-04-02 21:27:02 +00:00
|
|
|
|
q: quit the prompt
|
|
|
|
|
enter the index of the commit you want to target:
|
|
|
|
|
"###);
|
2024-01-19 18:54:38 +00:00
|
|
|
|
insta::assert_snapshot!(stderr,@r###"
|
2024-06-23 22:20:33 +00:00
|
|
|
|
Working copy now at: zsuskuln a83fc061 (empty) z
|
|
|
|
|
Parent commit : qpvuntsm 6799aaa2 (empty) x
|
2024-04-02 21:27:02 +00:00
|
|
|
|
Parent commit : kkmpptxz 146d5c67 (empty) y
|
2023-01-21 23:07:42 +00:00
|
|
|
|
"###);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
2024-04-02 21:27:02 +00:00
|
|
|
|
fn test_prev_prompts_on_multiple_parents() {
|
2023-01-21 23:07:42 +00:00
|
|
|
|
let test_env = TestEnvironment::default();
|
2024-05-17 19:49:25 +00:00
|
|
|
|
test_env.jj_cmd_ok(test_env.env_root(), &["git", "init", "repo"]);
|
2023-01-21 23:07:42 +00:00
|
|
|
|
let repo_path = test_env.env_root().join("repo");
|
2023-10-10 11:59:18 +00:00
|
|
|
|
test_env.jj_cmd_ok(&repo_path, &["commit", "-m", "first"]);
|
2024-03-05 05:26:31 +00:00
|
|
|
|
test_env.jj_cmd_ok(&repo_path, &["new", "@--"]);
|
2023-10-10 11:59:18 +00:00
|
|
|
|
test_env.jj_cmd_ok(&repo_path, &["commit", "-m", "second"]);
|
2024-03-25 08:44:00 +00:00
|
|
|
|
test_env.jj_cmd_ok(&repo_path, &["new", "@--"]);
|
|
|
|
|
test_env.jj_cmd_ok(&repo_path, &["commit", "-m", "third"]);
|
2023-01-21 23:07:42 +00:00
|
|
|
|
// Create a merge commit, which has two parents.
|
2024-03-25 08:44:00 +00:00
|
|
|
|
test_env.jj_cmd_ok(&repo_path, &["new", "all:@--+"]);
|
2024-01-19 18:54:38 +00:00
|
|
|
|
test_env.jj_cmd_ok(&repo_path, &["commit", "-m", "merge"]);
|
2024-04-02 21:27:02 +00:00
|
|
|
|
|
|
|
|
|
// Check that the graph looks the way we expect.
|
|
|
|
|
insta::assert_snapshot!(get_log_output(&test_env, &repo_path), @r###"
|
|
|
|
|
@ vruxwmqvtpmx
|
2024-07-15 22:20:10 +00:00
|
|
|
|
○ yqosqzytrlsw merge
|
2024-04-02 21:27:02 +00:00
|
|
|
|
├─┬─╮
|
2024-07-15 22:20:10 +00:00
|
|
|
|
│ │ ○ qpvuntsmwlqt first
|
|
|
|
|
│ ○ │ kkmpptxzrspx second
|
2024-04-02 21:27:02 +00:00
|
|
|
|
│ ├─╯
|
2024-07-15 22:20:10 +00:00
|
|
|
|
○ │ mzvwutvlkqwt third
|
2024-04-02 21:27:02 +00:00
|
|
|
|
├─╯
|
2024-07-15 22:20:10 +00:00
|
|
|
|
◆ zzzzzzzzzzzz
|
2024-04-02 21:27:02 +00:00
|
|
|
|
"###);
|
|
|
|
|
|
|
|
|
|
// Move @ backwards.
|
2024-03-25 08:44:00 +00:00
|
|
|
|
let (stdout, stderr) = test_env.jj_cmd_stdin_ok(&repo_path, &["prev"], "3\n");
|
2024-01-19 17:49:13 +00:00
|
|
|
|
insta::assert_snapshot!(stdout,@r###"
|
|
|
|
|
ambiguous prev commit, choose one to target:
|
2024-06-23 22:20:33 +00:00
|
|
|
|
1: mzvwutvl bc4f4fe3 (empty) third
|
|
|
|
|
2: kkmpptxz b0d21db3 (empty) second
|
|
|
|
|
3: qpvuntsm fa15625b (empty) first
|
2024-01-19 17:49:13 +00:00
|
|
|
|
q: quit the prompt
|
|
|
|
|
enter the index of the commit you want to target:
|
|
|
|
|
"###);
|
2023-01-21 23:07:42 +00:00
|
|
|
|
insta::assert_snapshot!(stderr,@r###"
|
2024-06-23 22:20:33 +00:00
|
|
|
|
Working copy now at: znkkpsqq 07b409e8 (empty) (no description set)
|
|
|
|
|
Parent commit : qpvuntsm fa15625b (empty) first
|
2023-01-21 23:07:42 +00:00
|
|
|
|
"###);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
2024-04-02 21:27:02 +00:00
|
|
|
|
fn test_prev_beyond_root_fails() {
|
2023-01-21 23:07:42 +00:00
|
|
|
|
let test_env = TestEnvironment::default();
|
2024-05-17 19:49:25 +00:00
|
|
|
|
test_env.jj_cmd_ok(test_env.env_root(), &["git", "init", "repo"]);
|
2023-01-21 23:07:42 +00:00
|
|
|
|
let repo_path = test_env.env_root().join("repo");
|
2023-10-10 11:59:18 +00:00
|
|
|
|
test_env.jj_cmd_ok(&repo_path, &["commit", "-m", "first"]);
|
|
|
|
|
test_env.jj_cmd_ok(&repo_path, &["commit", "-m", "second"]);
|
|
|
|
|
test_env.jj_cmd_ok(&repo_path, &["commit", "-m", "third"]);
|
|
|
|
|
test_env.jj_cmd_ok(&repo_path, &["commit", "-m", "fourth"]);
|
2024-04-02 21:27:02 +00:00
|
|
|
|
insta::assert_snapshot!(get_log_output(&test_env, &repo_path), @r###"
|
|
|
|
|
@ mzvwutvlkqwt
|
2024-07-15 22:20:10 +00:00
|
|
|
|
○ zsuskulnrvyr fourth
|
|
|
|
|
○ kkmpptxzrspx third
|
|
|
|
|
○ rlvkpnrzqnoo second
|
|
|
|
|
○ qpvuntsmwlqt first
|
|
|
|
|
◆ zzzzzzzzzzzz
|
2024-04-02 21:27:02 +00:00
|
|
|
|
"###);
|
|
|
|
|
// @- is at "fourth", and there is no parent 5 commits behind it.
|
|
|
|
|
let stderr = test_env.jj_cmd_failure(&repo_path, &["prev", "5"]);
|
2023-01-21 23:07:42 +00:00
|
|
|
|
insta::assert_snapshot!(stderr,@r###"
|
2024-04-02 21:27:02 +00:00
|
|
|
|
Error: No ancestor found 5 commits back
|
2023-01-21 23:07:42 +00:00
|
|
|
|
"###);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn test_prev_editing() {
|
|
|
|
|
// Edit the third commit.
|
|
|
|
|
let test_env = TestEnvironment::default();
|
2024-05-17 19:49:25 +00:00
|
|
|
|
test_env.jj_cmd_ok(test_env.env_root(), &["git", "init", "repo"]);
|
2023-01-21 23:07:42 +00:00
|
|
|
|
let repo_path = test_env.env_root().join("repo");
|
2023-10-10 11:59:18 +00:00
|
|
|
|
test_env.jj_cmd_ok(&repo_path, &["commit", "-m", "first"]);
|
|
|
|
|
test_env.jj_cmd_ok(&repo_path, &["commit", "-m", "second"]);
|
|
|
|
|
test_env.jj_cmd_ok(&repo_path, &["commit", "-m", "third"]);
|
|
|
|
|
test_env.jj_cmd_ok(&repo_path, &["commit", "-m", "fourth"]);
|
2024-04-02 21:27:02 +00:00
|
|
|
|
// Edit the "fourth" commit, which becomes the leaf.
|
|
|
|
|
test_env.jj_cmd_ok(&repo_path, &["edit", "@-"]);
|
|
|
|
|
// Check that the graph looks the way we expect.
|
|
|
|
|
insta::assert_snapshot!(get_log_output(&test_env, &repo_path), @r###"
|
|
|
|
|
@ zsuskulnrvyr fourth
|
2024-07-15 22:20:10 +00:00
|
|
|
|
○ kkmpptxzrspx third
|
|
|
|
|
○ rlvkpnrzqnoo second
|
|
|
|
|
○ qpvuntsmwlqt first
|
|
|
|
|
◆ zzzzzzzzzzzz
|
2024-04-02 21:27:02 +00:00
|
|
|
|
"###);
|
|
|
|
|
|
2023-10-10 11:59:18 +00:00
|
|
|
|
let (stdout, stderr) = test_env.jj_cmd_ok(&repo_path, &["prev", "--edit"]);
|
2024-04-02 21:27:02 +00:00
|
|
|
|
insta::assert_snapshot!(stdout, @r"");
|
2023-10-10 11:07:06 +00:00
|
|
|
|
insta::assert_snapshot!(stderr, @r###"
|
2024-06-23 22:20:33 +00:00
|
|
|
|
Working copy now at: kkmpptxz 30056b0c (empty) third
|
|
|
|
|
Parent commit : rlvkpnrz 9ed53a4a (empty) second
|
2023-10-10 11:07:06 +00:00
|
|
|
|
"###);
|
2024-02-12 05:56:52 +00:00
|
|
|
|
// --edit is implied when already editing a non-head commit
|
|
|
|
|
let (stdout, stderr) = test_env.jj_cmd_ok(&repo_path, &["prev"]);
|
|
|
|
|
insta::assert_snapshot!(stdout, @"");
|
|
|
|
|
insta::assert_snapshot!(stderr, @r###"
|
2024-06-23 22:20:33 +00:00
|
|
|
|
Working copy now at: rlvkpnrz 9ed53a4a (empty) second
|
|
|
|
|
Parent commit : qpvuntsm fa15625b (empty) first
|
2024-02-12 05:56:52 +00:00
|
|
|
|
"###);
|
2023-01-21 23:07:42 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn test_next_editing() {
|
|
|
|
|
// Edit the second commit.
|
|
|
|
|
let test_env = TestEnvironment::default();
|
2024-05-17 19:49:25 +00:00
|
|
|
|
test_env.jj_cmd_ok(test_env.env_root(), &["git", "init", "repo"]);
|
2023-01-21 23:07:42 +00:00
|
|
|
|
let repo_path = test_env.env_root().join("repo");
|
2023-10-10 11:59:18 +00:00
|
|
|
|
test_env.jj_cmd_ok(&repo_path, &["commit", "-m", "first"]);
|
|
|
|
|
test_env.jj_cmd_ok(&repo_path, &["commit", "-m", "second"]);
|
|
|
|
|
test_env.jj_cmd_ok(&repo_path, &["commit", "-m", "third"]);
|
|
|
|
|
test_env.jj_cmd_ok(&repo_path, &["commit", "-m", "fourth"]);
|
2024-02-12 05:56:52 +00:00
|
|
|
|
test_env.jj_cmd_ok(&repo_path, &["edit", "@---"]);
|
2023-10-10 11:59:18 +00:00
|
|
|
|
let (stdout, stderr) = test_env.jj_cmd_ok(&repo_path, &["next", "--edit"]);
|
2023-10-10 11:07:06 +00:00
|
|
|
|
insta::assert_snapshot!(stdout, @"");
|
|
|
|
|
insta::assert_snapshot!(stderr, @r###"
|
2024-06-23 22:20:33 +00:00
|
|
|
|
Working copy now at: kkmpptxz 30056b0c (empty) third
|
|
|
|
|
Parent commit : rlvkpnrz 9ed53a4a (empty) second
|
2024-02-12 05:56:52 +00:00
|
|
|
|
"###);
|
|
|
|
|
// --edit is implied when already editing a non-head commit
|
|
|
|
|
let (stdout, stderr) = test_env.jj_cmd_ok(&repo_path, &["next"]);
|
|
|
|
|
insta::assert_snapshot!(stdout, @"");
|
|
|
|
|
insta::assert_snapshot!(stderr, @r###"
|
2024-06-23 22:20:33 +00:00
|
|
|
|
Working copy now at: zsuskuln 9d7e5e99 (empty) fourth
|
|
|
|
|
Parent commit : kkmpptxz 30056b0c (empty) third
|
2023-10-10 11:07:06 +00:00
|
|
|
|
"###);
|
2023-01-21 23:07:42 +00:00
|
|
|
|
}
|
2024-04-02 21:27:02 +00:00
|
|
|
|
|
2024-02-18 17:57:55 +00:00
|
|
|
|
#[test]
|
|
|
|
|
fn test_prev_conflict() {
|
|
|
|
|
// Make the first commit our new parent.
|
|
|
|
|
let test_env = TestEnvironment::default();
|
|
|
|
|
test_env.jj_cmd_ok(test_env.env_root(), &["init", "repo", "--git"]);
|
|
|
|
|
let repo_path = test_env.env_root().join("repo");
|
|
|
|
|
let file_path = repo_path.join("content.txt");
|
|
|
|
|
std::fs::write(&file_path, "first").unwrap();
|
|
|
|
|
test_env.jj_cmd_ok(&repo_path, &["commit", "-m", "first"]);
|
|
|
|
|
std::fs::write(&file_path, "second").unwrap();
|
|
|
|
|
test_env.jj_cmd_ok(&repo_path, &["commit", "-m", "second"]);
|
|
|
|
|
test_env.jj_cmd_ok(&repo_path, &["commit", "-m", "third"]);
|
|
|
|
|
// Create a conflict in the first commit, where we'll jump to.
|
|
|
|
|
test_env.jj_cmd_ok(&repo_path, &["edit", "description(first)"]);
|
|
|
|
|
std::fs::write(&file_path, "first+1").unwrap();
|
|
|
|
|
test_env.jj_cmd_ok(&repo_path, &["new", "description(third)"]);
|
|
|
|
|
test_env.jj_cmd_ok(&repo_path, &["commit", "-m", "fourth"]);
|
2024-06-21 00:07:01 +00:00
|
|
|
|
// Test the setup
|
|
|
|
|
insta::assert_snapshot!(get_log_output(&test_env, &repo_path), @r###"
|
|
|
|
|
@ yqosqzytrlsw conflict
|
2024-07-15 22:20:10 +00:00
|
|
|
|
× royxmykxtrkr conflict fourth
|
|
|
|
|
× kkmpptxzrspx conflict third
|
|
|
|
|
× rlvkpnrzqnoo conflict second
|
|
|
|
|
○ qpvuntsmwlqt first
|
|
|
|
|
◆ zzzzzzzzzzzz
|
2024-06-21 00:07:01 +00:00
|
|
|
|
"###);
|
|
|
|
|
test_env.jj_cmd_ok(&repo_path, &["prev", "--conflict"]);
|
|
|
|
|
insta::assert_snapshot!(get_log_output(&test_env, &repo_path), @r###"
|
|
|
|
|
@ yostqsxwqrlt conflict
|
2024-07-15 22:20:10 +00:00
|
|
|
|
│ × royxmykxtrkr conflict fourth
|
2024-06-21 00:07:01 +00:00
|
|
|
|
├─╯
|
2024-07-15 22:20:10 +00:00
|
|
|
|
× kkmpptxzrspx conflict third
|
|
|
|
|
× rlvkpnrzqnoo conflict second
|
|
|
|
|
○ qpvuntsmwlqt first
|
|
|
|
|
◆ zzzzzzzzzzzz
|
2024-02-18 17:57:55 +00:00
|
|
|
|
"###);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn test_prev_conflict_editing() {
|
|
|
|
|
// Edit the third commit.
|
|
|
|
|
let test_env = TestEnvironment::default();
|
|
|
|
|
test_env.jj_cmd_ok(test_env.env_root(), &["init", "repo", "--git"]);
|
|
|
|
|
let repo_path = test_env.env_root().join("repo");
|
|
|
|
|
let file_path = repo_path.join("content.txt");
|
|
|
|
|
test_env.jj_cmd_ok(&repo_path, &["commit", "-m", "first"]);
|
|
|
|
|
test_env.jj_cmd_ok(&repo_path, &["commit", "-m", "second"]);
|
|
|
|
|
std::fs::write(&file_path, "second").unwrap();
|
|
|
|
|
test_env.jj_cmd_ok(&repo_path, &["commit", "-m", "third"]);
|
|
|
|
|
// Create a conflict in the third commit, where we'll jump to.
|
|
|
|
|
test_env.jj_cmd_ok(&repo_path, &["edit", "description(first)"]);
|
|
|
|
|
std::fs::write(&file_path, "first text").unwrap();
|
|
|
|
|
test_env.jj_cmd_ok(&repo_path, &["new", "description(third)"]);
|
2024-06-21 00:07:01 +00:00
|
|
|
|
// Test the setup
|
|
|
|
|
insta::assert_snapshot!(get_log_output(&test_env, &repo_path), @r###"
|
|
|
|
|
@ royxmykxtrkr conflict
|
2024-07-15 22:20:10 +00:00
|
|
|
|
× kkmpptxzrspx conflict third
|
|
|
|
|
○ rlvkpnrzqnoo second
|
|
|
|
|
○ qpvuntsmwlqt first
|
|
|
|
|
◆ zzzzzzzzzzzz
|
2024-06-21 00:07:01 +00:00
|
|
|
|
"###);
|
|
|
|
|
test_env.jj_cmd_ok(&repo_path, &["prev", "--conflict", "--edit"]);
|
2024-02-18 17:57:55 +00:00
|
|
|
|
// We now should be editing the third commit.
|
2024-06-21 00:07:01 +00:00
|
|
|
|
insta::assert_snapshot!(get_log_output(&test_env, &repo_path), @r###"
|
|
|
|
|
@ kkmpptxzrspx conflict third
|
2024-07-15 22:20:10 +00:00
|
|
|
|
○ rlvkpnrzqnoo second
|
|
|
|
|
○ qpvuntsmwlqt first
|
|
|
|
|
◆ zzzzzzzzzzzz
|
2024-02-18 17:57:55 +00:00
|
|
|
|
"###);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn test_next_conflict() {
|
2024-06-21 02:09:11 +00:00
|
|
|
|
// There is a conflict in the third commit, so after next it should be the new
|
2024-02-18 17:57:55 +00:00
|
|
|
|
// parent.
|
|
|
|
|
let test_env = TestEnvironment::default();
|
|
|
|
|
test_env.jj_cmd_ok(test_env.env_root(), &["init", "repo", "--git"]);
|
|
|
|
|
let repo_path = test_env.env_root().join("repo");
|
|
|
|
|
let file_path = repo_path.join("content.txt");
|
2024-06-21 02:09:11 +00:00
|
|
|
|
std::fs::write(&file_path, "first").unwrap();
|
2024-02-18 17:57:55 +00:00
|
|
|
|
test_env.jj_cmd_ok(&repo_path, &["commit", "-m", "first"]);
|
|
|
|
|
test_env.jj_cmd_ok(&repo_path, &["commit", "-m", "second"]);
|
2024-06-21 02:09:11 +00:00
|
|
|
|
// Create a conflict in the third commit.
|
|
|
|
|
std::fs::write(&file_path, "third").unwrap();
|
2024-02-18 17:57:55 +00:00
|
|
|
|
test_env.jj_cmd_ok(&repo_path, &["commit", "-m", "third"]);
|
2024-06-21 02:09:11 +00:00
|
|
|
|
test_env.jj_cmd_ok(&repo_path, &["new", "description(first)"]);
|
|
|
|
|
std::fs::write(&file_path, "first v2").unwrap();
|
|
|
|
|
test_env.jj_cmd_ok(&repo_path, &["squash", "--into", "description(third)"]);
|
2024-06-21 00:07:01 +00:00
|
|
|
|
// Test the setup
|
|
|
|
|
insta::assert_snapshot!(get_log_output(&test_env, &repo_path), @r###"
|
2024-06-21 02:09:11 +00:00
|
|
|
|
@ royxmykxtrkr
|
2024-07-15 22:20:10 +00:00
|
|
|
|
│ × kkmpptxzrspx conflict third
|
|
|
|
|
│ ○ rlvkpnrzqnoo second
|
2024-06-21 00:07:01 +00:00
|
|
|
|
├─╯
|
2024-07-15 22:20:10 +00:00
|
|
|
|
○ qpvuntsmwlqt first
|
|
|
|
|
◆ zzzzzzzzzzzz
|
2024-06-21 00:07:01 +00:00
|
|
|
|
"###);
|
|
|
|
|
test_env.jj_cmd_ok(&repo_path, &["next", "--conflict"]);
|
|
|
|
|
insta::assert_snapshot!(get_log_output(&test_env, &repo_path), @r###"
|
2024-06-21 02:09:11 +00:00
|
|
|
|
@ vruxwmqvtpmx conflict
|
2024-07-15 22:20:10 +00:00
|
|
|
|
× kkmpptxzrspx conflict third
|
|
|
|
|
○ rlvkpnrzqnoo second
|
|
|
|
|
○ qpvuntsmwlqt first
|
|
|
|
|
◆ zzzzzzzzzzzz
|
2024-02-18 17:57:55 +00:00
|
|
|
|
"###);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn test_next_conflict_editing() {
|
|
|
|
|
// There is a conflict in the third commit, so after next it should be our
|
|
|
|
|
// working copy.
|
|
|
|
|
let test_env = TestEnvironment::default();
|
|
|
|
|
test_env.jj_cmd_ok(test_env.env_root(), &["init", "repo", "--git"]);
|
|
|
|
|
let repo_path = test_env.env_root().join("repo");
|
|
|
|
|
let file_path = repo_path.join("content.txt");
|
|
|
|
|
test_env.jj_cmd_ok(&repo_path, &["commit", "-m", "first"]);
|
|
|
|
|
std::fs::write(&file_path, "second").unwrap();
|
|
|
|
|
test_env.jj_cmd_ok(&repo_path, &["commit", "-m", "second"]);
|
|
|
|
|
// Create a conflict in the third commit.
|
|
|
|
|
std::fs::write(&file_path, "third").unwrap();
|
|
|
|
|
test_env.jj_cmd_ok(&repo_path, &["edit", "description(second)"]);
|
|
|
|
|
std::fs::write(&file_path, "modified second").unwrap();
|
2024-06-21 02:09:11 +00:00
|
|
|
|
test_env.jj_cmd_ok(&repo_path, &["edit", "@-"]);
|
2024-06-21 00:07:01 +00:00
|
|
|
|
// Test the setup
|
|
|
|
|
insta::assert_snapshot!(get_log_output(&test_env, &repo_path), @r###"
|
2024-07-15 22:20:10 +00:00
|
|
|
|
× kkmpptxzrspx conflict
|
|
|
|
|
○ rlvkpnrzqnoo second
|
2024-06-21 02:09:11 +00:00
|
|
|
|
@ qpvuntsmwlqt first
|
2024-07-15 22:20:10 +00:00
|
|
|
|
◆ zzzzzzzzzzzz
|
2024-06-21 00:07:01 +00:00
|
|
|
|
"###);
|
|
|
|
|
test_env.jj_cmd_ok(&repo_path, &["next", "--conflict", "--edit"]);
|
|
|
|
|
insta::assert_snapshot!(get_log_output(&test_env, &repo_path), @r###"
|
2024-06-21 02:09:11 +00:00
|
|
|
|
@ kkmpptxzrspx conflict
|
2024-07-15 22:20:10 +00:00
|
|
|
|
○ rlvkpnrzqnoo second
|
|
|
|
|
○ qpvuntsmwlqt first
|
|
|
|
|
◆ zzzzzzzzzzzz
|
2024-02-18 17:57:55 +00:00
|
|
|
|
"###);
|
|
|
|
|
}
|
|
|
|
|
|
2024-06-21 00:51:17 +00:00
|
|
|
|
#[test]
|
|
|
|
|
fn test_next_conflict_head() {
|
|
|
|
|
// When editing a head with conflicts, `jj next --conflict [--edit]` errors out.
|
|
|
|
|
let test_env = TestEnvironment::default();
|
|
|
|
|
test_env.jj_cmd_ok(test_env.env_root(), &["init", "repo", "--git"]);
|
|
|
|
|
let repo_path = test_env.env_root().join("repo");
|
|
|
|
|
let file_path = repo_path.join("file");
|
|
|
|
|
std::fs::write(&file_path, "first").unwrap();
|
|
|
|
|
test_env.jj_cmd_ok(&repo_path, &["new"]);
|
|
|
|
|
std::fs::write(&file_path, "second").unwrap();
|
|
|
|
|
test_env.jj_cmd_ok(&repo_path, &["abandon", "@-"]);
|
|
|
|
|
// Test the setup
|
|
|
|
|
insta::assert_snapshot!(get_log_output(&test_env, &repo_path), @r###"
|
|
|
|
|
@ rlvkpnrzqnoo conflict
|
2024-07-15 22:20:10 +00:00
|
|
|
|
◆ zzzzzzzzzzzz
|
2024-06-21 00:51:17 +00:00
|
|
|
|
"###);
|
2024-06-21 03:05:57 +00:00
|
|
|
|
let stderr = test_env.jj_cmd_failure(&repo_path, &["next", "--conflict"]);
|
|
|
|
|
insta::assert_snapshot!(stderr, @r###"
|
|
|
|
|
Error: No descendant found 1 commit forward
|
|
|
|
|
"###);
|
|
|
|
|
let stderr = test_env.jj_cmd_failure(&repo_path, &["next", "--conflict", "--edit"]);
|
|
|
|
|
insta::assert_snapshot!(stderr, @r###"
|
|
|
|
|
Error: No descendant found 1 commit forward
|
|
|
|
|
"###);
|
2024-06-21 00:51:17 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-04-02 21:27:02 +00:00
|
|
|
|
fn get_log_output(test_env: &TestEnvironment, cwd: &Path) -> String {
|
2024-06-21 00:07:01 +00:00
|
|
|
|
let template = r#"separate(" ", change_id.short(), local_branches, if(conflict, "conflict"), description)"#;
|
2024-04-02 21:27:02 +00:00
|
|
|
|
test_env.jj_cmd_success(cwd, &["log", "-T", template])
|
|
|
|
|
}
|