view: drop tracking of public heads

We've had the public_heads for as long as we've had the View object,
IIRC (I didn't check), but we still don't use it for anything. I don't
have any concrete plans for using it either. Maybe our config for
immutable commits is good enough, or maybe we'll want something more
generic (like Mercurial's phases). For now, I think we should simplify
by removing it the storage for public heads.
This commit is contained in:
Martin von Zweigbergk 2024-01-13 10:06:42 -08:00 committed by Martin von Zweigbergk
parent 7e62d5ef36
commit c9af8bf43a
14 changed files with 74 additions and 240 deletions

View file

@ -234,7 +234,6 @@ fn view_with_desired_portions_restored(
};
jj_lib::op_store::View {
head_ids: repo_source.head_ids.clone(),
public_head_ids: repo_source.public_head_ids.clone(),
local_branches: repo_source.local_branches.clone(),
tags: repo_source.tags.clone(),
remote_views: remote_source.remote_views.clone(),

View file

@ -35,15 +35,15 @@ fn test_concurrent_operation_divergence() {
// "op log" doesn't merge the concurrent operations
let stdout = test_env.jj_cmd_success(&repo_path, &["op", "log"]);
insta::assert_snapshot!(stdout, @r###"
94fce7319d45 test-username@host.example.com 2001-02-03 04:05:09.000 +07:00 - 2001-02-03 04:05:09.000 +07:00
a0cb96855e6b test-username@host.example.com 2001-02-03 04:05:09.000 +07:00 - 2001-02-03 04:05:09.000 +07:00
describe commit 230dd059e1b059aefc0da06a2e5a7dbf22362f22
args: jj describe -m 'message 2' --at-op @-
15e35d1e9190 test-username@host.example.com 2001-02-03 04:05:08.000 +07:00 - 2001-02-03 04:05:08.000 +07:00
c208376a3fee test-username@host.example.com 2001-02-03 04:05:08.000 +07:00 - 2001-02-03 04:05:08.000 +07:00
describe commit 230dd059e1b059aefc0da06a2e5a7dbf22362f22
args: jj describe -m 'message 1'
19b8089fc78b test-username@host.example.com 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00
90e23f7e6c7c test-username@host.example.com 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00
add workspace 'default'
f1c462c494be test-username@host.example.com 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00
b73abeebcf94 test-username@host.example.com 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00
initialize repo
"###);
@ -70,15 +70,15 @@ fn test_concurrent_operations_auto_rebase() {
test_env.jj_cmd_ok(&repo_path, &["describe", "-m", "initial"]);
let stdout = test_env.jj_cmd_success(&repo_path, &["op", "log"]);
insta::assert_snapshot!(stdout, @r###"
@ cfc96ff553b9 test-username@host.example.com 2001-02-03 04:05:08.000 +07:00 - 2001-02-03 04:05:08.000 +07:00
@ ec9298123a0d test-username@host.example.com 2001-02-03 04:05:08.000 +07:00 - 2001-02-03 04:05:08.000 +07:00
describe commit 123ed18e4c4c0d77428df41112bc02ffc83fb935
args: jj describe -m initial
65a6c90b9544 test-username@host.example.com 2001-02-03 04:05:08.000 +07:00 - 2001-02-03 04:05:08.000 +07:00
7ba3da0db37d test-username@host.example.com 2001-02-03 04:05:08.000 +07:00 - 2001-02-03 04:05:08.000 +07:00
snapshot working copy
args: jj describe -m initial
19b8089fc78b test-username@host.example.com 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00
90e23f7e6c7c test-username@host.example.com 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00
add workspace 'default'
f1c462c494be test-username@host.example.com 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00
b73abeebcf94 test-username@host.example.com 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00
initialize repo
"###);
let op_id_hex = stdout[3..15].to_string();
@ -183,21 +183,21 @@ fn test_concurrent_snapshot_wc_reloadable() {
let template = r#"id ++ "\n" ++ description ++ "\n" ++ tags"#;
let op_log_stdout = test_env.jj_cmd_success(&repo_path, &["op", "log", "-T", template]);
insta::assert_snapshot!(op_log_stdout, @r###"
@ 9be517934aaabc351597e88ed4119aa9454ae3588ab7f28646a810272c82f3dafb1deb20b3c978dbb58ba9abc8f08fe870fe3c7ce5f682411991e83eee40a77f
@ 4f927bf9d6694ed9c409828dc0f9f5f64897ba95ac850f63df92572164b5f146cc09c3217481e74aadbc3a581ded02a487dc73911fe03d86cf1b2c6a20bbe8ed
commit 323b414dd255b51375d7f4392b7b2641ffe4289f
args: jj commit -m 'new child1'
d967c09eb12b38dad2065a0bc9e251824247f9f84ba406a7356f5405e4c93c21562178a3f00cafedfa1df1435ba496265f39da9d1ccebaccb78bdcb4bd7031e1
def64cf8aa9890a8a5f607890cc6017103a1affbff84addd5f0546c9f9be732f6c2348c082cc81a0654928263978e3d9690e684b9a08214c420311e978487f08
snapshot working copy
args: jj commit -m 'new child1'
b6d168ba4fb4534257b6e58d53eb407582567342358eab07cf5a01a7e4d797313b692f27664c2fb7935b2380d398d0298233c9732f821b8c687e35607ea08a55
42881255f9267d7713b5a2621eb1cabfe6654ac77913642522d5dd482b94b2dee321b75cda544b4252cfc4b18a6c43bcd291f9b1e2838e44843c38fba21d49fa
commit 3d918700494a9895696e955b85fa05eb0d314cc6
args: jj commit -m initial
5e9e3f82fc14750ff985c5a39f1935ed8876b973b8800b56bc03d1c9754795e724956d862d1fcb2c533d06ca36abc9fa9f7cb7d3b2b64e993e9a87f80d5af670
8816f70c50c1393c80b6538c8833209802d554600de08adac94c1150ef81af323725f4ed2b52c78e6757c9821400de23483dad5f019ea1a1bf7d9ea49f6b91ab
snapshot working copy
args: jj commit -m initial
19b8089fc78b7c49171f3c8934248be6f89f52311005e961cab5780f9f138b142456d77b27d223d7ee84d21d8c30c4a80100eaf6735b548b1acd0da688f94c80
90e23f7e6c7ce885df899e0b4990b39a43816549596a834b727d7eed9650cfe917ac2d043518734223fd7537b9d464e556d28e73cdfed7a0aceb592b89fdba4b
add workspace 'default'
f1c462c494be39f6690928603c5393f908866bc8d81d8cd1ae0bb2ea02cb4f78cafa47165fa5b7cda258e2178f846881de199066991960a80954ba6066ba0821
b73abeebcf94a1528dfeeed335d6f8c8bac623d060254b01fb6b329d0407f1271eb2c16ecf56f6bac5de73dab988a1524dfb98bfff960eba5e54fa01547fea0d
initialize repo
"###);
let op_log_lines = op_log_stdout.lines().collect_vec();

View file

@ -127,7 +127,7 @@ fn test_debug_operation_id() {
let stdout =
test_env.jj_cmd_success(&workspace_path, &["debug", "operation", "--display", "id"]);
assert_snapshot!(filter_index_stats(&stdout), @r###"
19b8089fc78b7c49171f3c8934248be6f89f52311005e961cab5780f9f138b142456d77b27d223d7ee84d21d8c30c4a80100eaf6735b548b1acd0da688f94c80
90e23f7e6c7ce885df899e0b4990b39a43816549596a834b727d7eed9650cfe917ac2d043518734223fd7537b9d464e556d28e73cdfed7a0aceb592b89fdba4b
"###
);
}

View file

@ -38,12 +38,12 @@ fn test_op_log() {
],
);
insta::assert_snapshot!(&stdout, @r###"
@ 98f7262e4a06 test-username@host.example.com 2001-02-03 04:05:08.000 +07:00 - 2001-02-03 04:05:08.000 +07:00
@ 00cc30b6a1b8 test-username@host.example.com 2001-02-03 04:05:08.000 +07:00 - 2001-02-03 04:05:08.000 +07:00
describe commit 230dd059e1b059aefc0da06a2e5a7dbf22362f22
args: jj describe -m 'description 0'
19b8089fc78b test-username@host.example.com 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00
90e23f7e6c7c test-username@host.example.com 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00
add workspace 'default'
f1c462c494be test-username@host.example.com 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00
b73abeebcf94 test-username@host.example.com 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00
initialize repo
"###);
let op_log_lines = stdout.lines().collect_vec();
@ -115,9 +115,9 @@ fn test_op_log_no_graph() {
let stdout =
test_env.jj_cmd_success(&repo_path, &["op", "log", "--no-graph", "--color=always"]);
insta::assert_snapshot!(stdout, @r###"
19b8089fc78b test-username@host.example.com 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00
90e23f7e6c7c test-username@host.example.com 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00
add workspace 'default'
f1c462c494be test-username@host.example.com 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00
b73abeebcf94 test-username@host.example.com 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00
initialize repo
"###);
}
@ -140,7 +140,7 @@ fn test_op_log_no_graph_null_terminated() {
r#"id.short(4) ++ "\0""#,
],
);
insta::assert_debug_snapshot!(stdout, @r###""c8b0\07277\019b8\0f1c4\0""###);
insta::assert_debug_snapshot!(stdout, @r###""6dec\08542\090e2\0b73a\0""###);
}
#[test]
@ -151,14 +151,14 @@ fn test_op_log_template() {
let render = |template| test_env.jj_cmd_success(&repo_path, &["op", "log", "-T", template]);
insta::assert_snapshot!(render(r#"id ++ "\n""#), @r###"
@ 19b8089fc78b7c49171f3c8934248be6f89f52311005e961cab5780f9f138b142456d77b27d223d7ee84d21d8c30c4a80100eaf6735b548b1acd0da688f94c80
f1c462c494be39f6690928603c5393f908866bc8d81d8cd1ae0bb2ea02cb4f78cafa47165fa5b7cda258e2178f846881de199066991960a80954ba6066ba0821
@ 90e23f7e6c7ce885df899e0b4990b39a43816549596a834b727d7eed9650cfe917ac2d043518734223fd7537b9d464e556d28e73cdfed7a0aceb592b89fdba4b
b73abeebcf94a1528dfeeed335d6f8c8bac623d060254b01fb6b329d0407f1271eb2c16ecf56f6bac5de73dab988a1524dfb98bfff960eba5e54fa01547fea0d
"###);
insta::assert_snapshot!(
render(r#"separate(" ", id.short(5), current_operation, user,
time.start(), time.end(), time.duration()) ++ "\n""#), @r###"
@ 19b80 true test-username@host.example.com 2001-02-03 04:05:07.000 +07:00 2001-02-03 04:05:07.000 +07:00 less than a microsecond
f1c46 false test-username@host.example.com 2001-02-03 04:05:07.000 +07:00 2001-02-03 04:05:07.000 +07:00 less than a microsecond
@ 90e23 true test-username@host.example.com 2001-02-03 04:05:07.000 +07:00 2001-02-03 04:05:07.000 +07:00 less than a microsecond
b73ab false test-username@host.example.com 2001-02-03 04:05:07.000 +07:00 2001-02-03 04:05:07.000 +07:00 less than a microsecond
"###);
// Negative length shouldn't cause panic (and is clamped.)
@ -180,9 +180,9 @@ fn test_op_log_template() {
let regex = Regex::new(r"\d\d years").unwrap();
let stdout = test_env.jj_cmd_success(&repo_path, &["op", "log"]);
insta::assert_snapshot!(regex.replace_all(&stdout, "NN years"), @r###"
@ 19b8089fc78b test-username@host.example.com NN years ago, lasted less than a microsecond
@ 90e23f7e6c7c test-username@host.example.com NN years ago, lasted less than a microsecond
add workspace 'default'
f1c462c494be test-username@host.example.com NN years ago, lasted less than a microsecond
b73abeebcf94 test-username@host.example.com NN years ago, lasted less than a microsecond
initialize repo
"###);
}
@ -196,24 +196,24 @@ fn test_op_log_builtin_templates() {
test_env.jj_cmd_ok(&repo_path, &["describe", "-m", "description 0"]);
insta::assert_snapshot!(render(r#"builtin_op_log_compact"#), @r###"
@ 98f7262e4a06 test-username@host.example.com 2001-02-03 04:05:08.000 +07:00 - 2001-02-03 04:05:08.000 +07:00
@ 00cc30b6a1b8 test-username@host.example.com 2001-02-03 04:05:08.000 +07:00 - 2001-02-03 04:05:08.000 +07:00
describe commit 230dd059e1b059aefc0da06a2e5a7dbf22362f22
args: jj describe -m 'description 0'
19b8089fc78b test-username@host.example.com 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00
90e23f7e6c7c test-username@host.example.com 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00
add workspace 'default'
f1c462c494be test-username@host.example.com 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00
b73abeebcf94 test-username@host.example.com 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00
initialize repo
"###);
insta::assert_snapshot!(render(r#"builtin_op_log_comfortable"#), @r###"
@ 98f7262e4a06 test-username@host.example.com 2001-02-03 04:05:08.000 +07:00 - 2001-02-03 04:05:08.000 +07:00
@ 00cc30b6a1b8 test-username@host.example.com 2001-02-03 04:05:08.000 +07:00 - 2001-02-03 04:05:08.000 +07:00
describe commit 230dd059e1b059aefc0da06a2e5a7dbf22362f22
args: jj describe -m 'description 0'
19b8089fc78b test-username@host.example.com 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00
90e23f7e6c7c test-username@host.example.com 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00
add workspace 'default'
f1c462c494be test-username@host.example.com 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00
b73abeebcf94 test-username@host.example.com 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00
initialize repo
"###);
@ -240,18 +240,18 @@ fn test_op_log_word_wrap() {
// ui.log-word-wrap option works
insta::assert_snapshot!(render(&["op", "log"], 40, false), @r###"
@ 19b8089fc78b test-username@host.example.com 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00
@ 90e23f7e6c7c test-username@host.example.com 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00
add workspace 'default'
f1c462c494be test-username@host.example.com 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00
b73abeebcf94 test-username@host.example.com 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00
initialize repo
"###);
insta::assert_snapshot!(render(&["op", "log"], 40, true), @r###"
@ 19b8089fc78b
@ 90e23f7e6c7c
test-username@host.example.com
2001-02-03 04:05:07.000 +07:00 -
2001-02-03 04:05:07.000 +07:00
add workspace 'default'
f1c462c494be
b73abeebcf94
test-username@host.example.com
2001-02-03 04:05:07.000 +07:00 -
2001-02-03 04:05:07.000 +07:00
@ -288,15 +288,15 @@ fn test_op_abandon_ancestors() {
test_env.jj_cmd_ok(&repo_path, &["commit", "-m", "commit 1"]);
test_env.jj_cmd_ok(&repo_path, &["commit", "-m", "commit 2"]);
insta::assert_snapshot!(test_env.jj_cmd_success(&repo_path, &["op", "log"]), @r###"
@ bacc8030a969 test-username@host.example.com 2001-02-03 04:05:09.000 +07:00 - 2001-02-03 04:05:09.000 +07:00
@ 362b35cdcee0 test-username@host.example.com 2001-02-03 04:05:09.000 +07:00 - 2001-02-03 04:05:09.000 +07:00
commit a8ac27b29a157ae7dabc0deb524df68823505730
args: jj commit -m 'commit 2'
bb26fe31d66f test-username@host.example.com 2001-02-03 04:05:08.000 +07:00 - 2001-02-03 04:05:08.000 +07:00
b46d00bc0741 test-username@host.example.com 2001-02-03 04:05:08.000 +07:00 - 2001-02-03 04:05:08.000 +07:00
commit 230dd059e1b059aefc0da06a2e5a7dbf22362f22
args: jj commit -m 'commit 1'
19b8089fc78b test-username@host.example.com 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00
90e23f7e6c7c test-username@host.example.com 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00
add workspace 'default'
f1c462c494be test-username@host.example.com 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00
b73abeebcf94 test-username@host.example.com 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00
initialize repo
"###);
@ -307,14 +307,14 @@ fn test_op_abandon_ancestors() {
"###);
insta::assert_snapshot!(
test_env.jj_cmd_success(&repo_path, &["debug", "workingcopy", "--ignore-working-copy"]), @r###"
Current operation: OperationId("fb5252a68411468f5e3cf480a75b8b54d8ca9231406a3d0ddc4dfb31d851839a855aca5615ba4b09018fe45d11a04e1c051817a98de1c1ef5dd75cb6c2c09ba8")
Current operation: OperationId("3a0226ca7b0f364650c64a8b8ffe3c9802c5db40d9cc19387a29a28826ccada0dd4ec6926e649c5eb3c8150ebd5cd8ffb3c2c8922445c5dc8ccf474cd83d0d9c")
Current tree: Legacy(TreeId("4b825dc642cb6eb9a060e54bf8d69288fbee4904"))
"###);
insta::assert_snapshot!(test_env.jj_cmd_success(&repo_path, &["op", "log"]), @r###"
@ fb5252a68411 test-username@host.example.com 2001-02-03 04:05:09.000 +07:00 - 2001-02-03 04:05:09.000 +07:00
@ 3a0226ca7b0f test-username@host.example.com 2001-02-03 04:05:09.000 +07:00 - 2001-02-03 04:05:09.000 +07:00
commit a8ac27b29a157ae7dabc0deb524df68823505730
args: jj commit -m 'commit 2'
f1c462c494be test-username@host.example.com 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00
b73abeebcf94 test-username@host.example.com 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00
initialize repo
"###);
@ -327,13 +327,13 @@ fn test_op_abandon_ancestors() {
Abandoned 2 operations and reparented 1 descendant operations.
"###);
insta::assert_snapshot!(test_env.jj_cmd_success(&repo_path, &["op", "log"]), @r###"
@ ee40c9ad806a test-username@host.example.com 2001-02-03 04:05:16.000 +07:00 - 2001-02-03 04:05:16.000 +07:00
@ 54d9d0dfc198 test-username@host.example.com 2001-02-03 04:05:16.000 +07:00 - 2001-02-03 04:05:16.000 +07:00
commit e184d62c9ab118b0f62de91959b857550a9273a5
args: jj commit -m 'commit 5'
fb5252a68411 test-username@host.example.com 2001-02-03 04:05:09.000 +07:00 - 2001-02-03 04:05:09.000 +07:00
3a0226ca7b0f test-username@host.example.com 2001-02-03 04:05:09.000 +07:00 - 2001-02-03 04:05:09.000 +07:00
commit a8ac27b29a157ae7dabc0deb524df68823505730
args: jj commit -m 'commit 2'
f1c462c494be test-username@host.example.com 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00
b73abeebcf94 test-username@host.example.com 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00
initialize repo
"###);
@ -358,17 +358,17 @@ fn test_op_abandon_ancestors() {
"###);
insta::assert_snapshot!(
test_env.jj_cmd_success(&repo_path, &["debug", "workingcopy", "--ignore-working-copy"]), @r###"
Current operation: OperationId("571221174898ef510c580f96bfb54f720bcfe0cd457e2ac5531d511fd10762b883f89b06c4ce5a8924db74406ddb59adbc2cbe0204540c7749ca24ded3fce94b")
Current operation: OperationId("25cd03cd1029c1d22ea67cc11b89d357000bae5836f482be46d054220b1b08852713e32d0eec542bb275803214415ef8bb25b65a740fbc5c7b37094a311cac7c")
Current tree: Legacy(TreeId("4b825dc642cb6eb9a060e54bf8d69288fbee4904"))
"###);
insta::assert_snapshot!(test_env.jj_cmd_success(&repo_path, &["op", "log"]), @r###"
@ 571221174898 test-username@host.example.com 2001-02-03 04:05:21.000 +07:00 - 2001-02-03 04:05:21.000 +07:00
undo operation ee40c9ad806a7d42f351beab5aa81a8ac38d926d02711c059229bf6a7388b7b4a7c04c004067ee6c5b6253e8398fa82bc74d0d621f8bc2c8c11f33d445f90b77
@ 25cd03cd1029 test-username@host.example.com 2001-02-03 04:05:21.000 +07:00 - 2001-02-03 04:05:21.000 +07:00
undo operation 54d9d0dfc198e3550d04acd89329f8b49765a94c4c85239ee44d6a602127ac658ed91933ad32211cc26e32b3ef2f384e9e0bab471327338fb1b3f04df7916cc2
args: jj undo
fb5252a68411 test-username@host.example.com 2001-02-03 04:05:09.000 +07:00 - 2001-02-03 04:05:09.000 +07:00
3a0226ca7b0f test-username@host.example.com 2001-02-03 04:05:09.000 +07:00 - 2001-02-03 04:05:09.000 +07:00
commit a8ac27b29a157ae7dabc0deb524df68823505730
args: jj commit -m 'commit 2'
f1c462c494be test-username@host.example.com 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00
b73abeebcf94 test-username@host.example.com 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00
initialize repo
"###);
@ -378,8 +378,8 @@ fn test_op_abandon_ancestors() {
Nothing changed.
"###);
insta::assert_snapshot!(test_env.jj_cmd_success(&repo_path, &["op", "log", "-l1"]), @r###"
@ 571221174898 test-username@host.example.com 2001-02-03 04:05:21.000 +07:00 - 2001-02-03 04:05:21.000 +07:00
undo operation ee40c9ad806a7d42f351beab5aa81a8ac38d926d02711c059229bf6a7388b7b4a7c04c004067ee6c5b6253e8398fa82bc74d0d621f8bc2c8c11f33d445f90b77
@ 25cd03cd1029 test-username@host.example.com 2001-02-03 04:05:21.000 +07:00 - 2001-02-03 04:05:21.000 +07:00
undo operation 54d9d0dfc198e3550d04acd89329f8b49765a94c4c85239ee44d6a602127ac658ed91933ad32211cc26e32b3ef2f384e9e0bab471327338fb1b3f04df7916cc2
args: jj undo
"###);
}
@ -404,12 +404,12 @@ fn test_op_abandon_without_updating_working_copy() {
"###);
insta::assert_snapshot!(
test_env.jj_cmd_success(&repo_path, &["debug", "workingcopy", "--ignore-working-copy"]), @r###"
Current operation: OperationId("a6a87becb46cb138b33b8bc238ff066e1141da3e988574260ab54db676a68a070a592cacfd37e06177f604882f7de01189e2efb75148bc00ee5f9f55513feb26")
Current operation: OperationId("324622dffebde1f5b9c75347254d0481aa5f51931816782a8a5c0578fe74893fbf63ba7921e94f44058b1e1162e932648146136b4c13236cf2eccc42347e6dcf")
Current tree: Legacy(TreeId("4b825dc642cb6eb9a060e54bf8d69288fbee4904"))
"###);
insta::assert_snapshot!(
test_env.jj_cmd_success(&repo_path, &["op", "log", "-l1", "--ignore-working-copy"]), @r###"
@ 5dca1e30e810 test-username@host.example.com 2001-02-03 04:05:10.000 +07:00 - 2001-02-03 04:05:10.000 +07:00
@ bc4e5d99e86e test-username@host.example.com 2001-02-03 04:05:10.000 +07:00 - 2001-02-03 04:05:10.000 +07:00
commit 268f5f16139313ff25bef31280b2ec2e675200f3
args: jj commit -m 'commit 3'
"###);
@ -420,16 +420,16 @@ fn test_op_abandon_without_updating_working_copy() {
let (_stdout, stderr) = test_env.jj_cmd_ok(&repo_path, &["op", "abandon", "@-"]);
insta::assert_snapshot!(stderr, @r###"
Abandoned 1 operations and reparented 1 descendant operations.
The working copy operation a6a87becb46c is not updated because it differs from the repo 5dca1e30e810.
The working copy operation 324622dffebd is not updated because it differs from the repo bc4e5d99e86e.
"###);
insta::assert_snapshot!(
test_env.jj_cmd_success(&repo_path, &["debug", "workingcopy", "--ignore-working-copy"]), @r###"
Current operation: OperationId("a6a87becb46cb138b33b8bc238ff066e1141da3e988574260ab54db676a68a070a592cacfd37e06177f604882f7de01189e2efb75148bc00ee5f9f55513feb26")
Current operation: OperationId("324622dffebde1f5b9c75347254d0481aa5f51931816782a8a5c0578fe74893fbf63ba7921e94f44058b1e1162e932648146136b4c13236cf2eccc42347e6dcf")
Current tree: Legacy(TreeId("4b825dc642cb6eb9a060e54bf8d69288fbee4904"))
"###);
insta::assert_snapshot!(
test_env.jj_cmd_success(&repo_path, &["op", "log", "-l1", "--ignore-working-copy"]), @r###"
@ e3b64811d26b test-username@host.example.com 2001-02-03 04:05:10.000 +07:00 - 2001-02-03 04:05:10.000 +07:00
@ d7c3591bc1df test-username@host.example.com 2001-02-03 04:05:10.000 +07:00 - 2001-02-03 04:05:10.000 +07:00
commit 268f5f16139313ff25bef31280b2ec2e675200f3
args: jj commit -m 'commit 3'
"###);

View file

@ -275,14 +275,14 @@ fn test_workspaces_conflicting_edits() {
"###);
let stderr = test_env.jj_cmd_failure(&secondary_path, &["st"]);
insta::assert_snapshot!(stderr, @r###"
Error: The working copy is stale (not updated since operation 5c95db542ebd).
Error: The working copy is stale (not updated since operation 86c5150a3a9c).
Hint: Run `jj workspace update-stale` to update it.
See https://github.com/martinvonz/jj/blob/main/docs/working-copy.md#stale-working-copy for more information.
"###);
// Same error on second run, and from another command
let stderr = test_env.jj_cmd_failure(&secondary_path, &["log"]);
insta::assert_snapshot!(stderr, @r###"
Error: The working copy is stale (not updated since operation 5c95db542ebd).
Error: The working copy is stale (not updated since operation 86c5150a3a9c).
Hint: Run `jj workspace update-stale` to update it.
See https://github.com/martinvonz/jj/blob/main/docs/working-copy.md#stale-working-copy for more information.
"###);
@ -362,7 +362,7 @@ fn test_workspaces_updated_by_other() {
"###);
let stderr = test_env.jj_cmd_failure(&secondary_path, &["st"]);
insta::assert_snapshot!(stderr, @r###"
Error: The working copy is stale (not updated since operation 5c95db542ebd).
Error: The working copy is stale (not updated since operation 86c5150a3a9c).
Hint: Run `jj workspace update-stale` to update it.
See https://github.com/martinvonz/jj/blob/main/docs/working-copy.md#stale-working-copy for more information.
"###);
@ -543,7 +543,7 @@ fn test_workspaces_forget_multi_transaction() {
// the op log should have multiple workspaces forgotten in a single tx
let stdout = test_env.jj_cmd_success(&main_path, &["op", "log", "--limit", "1"]);
insta::assert_snapshot!(stdout, @r###"
@ e18f223ba3d3 test-username@host.example.com 2001-02-03 04:05:12.000 +07:00 - 2001-02-03 04:05:12.000 +07:00
@ a2acfd91b649 test-username@host.example.com 2001-02-03 04:05:12.000 +07:00 - 2001-02-03 04:05:12.000 +07:00
forget workspaces second, third
args: jj workspace forget second third
"###);

View file

@ -268,8 +268,6 @@ content_hash! {
pub struct View {
/// All head commits
pub head_ids: HashSet<CommitId>,
/// Heads of the set of public commits.
pub public_head_ids: HashSet<CommitId>,
pub local_branches: BTreeMap<String, RefTarget>,
pub tags: BTreeMap<String, RefTarget>,
pub remote_views: BTreeMap<String, RemoteView>,

View file

@ -77,7 +77,7 @@ message Tag {
message View {
repeated bytes head_ids = 1;
repeated bytes public_head_ids = 4;
reserved 4;
bytes wc_commit_id = 2 [deprecated = true];
map<string, bytes> wc_commit_ids = 8;
repeated Branch branches = 5;

View file

@ -98,8 +98,6 @@ pub struct Tag {
pub struct View {
#[prost(bytes = "vec", repeated, tag = "1")]
pub head_ids: ::prost::alloc::vec::Vec<::prost::alloc::vec::Vec<u8>>,
#[prost(bytes = "vec", repeated, tag = "4")]
pub public_head_ids: ::prost::alloc::vec::Vec<::prost::alloc::vec::Vec<u8>>,
#[deprecated]
#[prost(bytes = "vec", tag = "2")]
pub wc_commit_id: ::prost::alloc::vec::Vec<u8>,

View file

@ -169,9 +169,6 @@ impl ReadonlyRepo {
let mut root_view = op_store::View::default();
root_view.head_ids.insert(store.root_commit_id().clone());
root_view
.public_head_ids
.insert(store.root_commit_id().clone());
let op_heads_path = repo_path.join("op_heads");
fs::create_dir(&op_heads_path).context(&op_heads_path)?;
@ -1020,13 +1017,7 @@ impl MutableRepo {
fn enforce_view_invariants(&self, view: &mut View) {
let view = view.store_view_mut();
view.public_head_ids = self
.index()
.heads(&mut view.public_head_ids.iter())
.iter()
.cloned()
.collect();
view.head_ids.extend(view.public_head_ids.iter().cloned());
view.head_ids.insert(self.store().root_commit_id().clone());
view.head_ids = self
.index()
.heads(&mut view.head_ids.iter())
@ -1101,16 +1092,6 @@ impl MutableRepo {
self.view.mark_dirty();
}
pub fn add_public_head(&mut self, head: &Commit) {
self.view_mut().add_public_head(head.id());
self.view.mark_dirty();
}
pub fn remove_public_head(&mut self, head: &CommitId) {
self.view_mut().remove_public_head(head);
self.view.mark_dirty();
}
/// Returns true if any local or remote branch of the given `name` exists.
#[must_use]
pub fn has_branch(&self, name: &str) -> bool {
@ -1278,13 +1259,6 @@ impl MutableRepo {
}
}
for removed_head in base.public_heads().difference(other.public_heads()) {
self.view_mut().remove_public_head(removed_head);
}
for added_head in other.public_heads().difference(base.public_heads()) {
self.view_mut().add_public_head(added_head);
}
let base_heads = base.heads().iter().cloned().collect_vec();
let own_heads = self.view().heads().iter().cloned().collect_vec();
let other_heads = other.heads().iter().cloned().collect_vec();

View file

@ -384,9 +384,6 @@ fn view_to_proto(view: &View) -> crate::protos::op_store::View {
for head_id in &view.head_ids {
proto.head_ids.push(head_id.to_bytes());
}
for head_id in &view.public_head_ids {
proto.public_head_ids.push(head_id.to_bytes());
}
proto.branches = branch_views_to_proto_legacy(&view.local_branches, &view.remote_views);
@ -426,9 +423,6 @@ fn view_from_proto(proto: crate::protos::op_store::View) -> View {
for head_id_bytes in proto.head_ids {
view.head_ids.insert(CommitId::new(head_id_bytes));
}
for head_id_bytes in proto.public_head_ids {
view.public_head_ids.insert(CommitId::new(head_id_bytes));
}
let (local_branches, remote_views) = branch_views_from_proto_legacy(proto.branches);
view.local_branches = local_branches;
@ -677,8 +671,6 @@ mod tests {
};
let head_id1 = CommitId::from_hex("aaa111");
let head_id2 = CommitId::from_hex("aaa222");
let public_head_id1 = CommitId::from_hex("bbb444");
let public_head_id2 = CommitId::from_hex("bbb555");
let branch_main_local_target = RefTarget::normal(CommitId::from_hex("ccc111"));
let branch_main_origin_target = RefTarget::normal(CommitId::from_hex("ccc222"));
let branch_deleted_origin_target = RefTarget::normal(CommitId::from_hex("ccc333"));
@ -692,7 +684,6 @@ mod tests {
let test_wc_commit_id = CommitId::from_hex("abc222");
View {
head_ids: hashset! {head_id1, head_id2},
public_head_ids: hashset! {public_head_id1, public_head_id2},
local_branches: btreemap! {
"main".to_string() => branch_main_local_target,
},
@ -751,7 +742,7 @@ mod tests {
// Test exact output so we detect regressions in compatibility
assert_snapshot!(
ViewId::new(blake2b_hash(&create_view()).to_vec()).hex(),
@"d6d19f3edcb3b2fed6104801b7938e6be1147ab036e9fa81b7624fd5ff0149a6c221c3abb6fb7380c3f37e077a03b234313b44cbb6faca0b8c76f68f24ea7174"
@"19af495b5a828c38e933c518a53eb9f7fb7129348a0950d7971b86adf7eb25a13bf45c7f358da1776b27fe6f4bc9134787389d976b768e46ac6cef56bc20c083"
);
}

View file

@ -62,10 +62,6 @@ impl View {
&self.data.head_ids
}
pub fn public_heads(&self) -> &HashSet<CommitId> {
&self.data.public_head_ids
}
/// Iterates pair of local and remote branches by branch name.
pub fn branches(&self) -> impl Iterator<Item = (&str, BranchTarget<'_>)> {
op_store::merge_join_branch_views(&self.data.local_branches, &self.data.remote_views)
@ -99,14 +95,6 @@ impl View {
self.data.head_ids.remove(head_id);
}
pub fn add_public_head(&mut self, head_id: &CommitId) {
self.data.public_head_ids.insert(head_id.clone());
}
pub fn remove_public_head(&mut self, head_id: &CommitId) {
self.data.public_head_ids.remove(head_id);
}
/// Returns true if any local or remote branch of the given `name` exists.
#[must_use]
pub fn has_branch(&self, name: &str) -> bool {
@ -330,7 +318,6 @@ impl View {
// not be smart here. Callers will build a larger set of commits anyway.
let op_store::View {
head_ids,
public_head_ids,
local_branches,
tags,
remote_views,
@ -340,7 +327,6 @@ impl View {
} = &self.data;
itertools::chain!(
head_ids,
public_head_ids,
local_branches.values().flat_map(ref_target_ids),
tags.values().flat_map(ref_target_ids),
remote_views.values().flat_map(|remote_view| {

View file

@ -366,74 +366,6 @@ fn test_remove_head() {
assert!(repo.index().has_id(commit3.id()));
}
#[test]
fn test_add_public_head() {
// Test that MutableRepo::add_public_head() adds the head, and that it's still
// there after commit.
let settings = testutils::user_settings();
let test_repo = TestRepo::init();
let repo = &test_repo.repo;
let mut tx = repo.start_transaction(&settings);
let commit1 = write_random_commit(tx.mut_repo(), &settings);
let repo = tx.commit("test");
let mut tx = repo.start_transaction(&settings);
let mut_repo = tx.mut_repo();
assert!(!mut_repo.view().public_heads().contains(commit1.id()));
mut_repo.add_public_head(&commit1);
assert!(mut_repo.view().public_heads().contains(commit1.id()));
let repo = tx.commit("test");
assert!(repo.view().public_heads().contains(commit1.id()));
}
#[test]
fn test_add_public_head_ancestor() {
// Test that MutableRepo::add_public_head() does not add a public head if it's
// an ancestor of an existing public head.
let settings = testutils::user_settings();
let test_repo = TestRepo::init();
let repo = &test_repo.repo;
let mut tx = repo.start_transaction(&settings);
let mut graph_builder = CommitGraphBuilder::new(&settings, tx.mut_repo());
let commit1 = graph_builder.initial_commit();
let commit2 = graph_builder.commit_with_parents(&[&commit1]);
tx.mut_repo().add_public_head(&commit2);
let repo = tx.commit("test");
let mut tx = repo.start_transaction(&settings);
let mut_repo = tx.mut_repo();
assert!(!mut_repo.view().public_heads().contains(commit1.id()));
mut_repo.add_public_head(&commit1);
assert!(!mut_repo.view().public_heads().contains(commit1.id()));
let repo = tx.commit("test");
assert!(!repo.view().public_heads().contains(commit1.id()));
}
#[test]
fn test_remove_public_head() {
// Test that MutableRepo::remove_public_head() removes the head, and that it's
// still removed after commit.
let settings = testutils::user_settings();
let test_repo = TestRepo::init();
let repo = &test_repo.repo;
let mut tx = repo.start_transaction(&settings);
let mut_repo = tx.mut_repo();
let commit1 = write_random_commit(mut_repo, &settings);
mut_repo.add_public_head(&commit1);
let repo = tx.commit("test");
let mut tx = repo.start_transaction(&settings);
let mut_repo = tx.mut_repo();
assert!(mut_repo.view().public_heads().contains(commit1.id()));
mut_repo.remove_public_head(commit1.id());
assert!(!mut_repo.view().public_heads().contains(commit1.id()));
let repo = tx.commit("test");
assert!(!repo.view().public_heads().contains(commit1.id()));
}
#[test]
fn test_has_changed() {
// Test that MutableRepo::has_changed() reports changes iff the view has changed
@ -452,7 +384,6 @@ fn test_has_changed() {
let commit1 = write_random_commit(mut_repo, &settings);
let commit2 = write_random_commit(mut_repo, &settings);
mut_repo.remove_head(commit2.id());
mut_repo.add_public_head(&commit1);
let ws_id = WorkspaceId::default();
mut_repo
.set_wc_commit(ws_id.clone(), commit1.id().clone())
@ -462,12 +393,10 @@ fn test_has_changed() {
let repo = tx.commit("test");
// Test the setup
assert_eq!(repo.view().heads(), &hashset! {commit1.id().clone()});
assert_eq!(repo.view().public_heads(), &hashset! {commit1.id().clone()});
let mut tx = repo.start_transaction(&settings);
let mut_repo = tx.mut_repo();
mut_repo.add_public_head(&commit1);
mut_repo.add_head(&commit1).unwrap();
mut_repo
.set_wc_commit(ws_id.clone(), commit1.id().clone())
@ -476,7 +405,6 @@ fn test_has_changed() {
mut_repo.set_remote_branch("main", "origin", normal_remote_ref(commit1.id()));
assert!(!mut_repo.has_changes());
mut_repo.remove_public_head(commit2.id());
mut_repo.remove_head(commit2.id());
mut_repo.set_local_branch_target("stable", RefTarget::absent());
mut_repo.set_remote_branch("stable", "origin", RemoteRef::absent());
@ -487,16 +415,6 @@ fn test_has_changed() {
mut_repo.remove_head(commit2.id());
assert!(!mut_repo.has_changes());
mut_repo.add_public_head(&commit2);
assert!(mut_repo.has_changes());
mut_repo.remove_public_head(commit2.id());
// The commit was added as a visible head when we called has_changes() above.
// That's a weird side-effect.
// TODO: Should we make add_public_head() also add it as a visible head? Or
// should we decouple the two sets completely?
mut_repo.remove_head(commit2.id());
assert!(!mut_repo.has_changes());
mut_repo
.set_wc_commit(ws_id.clone(), commit2.id().clone())
.unwrap();

View file

@ -441,15 +441,15 @@ fn test_resolve_op_id() {
repo = tx.commit(format!("transaction {i}"));
operations.push(repo.operation().clone());
}
// "2" is ambiguous
// "8" is ambiguous
insta::assert_debug_snapshot!(operations.iter().map(|op| op.id().hex()).collect_vec(), @r###"
[
"27f8c802c8378c5c85825365e83928936ae84d7ae3b5bd26d1cd046aa9a2f791dd7b272338d0d2da8a4359523f25daf217f99128a155ba4bc728d279fc3d8f7f",
"8a6b19ed474dfad1efa49d64d265f80f74c1d10bf77439900d92d8e6a29fdb64ad1137a92928bfd409096bf84b6fbfb50ebdcc6a28323f9f8e5893548f21b7fb",
"65198b538e0f6558d875c49712b0b3570e3a0eb697fd22f5817e39139937b4498e9e9080df1353e116880e36c683f5dddc39d048007ef50da83690a94502bc68",
"59da2544953d8d5851e8f64ed5949c8c26f676b87ab84e9fe153bca76912de3753dee8c9cb641f53f57c51a0e876cd43f08c28ca651ad312e5bc09354e9ec40f",
"f40d12f62b921bdf96c2d191a4d04845fa26043d131ea1e69eb06fa7a4bbfed6668ab48bed7ec728f7e2c9e675d394b382a332c68399d7f4c446450610479ecf",
"2b45a4f90854dd3d4833d998f4fa2e4d4c4eda5212edd3845e8ccb3618d9d538d7a98c173791995898e68d272697ffed1b69838cf839d96cb770856cf499eea8",
"c304846fd5419130f961dc29a19e382ba1b48eeef92505da2f6be65c09a5321e36b3642bc8bf052cd47c2f0fa6cb103a837fc0d6b86a2ab5ef18c7ecfa6bec38",
"bffef6b286529cdebb9e48e209ea0eef96989bb23d8af4773847564d0b3b7961676ad9e23ddcd46774712198f5b3e28c2eb4fbba159ac640919b0c5f7d5a71d8",
"98d92c1e65617b594741968302d7225238f9f13e8126a6e12ee73f17def310a7b5be75a0d761399e2a9f3d13f066a274a4f40e6b9d588824da606a8888854f62",
"34d4b6ec40a425036a3e267cbe61ddc99582a1ec2601501d19a6a6c402d255aef5109ddc5bb6a79afaa17acc56a2e04bba8e69ef90a764aebb769f5038d24b64",
"89f50ea6a566fc5794164653511f35c40011321989a2499a6aec18780f0110cb5ce0fc0b248026cb32aa2b6a017a65a9472c497920933d13f68a95211c30bf2d",
"8913bd72461b92b2323b49a8789219f842942fd2040ddc078a4b7f731630f4bce8dabf181c3c55a3c54950023c04f6fc8f4174b92e9953230592a534222a5297",
]
"###);
@ -470,7 +470,7 @@ fn test_resolve_op_id() {
);
// Ambiguous id
assert_matches!(
op_walk::resolve_op_with_repo(&repo, "2"),
op_walk::resolve_op_with_repo(&repo, "8"),
Err(OpsetEvaluationError::OpsetResolution(
OpsetResolutionError::AmbiguousIdPrefix(_)
))

View file

@ -31,10 +31,6 @@ fn test_heads_empty() {
*repo.view().heads(),
hashset! {repo.store().root_commit_id().clone()}
);
assert_eq!(
*repo.view().public_heads(),
hashset! {repo.store().root_commit_id().clone()}
);
}
#[test]
@ -88,29 +84,15 @@ fn test_merge_views_heads() {
let head_unchanged = write_random_commit(mut_repo, &settings);
let head_remove_tx1 = write_random_commit(mut_repo, &settings);
let head_remove_tx2 = write_random_commit(mut_repo, &settings);
let public_head_unchanged = write_random_commit(mut_repo, &settings);
mut_repo.add_public_head(&public_head_unchanged);
let public_head_remove_tx1 = write_random_commit(mut_repo, &settings);
mut_repo.add_public_head(&public_head_remove_tx1);
let public_head_remove_tx2 = write_random_commit(mut_repo, &settings);
mut_repo.add_public_head(&public_head_remove_tx2);
let repo = tx.commit("test");
let mut tx1 = repo.start_transaction(&settings);
tx1.mut_repo().remove_head(head_remove_tx1.id());
tx1.mut_repo()
.remove_public_head(public_head_remove_tx1.id());
let head_add_tx1 = write_random_commit(tx1.mut_repo(), &settings);
let public_head_add_tx1 = write_random_commit(tx1.mut_repo(), &settings);
tx1.mut_repo().add_public_head(&public_head_add_tx1);
let mut tx2 = repo.start_transaction(&settings);
tx2.mut_repo().remove_head(head_remove_tx2.id());
tx2.mut_repo()
.remove_public_head(public_head_remove_tx2.id());
let head_add_tx2 = write_random_commit(tx2.mut_repo(), &settings);
let public_head_add_tx2 = write_random_commit(tx2.mut_repo(), &settings);
tx2.mut_repo().add_public_head(&public_head_add_tx2);
let repo = commit_transactions(&settings, vec![tx1, tx2]);
@ -118,20 +100,8 @@ fn test_merge_views_heads() {
head_unchanged.id().clone(),
head_add_tx1.id().clone(),
head_add_tx2.id().clone(),
public_head_unchanged.id().clone(),
public_head_remove_tx1.id().clone(),
public_head_remove_tx2.id().clone(),
public_head_add_tx1.id().clone(),
public_head_add_tx2.id().clone(),
};
assert_eq!(repo.view().heads(), &expected_heads);
let expected_public_heads = hashset! {
public_head_unchanged.id().clone(),
public_head_add_tx1.id().clone(),
public_head_add_tx2.id().clone(),
};
assert_eq!(repo.view().public_heads(), &expected_public_heads);
}
#[test]