diff --git a/tests/test_log_command.rs b/tests/test_log_command.rs index 75ff2c801..aaa891482 100644 --- a/tests/test_log_command.rs +++ b/tests/test_log_command.rs @@ -309,10 +309,17 @@ fn test_log_prefix_highlight_brackets() { ~ "### ); - for i in 1..50 { + + // Create a chain of 10 commits + for i in 1..10 { test_env.jj_cmd_success(&repo_path, &["new", "-m", &format!("commit{i}")]); std::fs::write(repo_path.join("file"), format!("file {i}\n")).unwrap(); } + // Create 2^3 duplicates of the chain + for _ in 0..3 { + test_env.jj_cmd_success(&repo_path, &["duplicate", "description(commit)"]); + } + insta::assert_snapshot!( test_env.jj_cmd_success(&repo_path, &["log", "-r", "original", "-T", &prefix_format(Some(12))]), @r###" @@ -321,54 +328,51 @@ fn test_log_prefix_highlight_brackets() { "### ); insta::assert_snapshot!( - test_env.jj_cmd_success(&repo_path, &["log", "-r", "@-----------..@", "-T", &prefix_format(Some(12))]), + test_env.jj_cmd_success(&repo_path, &["log", "-r", ":@", "-T", &prefix_format(Some(12))]), @r###" - @ Change 4c9[32da80131] commit49 d8[3437a2ceff] - o Change 0d[58f15eaba6] commit48 f3[abb4ea0ac3] - o Change fc[e6c2c59123] commit47 38e[891bea27b] - o Change d5[1defcac305] commit46 1c[04d947707a] - o Change 4f[13b1391d68] commit45 747[24ae22b1e] - o Change 6a[de2950a042] commit44 c7a[a67cf7bbd] - o Change 06c[482e452d3] commit43 8e[c99dfcb6c7] - o Change 392[beeb018eb] commit42 8f0[e60411b78] - o Change a1[b73d3ff916] commit41 71[d6937a66c3] - o Change 708[8f461291f] commit40 db[5720490266] - o Change c49[f7f006c77] commit39 d94[54fec8a69] - ~ + @ Change 39c[3fb0af576] commit9 03f[51310b83e] + o Change fd[f57e73a939] commit8 f7[7fb1909080] + o Change fa9[213bcf78e] commit7 e7[15ad5db646] + o Change 0cff[a7997ffe] commit6 38[622e54e2e5] + o Change 1b[76972398e6] commit5 0cf4[2f60199c] + o Change 48[523d946ad2] commit4 9e[6015e4e622] + o Change 19[b790168e73] commit3 06f[34d9b1475] + o Change 8b12[d1f268f8] commit2 1f[99a5e19891] + o Change d0[43564ef936] commit1 7b[1f7dee65b4] + o Change 9a4[5c67d3e96] initial ba1[a30916d29] original + o Change 000[000000000] 000[000000000] "### ); insta::assert_snapshot!( - test_env.jj_cmd_success(&repo_path, &["log", "-r", "@-----------..@", "-T", &prefix_format(Some(3))]), + test_env.jj_cmd_success(&repo_path, &["log", "-r", ":@", "-T", &prefix_format(Some(3))]), @r###" - @ Change 4c9 commit49 d8[3] - o Change 0d[5] commit48 f3[a] - o Change fc[e] commit47 38e - o Change d5[1] commit46 1c[0] - o Change 4f[1] commit45 747 - o Change 6a[d] commit44 c7a - o Change 06c commit43 8e[c] - o Change 392 commit42 8f0 - o Change a1[b] commit41 71[d] - o Change 708 commit40 db[5] - o Change c49 commit39 d94 - ~ + @ Change 39c commit9 03f + o Change fd[f] commit8 f7[7] + o Change fa9 commit7 e7[1] + o Change 0cff commit6 38[6] + o Change 1b[7] commit5 0cf4 + o Change 48[5] commit4 9e[6] + o Change 19[b] commit3 06f + o Change 8b12 commit2 1f[9] + o Change d0[4] commit1 7b[1] + o Change 9a4 initial ba1 original + o Change 000 000 "### ); insta::assert_snapshot!( - test_env.jj_cmd_success(&repo_path, &["log", "-r", "@-----------..@", "-T", &prefix_format(None)]), + test_env.jj_cmd_success(&repo_path, &["log", "-r", ":@", "-T", &prefix_format(None)]), @r###" - @ Change 4c9 commit49 d8 - o Change 0d commit48 f3 - o Change fc commit47 38e - o Change d5 commit46 1c - o Change 4f commit45 747 - o Change 6a commit44 c7a - o Change 06c commit43 8e - o Change 392 commit42 8f0 - o Change a1 commit41 71 - o Change 708 commit40 db - o Change c49 commit39 d94 - ~ + @ Change 39c commit9 03f + o Change fd commit8 f7 + o Change fa9 commit7 e7 + o Change 0cff commit6 38 + o Change 1b commit5 0cf4 + o Change 48 commit4 9e + o Change 19 commit3 06f + o Change 8b12 commit2 1f + o Change d0 commit1 7b + o Change 9a4 initial ba1 original + o Change 000 000 "### ); } @@ -399,10 +403,17 @@ fn test_log_prefix_highlight_styled() { ~ "### ); - for i in 1..50 { + + // Create a chain of 10 commits + for i in 1..10 { test_env.jj_cmd_success(&repo_path, &["new", "-m", &format!("commit{i}")]); std::fs::write(repo_path.join("file"), format!("file {i}\n")).unwrap(); } + // Create 2^3 duplicates of the chain + for _ in 0..3 { + test_env.jj_cmd_success(&repo_path, &["duplicate", "description(commit)"]); + } + insta::assert_snapshot!( test_env.jj_cmd_success(&repo_path, &["log", "-r", "original", "-T", &prefix_format(Some(12))]), @r###" @@ -423,18 +434,17 @@ fn test_log_prefix_highlight_styled() { ); insta::assert_snapshot!(stdout, @r###" - @ Change 4c932da80131 commit49 d83437a2ceff - o Change 0d58f15eaba6 commit48 f3abb4ea0ac3 - o Change fce6c2c59123 commit47 38e891bea27b - o Change d51defcac305 commit46 1c04d947707a - o Change 4f13b1391d68 commit45 74724ae22b1e - o Change 6ade2950a042 commit44 c7aa67cf7bbd - o Change 06c482e452d3 commit43 8ec99dfcb6c7 - o Change 392beeb018eb commit42 8f0e60411b78 - o Change a1b73d3ff916 commit41 71d6937a66c3 - o Change 7088f461291f commit40 db5720490266 - o Change c49f7f006c77 commit39 d9454fec8a69 - ~ + @ Change 39c3fb0af576 commit9 03f51310b83e + o Change fdf57e73a939 commit8 f77fb1909080 + o Change fa9213bcf78e commit7 e715ad5db646 + o Change 0cffa7997ffe commit6 38622e54e2e5 + o Change 1b76972398e6 commit5 0cf42f60199c + o Change 48523d946ad2 commit4 9e6015e4e622 + o Change 19b790168e73 commit3 06f34d9b1475 + o Change 8b12d1f268f8 commit2 1f99a5e19891 + o Change d043564ef936 commit1 7b1f7dee65b4 + o Change 9a45c67d3e96 initial ba1a30916d29 original + o Change 000000000000 000000000000 "### ); let stdout = test_env.jj_cmd_success( @@ -450,18 +460,17 @@ fn test_log_prefix_highlight_styled() { ); insta::assert_snapshot!(stdout, @r###" - @ Change 4c9 commit49 d83 - o Change 0d5 commit48 f3a - o Change fce commit47 38e - o Change d51 commit46 1c0 - o Change 4f1 commit45 747 - o Change 6ad commit44 c7a - o Change 06c commit43 8ec - o Change 392 commit42 8f0 - o Change a1b commit41 71d - o Change 708 commit40 db5 - o Change c49 commit39 d94 - ~ + @ Change 39c commit9 03f + o Change fdf commit8 f77 + o Change fa9 commit7 e71 + o Change 0cff commit6 386 + o Change 1b7 commit5 0cf4 + o Change 485 commit4 9e6 + o Change 19b commit3 06f + o Change 8b12 commit2 1f9 + o Change d04 commit1 7b1 + o Change 9a4 initial ba1 original + o Change 000 000 "### ); let stdout = test_env.jj_cmd_success( @@ -477,18 +486,17 @@ fn test_log_prefix_highlight_styled() { ); insta::assert_snapshot!(stdout, @r###" - @ Change 4c9 commit49 d8 - o Change 0d commit48 f3 - o Change fc commit47 38e - o Change d5 commit46 1c - o Change 4f commit45 747 - o Change 6a commit44 c7a - o Change 06c commit43 8e - o Change 392 commit42 8f0 - o Change a1 commit41 71 - o Change 708 commit40 db - o Change c49 commit39 d94 - ~ + @ Change 39c commit9 03f + o Change fd commit8 f7 + o Change fa9 commit7 e7 + o Change 0cff commit6 38 + o Change 1b commit5 0cf4 + o Change 48 commit4 9e + o Change 19 commit3 06f + o Change 8b12 commit2 1f + o Change d0 commit1 7b + o Change 9a4 initial ba1 original + o Change 000 000 "### ); } @@ -514,24 +522,22 @@ fn test_log_prefix_highlight_counts_hidden_commits() { o Change 0[00000000000] 0[00000000000] "### ); - for i in 1..100 { - test_env.jj_cmd_success(&repo_path, &["describe", "-m", &format!("commit{i}")]); - std::fs::write(repo_path.join("file"), format!("file {i}\n")).unwrap(); + + // Create 2^7 hidden commits + test_env.jj_cmd_success(&repo_path, &["new", "root", "-m", "extra"]); + for _ in 0..7 { + test_env.jj_cmd_success(&repo_path, &["duplicate", "description(extra)"]); } - // The first commit still exists. Its unique prefix became longer. + test_env.jj_cmd_success(&repo_path, &["abandon", "description(extra)"]); + + // The first commit's unique prefix became longer. insta::assert_snapshot!( - test_env.jj_cmd_success(&repo_path, &["log", "-r", "ba1", "-T", prefix_format]), + test_env.jj_cmd_success(&repo_path, &["log", "-T", prefix_format]), @r###" - o Change 9a4[5c67d3e96] initial ba1[a30916d29] - ~ - "### - ); - // The first commit is no longer visible - insta::assert_snapshot!( - test_env.jj_cmd_success(&repo_path, &["log", "-r", "all()", "-T", prefix_format]), - @r###" - @ Change 9a4[5c67d3e96] commit99 de[3177d2acf2] original - o Change 000[000000000] 000[000000000] + @ Change 39c3[fb0af576] 44[4c3c5066d3] + | o Change 9a[45c67d3e96] initial ba[1a30916d29] original + |/ + o Change 00[0000000000] 00[0000000000] "### ); insta::assert_snapshot!( @@ -541,9 +547,9 @@ fn test_log_prefix_highlight_counts_hidden_commits() { "### ); insta::assert_snapshot!( - test_env.jj_cmd_success(&repo_path, &["log", "-r", "de", "-T", prefix_format]), + test_env.jj_cmd_success(&repo_path, &["log", "-r", "d0", "-T", prefix_format]), @r###" - @ Change 9a4[5c67d3e96] commit99 de[3177d2acf2] original + o Change a70[78fc7d293] extra d0[947f34cec4] ~ "### );