forked from mirrors/jj
merge: simply generate content hash from interleaved values
This commit is contained in:
parent
46ffb2f0b2
commit
b07b370ed3
6 changed files with 39 additions and 47 deletions
|
@ -55,15 +55,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###"
|
||||
@ 8626e1f87784 test-username@host.example.com 2001-02-03 04:05:08.000 +07:00 - 2001-02-03 04:05:08.000 +07:00
|
||||
@ cfc96ff553b9 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
|
||||
◉ 80b17428029f test-username@host.example.com 2001-02-03 04:05:08.000 +07:00 - 2001-02-03 04:05:08.000 +07:00
|
||||
◉ 65a6c90b9544 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
|
||||
◉ d50e0e495b10 test-username@host.example.com 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00
|
||||
◉ 19b8089fc78b 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'
|
||||
◉ 23b83cc0392f test-username@host.example.com 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00
|
||||
◉ f1c462c494be 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();
|
||||
|
@ -168,21 +168,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###"
|
||||
@ 98aae8ac6dabe0f4e97b0708afd5848f22f0831d8f5be3169063120efe0769b27d123b038f505f2a78d1cd92a0b8345eee2bd201ba6d687fb8c9326dac1fcfaa
|
||||
@ 9be517934aaabc351597e88ed4119aa9454ae3588ab7f28646a810272c82f3dafb1deb20b3c978dbb58ba9abc8f08fe870fe3c7ce5f682411991e83eee40a77f
|
||||
│ commit 323b414dd255b51375d7f4392b7b2641ffe4289f
|
||||
│ args: jj commit -m 'new child1'
|
||||
◉ 13ce1be149ff5fe4386896a753f9321e1826cb6603a6310e50eb778aacbaf7080ca50e7eb3c3ddcacb3e433c619e222fe0f7637dec14551350a03b8a6959f739
|
||||
◉ d967c09eb12b38dad2065a0bc9e251824247f9f84ba406a7356f5405e4c93c21562178a3f00cafedfa1df1435ba496265f39da9d1ccebaccb78bdcb4bd7031e1
|
||||
│ snapshot working copy
|
||||
│ args: jj commit -m 'new child1'
|
||||
◉ 21126efd140dc442d7663ac963912f664dcde62b397e71bcc1628d914f454c3767a55ae16756a47793303b68099150d4a86344129e32e561f4853f283e745814
|
||||
◉ b6d168ba4fb4534257b6e58d53eb407582567342358eab07cf5a01a7e4d797313b692f27664c2fb7935b2380d398d0298233c9732f821b8c687e35607ea08a55
|
||||
│ commit 3d918700494a9895696e955b85fa05eb0d314cc6
|
||||
│ args: jj commit -m initial
|
||||
◉ f29c2903a0a18deefc8323c6e1ac8c1165c238f74ed508180a7ae77b46ba1c1be0ff13d7112d59368d56a3552564476b8595f7c2b3a6dc26aec1e926d0f280e6
|
||||
◉ 5e9e3f82fc14750ff985c5a39f1935ed8876b973b8800b56bc03d1c9754795e724956d862d1fcb2c533d06ca36abc9fa9f7cb7d3b2b64e993e9a87f80d5af670
|
||||
│ snapshot working copy
|
||||
│ args: jj commit -m initial
|
||||
◉ d50e0e495b10b2575e2a9b914fed7045e427254baec051bc769d22f607f2f55f09788e6f6c9e12a4e56ec994ac7a63decb1fa7e353b2c8fd20ce77760777283d
|
||||
◉ 19b8089fc78b7c49171f3c8934248be6f89f52311005e961cab5780f9f138b142456d77b27d223d7ee84d21d8c30c4a80100eaf6735b548b1acd0da688f94c80
|
||||
│ add workspace 'default'
|
||||
◉ 23b83cc0392f51ef6b548af289e54efbe8661fe88ab5d8c036444d8c4ec798fb9d4d6063f02c4db768b17bde4608bcae2d75ba79da91ddd59dc57a23d45b5c57
|
||||
◉ f1c462c494be39f6690928603c5393f908866bc8d81d8cd1ae0bb2ea02cb4f78cafa47165fa5b7cda258e2178f846881de199066991960a80954ba6066ba0821
|
||||
initialize repo
|
||||
"###);
|
||||
let op_log_lines = op_log_stdout.lines().collect_vec();
|
||||
|
|
|
@ -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###"
|
||||
d50e0e495b10b2575e2a9b914fed7045e427254baec051bc769d22f607f2f55f09788e6f6c9e12a4e56ec994ac7a63decb1fa7e353b2c8fd20ce77760777283d
|
||||
19b8089fc78b7c49171f3c8934248be6f89f52311005e961cab5780f9f138b142456d77b27d223d7ee84d21d8c30c4a80100eaf6735b548b1acd0da688f94c80
|
||||
"###
|
||||
);
|
||||
}
|
||||
|
|
|
@ -38,12 +38,12 @@ fn test_op_log() {
|
|||
],
|
||||
);
|
||||
insta::assert_snapshot!(&stdout, @r###"
|
||||
@ 745ab9998f2f test-username@host.example.com 2001-02-03 04:05:08.000 +07:00 - 2001-02-03 04:05:08.000 +07:00
|
||||
@ 98f7262e4a06 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'
|
||||
◉ d50e0e495b10 test-username@host.example.com 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00
|
||||
◉ 19b8089fc78b 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'
|
||||
◉ 23b83cc0392f test-username@host.example.com 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00
|
||||
◉ f1c462c494be 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();
|
||||
|
@ -139,9 +139,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###"
|
||||
[1m[38;5;12md50e0e495b10[39m [38;5;3mtest-username@host.example.com[39m [38;5;14m2001-02-03 04:05:07.000 +07:00[39m - [38;5;14m2001-02-03 04:05:07.000 +07:00[39m[0m
|
||||
[1m[38;5;12m19b8089fc78b[39m [38;5;3mtest-username@host.example.com[39m [38;5;14m2001-02-03 04:05:07.000 +07:00[39m - [38;5;14m2001-02-03 04:05:07.000 +07:00[39m[0m
|
||||
[1madd workspace 'default'[0m
|
||||
[38;5;4m23b83cc0392f[39m [38;5;3mtest-username@host.example.com[39m [38;5;6m2001-02-03 04:05:07.000 +07:00[39m - [38;5;6m2001-02-03 04:05:07.000 +07:00[39m
|
||||
[38;5;4mf1c462c494be[39m [38;5;3mtest-username@host.example.com[39m [38;5;6m2001-02-03 04:05:07.000 +07:00[39m - [38;5;6m2001-02-03 04:05:07.000 +07:00[39m
|
||||
initialize repo
|
||||
"###);
|
||||
}
|
||||
|
@ -164,7 +164,7 @@ fn test_op_log_no_graph_null_terminated() {
|
|||
r#"id.short(4) ++ "\0""#,
|
||||
],
|
||||
);
|
||||
insta::assert_debug_snapshot!(stdout, @r###""16e6\0fb05\0d50e\023b8\0""###);
|
||||
insta::assert_debug_snapshot!(stdout, @r###""c8b0\07277\019b8\0f1c4\0""###);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -175,14 +175,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###"
|
||||
@ d50e0e495b10b2575e2a9b914fed7045e427254baec051bc769d22f607f2f55f09788e6f6c9e12a4e56ec994ac7a63decb1fa7e353b2c8fd20ce77760777283d
|
||||
◉ 23b83cc0392f51ef6b548af289e54efbe8661fe88ab5d8c036444d8c4ec798fb9d4d6063f02c4db768b17bde4608bcae2d75ba79da91ddd59dc57a23d45b5c57
|
||||
@ 19b8089fc78b7c49171f3c8934248be6f89f52311005e961cab5780f9f138b142456d77b27d223d7ee84d21d8c30c4a80100eaf6735b548b1acd0da688f94c80
|
||||
◉ f1c462c494be39f6690928603c5393f908866bc8d81d8cd1ae0bb2ea02cb4f78cafa47165fa5b7cda258e2178f846881de199066991960a80954ba6066ba0821
|
||||
"###);
|
||||
insta::assert_snapshot!(
|
||||
render(r#"separate(" ", id.short(5), current_operation, user,
|
||||
time.start(), time.end(), time.duration()) ++ "\n""#), @r###"
|
||||
@ d50e0 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
|
||||
◉ 23b83 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
|
||||
@ 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
|
||||
"###);
|
||||
|
||||
// Negative length shouldn't cause panic (and is clamped.)
|
||||
|
@ -204,9 +204,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###"
|
||||
@ d50e0e495b10 test-username@host.example.com NN years ago, lasted less than a microsecond
|
||||
@ 19b8089fc78b test-username@host.example.com NN years ago, lasted less than a microsecond
|
||||
│ add workspace 'default'
|
||||
◉ 23b83cc0392f test-username@host.example.com NN years ago, lasted less than a microsecond
|
||||
◉ f1c462c494be test-username@host.example.com NN years ago, lasted less than a microsecond
|
||||
initialize repo
|
||||
"###);
|
||||
}
|
||||
|
@ -220,24 +220,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###"
|
||||
@ 745ab9998f2f test-username@host.example.com 2001-02-03 04:05:08.000 +07:00 - 2001-02-03 04:05:08.000 +07:00
|
||||
@ 98f7262e4a06 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'
|
||||
◉ d50e0e495b10 test-username@host.example.com 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00
|
||||
◉ 19b8089fc78b 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'
|
||||
◉ 23b83cc0392f test-username@host.example.com 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00
|
||||
◉ f1c462c494be 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###"
|
||||
@ 745ab9998f2f test-username@host.example.com 2001-02-03 04:05:08.000 +07:00 - 2001-02-03 04:05:08.000 +07:00
|
||||
@ 98f7262e4a06 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'
|
||||
│
|
||||
◉ d50e0e495b10 test-username@host.example.com 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00
|
||||
◉ 19b8089fc78b 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'
|
||||
│
|
||||
◉ 23b83cc0392f test-username@host.example.com 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00
|
||||
◉ f1c462c494be 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
|
||||
|
||||
"###);
|
||||
|
@ -264,18 +264,18 @@ fn test_op_log_word_wrap() {
|
|||
|
||||
// ui.log-word-wrap option works
|
||||
insta::assert_snapshot!(render(&["op", "log"], 40, false), @r###"
|
||||
@ d50e0e495b10 test-username@host.example.com 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00
|
||||
@ 19b8089fc78b 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'
|
||||
◉ 23b83cc0392f test-username@host.example.com 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00
|
||||
◉ f1c462c494be 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###"
|
||||
@ d50e0e495b10
|
||||
@ 19b8089fc78b
|
||||
│ 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'
|
||||
◉ 23b83cc0392f
|
||||
◉ f1c462c494be
|
||||
test-username@host.example.com
|
||||
2001-02-03 04:05:07.000 +07:00 -
|
||||
2001-02-03 04:05:07.000 +07:00
|
||||
|
|
|
@ -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 d47ba8bebf5d).
|
||||
Error: The working copy is stale (not updated since operation 5c95db542ebd).
|
||||
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 d47ba8bebf5d).
|
||||
Error: The working copy is stale (not updated since operation 5c95db542ebd).
|
||||
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 d47ba8bebf5d).
|
||||
Error: The working copy is stale (not updated since operation 5c95db542ebd).
|
||||
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###"
|
||||
@ dd31c8d01c8b test-username@host.example.com 2001-02-03 04:05:12.000 +07:00 - 2001-02-03 04:05:12.000 +07:00
|
||||
@ e18f223ba3d3 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
|
||||
"###);
|
||||
|
|
|
@ -446,15 +446,7 @@ impl<T> Merge<Merge<T>> {
|
|||
|
||||
impl<T: ContentHash> ContentHash for Merge<T> {
|
||||
fn hash(&self, state: &mut impl digest::Update) {
|
||||
// TODO: just hash values
|
||||
state.update(&(self.removes().len() as u64).to_le_bytes());
|
||||
for value in self.removes() {
|
||||
value.hash(state);
|
||||
}
|
||||
state.update(&(self.adds().len() as u64).to_le_bytes());
|
||||
for value in self.adds() {
|
||||
value.hash(state);
|
||||
}
|
||||
self.values.hash(state)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -625,7 +625,7 @@ mod tests {
|
|||
// Test exact output so we detect regressions in compatibility
|
||||
assert_snapshot!(
|
||||
ViewId::new(blake2b_hash(&create_view()).to_vec()).hex(),
|
||||
@"7a7d8e33aff631bc3a8a281358e818f3c962d539ec2ced78a40b8221a42a707d51e546c5a6644c435b5764d8a51b29e63c3c107d5a8926d4be74288ea8ac879d"
|
||||
@"d6d19f3edcb3b2fed6104801b7938e6be1147ab036e9fa81b7624fd5ff0149a6c221c3abb6fb7380c3f37e077a03b234313b44cbb6faca0b8c76f68f24ea7174"
|
||||
);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue