-
Notifications
You must be signed in to change notification settings - Fork 349
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cli: create new wc_commit when wc_commit become immuable
- Loading branch information
Showing
3 changed files
with
100 additions
and
2 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
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 |
---|---|---|
|
@@ -109,6 +109,65 @@ fn test_rewrite_immutable_generic() { | |
"###); | ||
} | ||
|
||
#[test] | ||
fn test_new_wc_commit_when_wc_immutable() { | ||
let test_env = TestEnvironment::default(); | ||
test_env.jj_cmd_ok(test_env.env_root(), &["git", "init"]); | ||
test_env.jj_cmd_ok(test_env.env_root(), &["branch", "create", "main"]); | ||
test_env.add_config(r#"revset-aliases."immutable_heads()" = "main""#); | ||
test_env.jj_cmd_ok(test_env.env_root(), &["new", "-m=a"]); | ||
let (_, stderr) = test_env.jj_cmd_ok(test_env.env_root(), &["branch", "set", "main"]); | ||
insta::assert_snapshot!(stderr, @r###" | ||
Warning: The working-copy commit in workspace 'default' became immutable, so a new commit has been created on top of it. | ||
Working copy now at: zsuskuln 87e33403 (empty) (no description set) | ||
Parent commit : kkmpptxz 7272528e main | (empty) a | ||
"###); | ||
} | ||
|
||
#[test] | ||
fn test_immutable_heads_set_to_working_copy() { | ||
let test_env = TestEnvironment::default(); | ||
test_env.jj_cmd_ok(test_env.env_root(), &["git", "init"]); | ||
test_env.jj_cmd_ok(test_env.env_root(), &["branch", "create", "main"]); | ||
test_env.add_config(r#"revset-aliases."immutable_heads()" = "@""#); | ||
let (_, stderr) = test_env.jj_cmd_ok(test_env.env_root(), &["new", "-m=a"]); | ||
insta::assert_snapshot!(stderr, @r###" | ||
Warning: The working-copy commit in workspace 'default' became immutable, so a new commit has been created on top of it. | ||
Working copy now at: pmmvwywv 09dafa31 (empty) (no description set) | ||
Parent commit : kkmpptxz 4963e243 (empty) a | ||
"###); | ||
} | ||
|
||
#[test] | ||
fn test_new_wc_commit_when_wc_immutable_multi_workspace() { | ||
let test_env = TestEnvironment::default(); | ||
test_env.jj_cmd_ok(test_env.env_root(), &["git", "init"]); | ||
test_env.jj_cmd_ok(test_env.env_root(), &["branch", "create", "main"]); | ||
test_env.add_config(r#"revset-aliases."immutable_heads()" = "main""#); | ||
test_env.jj_cmd_ok(test_env.env_root(), &["new", "-m=a"]); | ||
test_env.jj_cmd_ok(test_env.env_root(), &["workspace", "add", "workspace1"]); | ||
let workspace1_envroot = test_env.env_root().join("workspace1"); | ||
test_env.jj_cmd_ok(workspace1_envroot.as_path(), &["edit", "default@"]); | ||
let (_, stderr) = test_env.jj_cmd_ok(test_env.env_root(), &["branch", "set", "main"]); | ||
insta::assert_snapshot!(stderr, @r###" | ||
Warning: The working-copy commit in workspace 'default' became immutable, so a new commit has been created on top of it. | ||
Warning: The working-copy commit in workspace 'workspace1' became immutable, so a new commit has been created on top of it. | ||
Working copy now at: royxmykx c37fd624 (empty) (no description set) | ||
Parent commit : kkmpptxz ada0ee19 main | a | ||
"###); | ||
test_env.jj_cmd_ok(workspace1_envroot.as_path(), &["workspace", "update-stale"]); | ||
let (stdout, _) = test_env.jj_cmd_ok(workspace1_envroot.as_path(), &["log", "--no-graph"]); | ||
insta::assert_snapshot!(stdout, @r###" | ||
nppvrztz [email protected] 2001-02-03 08:05:11 workspace1@ f5e1b845 | ||
(empty) (no description set) | ||
royxmykx [email protected] 2001-02-03 08:05:12 default@ c37fd624 | ||
(empty) (no description set) | ||
kkmpptxz [email protected] 2001-02-03 08:05:12 main ada0ee19 | ||
a | ||
zzzzzzzz root() 00000000 | ||
"###); | ||
} | ||
|
||
#[test] | ||
fn test_rewrite_immutable_commands() { | ||
let test_env = TestEnvironment::default(); | ||
|