-
Notifications
You must be signed in to change notification settings - Fork 343
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
65 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -100,6 +100,40 @@ fn test_checkout_not_single_rev() { | |
"###); | ||
} | ||
|
||
#[test] | ||
fn test_checkout_conflicting_branches() { | ||
// Much of this test is borrowed from `test_git_fetch_conflicting_branches` in | ||
// test_git_fetch.rs | ||
let test_env = TestEnvironment::default(); | ||
test_env.jj_cmd_success(test_env.env_root(), &["init", "repo", "--git"]); | ||
let repo_path = test_env.env_root().join("repo"); | ||
|
||
test_env.jj_cmd_success(&repo_path, &["describe", "-m", "one"]); | ||
test_env.jj_cmd_success(&repo_path, &["new", "-m", "two", "@-"]); | ||
test_env.jj_cmd_success(&repo_path, &["branch", "create", "foo"]); | ||
test_env.jj_cmd_success(&repo_path, &["--at-op=@-", "branch", "create", "foo", "-r", r#"description("one")"#]); | ||
|
||
let stdout = test_env.jj_cmd_success(&repo_path, &["log"]); | ||
insta::assert_snapshot!(stdout, @r###" | ||
Concurrent modification detected, resolving automatically. | ||
@ kkmpptxz [email protected] 2001-02-03 04:05:09.000 +07:00 foo?? 66c6502d | ||
│ (empty) two | ||
│ ◉ qpvuntsm [email protected] 2001-02-03 04:05:08.000 +07:00 foo?? a9330854 | ||
├─╯ (empty) one | ||
◉ zzzzzzzz root() 00000000 | ||
"###); | ||
|
||
let stderr = test_env.jj_cmd_failure(&repo_path, &["checkout", "foo"]); | ||
insta::assert_snapshot!(stderr, @r###" | ||
Error: Revset "foo" resolved to more than one revision | ||
Hint: Branch foo resolved to multiple revisions because it's conflicted. | ||
It resolved to these revisions: | ||
kkmpptxz 66c6502d foo?? | (empty) two | ||
qpvuntsm a9330854 foo?? | (empty) one | ||
Set which revision the branch points to with "jj branch set foo -r <REVISION>". | ||
"###); | ||
} | ||
|
||
fn get_log_output(test_env: &TestEnvironment, cwd: &Path) -> String { | ||
let template = r#"commit_id ++ " " ++ description"#; | ||
test_env.jj_cmd_success(cwd, &["log", "-T", template]) | ||
|