-
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
76 additions
and
3 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 |
---|---|---|
|
@@ -13,6 +13,7 @@ | |
// limitations under the License. | ||
|
||
use std::path::Path; | ||
use std::path::PathBuf; | ||
|
||
use crate::common::TestEnvironment; | ||
|
||
|
@@ -100,6 +101,38 @@ fn test_checkout_not_single_rev() { | |
"###); | ||
} | ||
|
||
#[test] | ||
fn test_checkout_conflicting_change_ids() { | ||
let (test_env, repo_path) = set_up(); | ||
|
||
test_env.jj_cmd_success(&repo_path, &["branch", "create", "conflict"]); | ||
test_env.jj_cmd_success(&repo_path, &["describe", "--message", "foo"]); | ||
test_env.jj_cmd_success(&repo_path, &["git", "push", "--branch", "conflict"]); | ||
test_env.jj_cmd_success(&repo_path, &["describe", "--message", "bar"]); | ||
test_env.jj_cmd_success(&repo_path, &["git", "fetch"]); | ||
test_env.jj_cmd_success(&repo_path, &["checkout", "conflict@origin"]); | ||
|
||
let stdout = test_env.jj_cmd_success(&repo_path, &["log"]); | ||
insta::assert_snapshot!(stdout, @r###" | ||
@ wqnwkozp [email protected] 2001-02-03 04:05:19.000 +07:00 434ac141 | ||
│ (empty) (no description set) | ||
◉ yqosqzyt?? [email protected] 2001-02-03 04:05:15.000 +07:00 conflict@origin 6553d57b | ||
│ (empty) foo | ||
│ ◉ yqosqzyt?? [email protected] 2001-02-03 04:05:17.000 +07:00 conflict* 8d2be885 | ||
├─╯ (empty) bar | ||
◉ zzzzzzzz root() 00000000 | ||
"###); | ||
|
||
let stderr = test_env.jj_cmd_failure(&repo_path, &["checkout", "yqosqzyt"]); | ||
insta::assert_snapshot!(stderr, @r###" | ||
Error: Revset "yqosqzyt" resolved to more than one revision | ||
Hint: The revset "yqosqzyt" resolved to these revisions: | ||
yqosqzyt 8d2be885 conflict* | (empty) bar | ||
yqosqzyt 6553d57b conflict@origin | (empty) foo | ||
These commits have the same change id. Abandon one of them with "jj abandon -r <REVISION>". | ||
"###); | ||
} | ||
|
||
#[test] | ||
fn test_checkout_conflicting_branches() { | ||
// Much of this test is borrowed from `test_git_fetch_conflicting_branches` in | ||
|
@@ -177,3 +210,32 @@ fn add_git_remote(test_env: &TestEnvironment, repo_path: &Path, remote: &str) { | |
&["git", "remote", "add", remote, &format!("../{remote}")], | ||
); | ||
} | ||
|
||
fn set_up() -> (TestEnvironment, PathBuf) { | ||
let test_env = TestEnvironment::default(); | ||
test_env.jj_cmd_success(test_env.env_root(), &["init", "--git", "origin"]); | ||
let origin_path = test_env.env_root().join("origin"); | ||
let origin_git_repo_path = origin_path | ||
.join(".jj") | ||
.join("repo") | ||
.join("store") | ||
.join("git"); | ||
|
||
test_env.jj_cmd_success(&origin_path, &["describe", "-m=description 1"]); | ||
test_env.jj_cmd_success(&origin_path, &["branch", "create", "branch1"]); | ||
test_env.jj_cmd_success(&origin_path, &["new", "root()", "-m=description 2"]); | ||
test_env.jj_cmd_success(&origin_path, &["branch", "create", "branch2"]); | ||
test_env.jj_cmd_success(&origin_path, &["git", "export"]); | ||
|
||
test_env.jj_cmd_success( | ||
test_env.env_root(), | ||
&[ | ||
"git", | ||
"clone", | ||
origin_git_repo_path.to_str().unwrap(), | ||
"local", | ||
], | ||
); | ||
let workspace_root = test_env.env_root().join("local"); | ||
(test_env, workspace_root) | ||
} |