forked from mirrors/jj
op_store: add metadata flag for ops representing working-copy snapshot
It should be useful at least in the presentation layer to know which operations correspond to working-copy snapshots. They might be rendered differently in the graph, for example. Or maybe an undo command wants to warn if you just undid a snapshot operation. This patch just introduces a field in the metadata to store the information.
This commit is contained in:
parent
84685a4d71
commit
11c67cf979
12 changed files with 102 additions and 83 deletions
|
@ -1412,6 +1412,7 @@ See https://github.com/martinvonz/jj/blob/main/docs/working-copy.md#stale-workin
|
|||
if new_tree_id != *wc_commit.tree_id() {
|
||||
let mut tx =
|
||||
start_repo_transaction(&self.user_repo.repo, &self.settings, &self.string_args);
|
||||
tx.set_is_snapshot(true);
|
||||
let mut_repo = tx.mut_repo();
|
||||
let commit = mut_repo
|
||||
.rewrite_commit(&self.settings, &wc_commit)
|
||||
|
|
|
@ -33,15 +33,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###"
|
||||
◉ 1e346ac76e7c test-username@host.example.com 2001-02-03 04:05:09.000 +07:00 - 2001-02-03 04:05:09.000 +07:00
|
||||
◉ bd72b691e2a8 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 @-
|
||||
│ ◉ 1fb59888922c test-username@host.example.com 2001-02-03 04:05:08.000 +07:00 - 2001-02-03 04:05:08.000 +07:00
|
||||
│ ◉ aff16879e85e 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'
|
||||
◉ 6ac4339ad699 test-username@host.example.com 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00
|
||||
◉ b51416386f26 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'
|
||||
◉ 1b0049c19762 test-username@host.example.com 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00
|
||||
◉ 9a7d829846af 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
|
||||
◉ 000000000000 root()
|
||||
"###);
|
||||
|
@ -69,15 +69,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###"
|
||||
@ d5b4f16ef469 test-username@host.example.com 2001-02-03 04:05:08.000 +07:00 - 2001-02-03 04:05:08.000 +07:00
|
||||
@ 254fed738276 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
|
||||
◉ e632e64d7fa1 test-username@host.example.com 2001-02-03 04:05:08.000 +07:00 - 2001-02-03 04:05:08.000 +07:00
|
||||
◉ 1a6e7a5002b6 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
|
||||
◉ 6ac4339ad699 test-username@host.example.com 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00
|
||||
◉ b51416386f26 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'
|
||||
◉ 1b0049c19762 test-username@host.example.com 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00
|
||||
◉ 9a7d829846af 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
|
||||
◉ 000000000000 root()
|
||||
"###);
|
||||
|
@ -184,21 +184,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###"
|
||||
@ 1578600dd63556a22abef7cf6e7054a7e07468187ba31f79d0aa6a197b17004b7cd3e19d2fab1e6a00f2520b48d41969dbbb562c60d4c4af9436224f7f14ab83
|
||||
@ 072711d601c17a74367ab8654d797d1743063208689cafad1bd43581490b4a4180916964824916c5e10d1ecdbaa0763efe79066554959978af0f7ff4b5ed66f0
|
||||
│ commit 323b414dd255b51375d7f4392b7b2641ffe4289f
|
||||
│ args: jj commit -m 'new child1'
|
||||
◉ 90bb10893e980b606939a1f45f2aadf7de1eef65589ac5cd70e20dc20dfd0073c989b5ba0de70ce79a52d27aab5f5699eba66649b531530be5d13bc12c6bd926
|
||||
◉ ab6c5b4e16160c48cabbde43a267ee6991b78668695e744b97e2ae150995458e3ea1d553550e2305028b23af62f74270dc86bd8826b36ad7f1fa7e3986cfdaa3
|
||||
│ snapshot working copy
|
||||
│ args: jj commit -m 'new child1'
|
||||
◉ 6104865e95226d46d8c6f5bf43ab025e67f88da6e27f8d8cc598c6d058e333126380c4cb25ea49c841480efee82ce2c602d87b4d3f53b85b4e704af5e83cbdc9
|
||||
◉ 6454b2aacf0821685fda129124aecd7a379bdc2da9c3f9b5e0d58da24d1300bf6a09806a572aa7040263fbe57d430aa706d9cea1f3356fe042029e53d9faa991
|
||||
│ commit 3d918700494a9895696e955b85fa05eb0d314cc6
|
||||
│ args: jj commit -m initial
|
||||
◉ 76137fc212ef44c53db04be2010ba0419db1fe30e31289bed7d1d0410bee7c3c93d8fd5f6d1b03d93801a2517c436cc1bc4cc512c740e2d88979e771a6fb3730
|
||||
◉ 8ae097b5e512914cd62b7e13b2ce27ded56ced97005b6e0232438f08b067df1272b06ad428984a6d28496df5ae41aa3522c5b54d7588abf76210922345d94b17
|
||||
│ snapshot working copy
|
||||
│ args: jj commit -m initial
|
||||
◉ 6ac4339ad6999058dd1806653ec37fc0091c1cc17419c750fddc5e8c1a6a77829e6dd70b3408403fb2c0b9839cf6bfd1c270f980674f7f89d4d78dc54082a8ef
|
||||
◉ b51416386f2685fd5493f2b20e8eec3c24a1776d9e1a7cb5ed7e30d2d9c88c0c1e1fe71b0b7358cba60de42533d1228ed9878f2f89817d892c803395ccf9fe92
|
||||
│ add workspace 'default'
|
||||
◉ 1b0049c19762e43499f2499a45afc9f72b3004d75a2863d41d8867cfafb9bbc8e16aa447107e460d58a5c1462429f032d806f7487836c66c6f351df45746c218
|
||||
◉ 9a7d829846af88a2f7a1e348fb46ff58729e49632bc9c6a052aec8501563cb0d10f4a4e6010ffde529f84a2b9b5b3a4c211a889106a41f6c076dfdacc79f6af7
|
||||
│ initialize repo
|
||||
◉ 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
|
||||
|
|
|
@ -125,7 +125,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###"
|
||||
6ac4339ad6999058dd1806653ec37fc0091c1cc17419c750fddc5e8c1a6a77829e6dd70b3408403fb2c0b9839cf6bfd1c270f980674f7f89d4d78dc54082a8ef
|
||||
b51416386f2685fd5493f2b20e8eec3c24a1776d9e1a7cb5ed7e30d2d9c88c0c1e1fe71b0b7358cba60de42533d1228ed9878f2f89817d892c803395ccf9fe92
|
||||
"###
|
||||
);
|
||||
}
|
||||
|
|
|
@ -36,12 +36,12 @@ fn test_op_log() {
|
|||
],
|
||||
);
|
||||
insta::assert_snapshot!(&stdout, @r###"
|
||||
@ c12bcc2a82e7 test-username@host.example.com 2001-02-03 04:05:08.000 +07:00 - 2001-02-03 04:05:08.000 +07:00
|
||||
@ 52ac15d375ba 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'
|
||||
◉ 6ac4339ad699 test-username@host.example.com 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00
|
||||
◉ b51416386f26 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'
|
||||
◉ 1b0049c19762 test-username@host.example.com 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00
|
||||
◉ 9a7d829846af 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
|
||||
◉ 000000000000 root()
|
||||
"###);
|
||||
|
@ -114,9 +114,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;12m6ac4339ad699[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;12mb51416386f26[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;4m1b0049c19762[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;4m9a7d829846af[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
|
||||
[38;5;4m000000000000[39m [38;5;2mroot()[39m
|
||||
"###);
|
||||
|
@ -140,7 +140,7 @@ fn test_op_log_no_graph_null_terminated() {
|
|||
r#"id.short(4) ++ "\0""#,
|
||||
],
|
||||
);
|
||||
insta::assert_debug_snapshot!(stdout, @r###""050b\0c02e\06ac4\01b00\00000\0""###);
|
||||
insta::assert_debug_snapshot!(stdout, @r###""22d4\023da\0b514\09a7d\00000\0""###);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -151,15 +151,15 @@ 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###"
|
||||
@ 6ac4339ad6999058dd1806653ec37fc0091c1cc17419c750fddc5e8c1a6a77829e6dd70b3408403fb2c0b9839cf6bfd1c270f980674f7f89d4d78dc54082a8ef
|
||||
◉ 1b0049c19762e43499f2499a45afc9f72b3004d75a2863d41d8867cfafb9bbc8e16aa447107e460d58a5c1462429f032d806f7487836c66c6f351df45746c218
|
||||
@ b51416386f2685fd5493f2b20e8eec3c24a1776d9e1a7cb5ed7e30d2d9c88c0c1e1fe71b0b7358cba60de42533d1228ed9878f2f89817d892c803395ccf9fe92
|
||||
◉ 9a7d829846af88a2f7a1e348fb46ff58729e49632bc9c6a052aec8501563cb0d10f4a4e6010ffde529f84a2b9b5b3a4c211a889106a41f6c076dfdacc79f6af7
|
||||
◉ 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
"###);
|
||||
insta::assert_snapshot!(
|
||||
render(r#"separate(" ", id.short(5), current_operation, user,
|
||||
time.start(), time.end(), time.duration()) ++ "\n""#), @r###"
|
||||
@ 6ac43 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
|
||||
◉ 1b004 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
|
||||
@ b5141 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
|
||||
◉ 9a7d8 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
|
||||
◉ 00000 false @ 1970-01-01 00:00:00.000 +00:00 1970-01-01 00:00:00.000 +00:00 less than a microsecond
|
||||
"###);
|
||||
|
||||
|
@ -183,9 +183,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###"
|
||||
@ 6ac4339ad699 test-username@host.example.com NN years ago, lasted less than a microsecond
|
||||
@ b51416386f26 test-username@host.example.com NN years ago, lasted less than a microsecond
|
||||
│ add workspace 'default'
|
||||
◉ 1b0049c19762 test-username@host.example.com NN years ago, lasted less than a microsecond
|
||||
◉ 9a7d829846af test-username@host.example.com NN years ago, lasted less than a microsecond
|
||||
│ initialize repo
|
||||
◉ 000000000000 root()
|
||||
"###);
|
||||
|
@ -200,25 +200,25 @@ 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###"
|
||||
@ c12bcc2a82e7 test-username@host.example.com 2001-02-03 04:05:08.000 +07:00 - 2001-02-03 04:05:08.000 +07:00
|
||||
@ 52ac15d375ba 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'
|
||||
◉ 6ac4339ad699 test-username@host.example.com 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00
|
||||
◉ b51416386f26 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'
|
||||
◉ 1b0049c19762 test-username@host.example.com 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00
|
||||
◉ 9a7d829846af 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
|
||||
◉ 000000000000 root()
|
||||
"###);
|
||||
|
||||
insta::assert_snapshot!(render(r#"builtin_op_log_comfortable"#), @r###"
|
||||
@ c12bcc2a82e7 test-username@host.example.com 2001-02-03 04:05:08.000 +07:00 - 2001-02-03 04:05:08.000 +07:00
|
||||
@ 52ac15d375ba 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'
|
||||
│
|
||||
◉ 6ac4339ad699 test-username@host.example.com 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00
|
||||
◉ b51416386f26 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'
|
||||
│
|
||||
◉ 1b0049c19762 test-username@host.example.com 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00
|
||||
◉ 9a7d829846af 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
|
||||
│
|
||||
◉ 000000000000 root()
|
||||
|
@ -246,19 +246,19 @@ fn test_op_log_word_wrap() {
|
|||
|
||||
// ui.log-word-wrap option works
|
||||
insta::assert_snapshot!(render(&["op", "log"], 40, false), @r###"
|
||||
@ 6ac4339ad699 test-username@host.example.com 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00
|
||||
@ b51416386f26 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'
|
||||
◉ 1b0049c19762 test-username@host.example.com 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00
|
||||
◉ 9a7d829846af 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
|
||||
◉ 000000000000 root()
|
||||
"###);
|
||||
insta::assert_snapshot!(render(&["op", "log"], 40, true), @r###"
|
||||
@ 6ac4339ad699
|
||||
@ b51416386f26
|
||||
│ 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'
|
||||
◉ 1b0049c19762
|
||||
◉ 9a7d829846af
|
||||
│ test-username@host.example.com
|
||||
│ 2001-02-03 04:05:07.000 +07:00 -
|
||||
│ 2001-02-03 04:05:07.000 +07:00
|
||||
|
@ -296,15 +296,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###"
|
||||
@ d4553a89325a test-username@host.example.com 2001-02-03 04:05:09.000 +07:00 - 2001-02-03 04:05:09.000 +07:00
|
||||
@ de138472a722 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'
|
||||
◉ de5974401ad4 test-username@host.example.com 2001-02-03 04:05:08.000 +07:00 - 2001-02-03 04:05:08.000 +07:00
|
||||
◉ 652e5aecc9f7 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'
|
||||
◉ 6ac4339ad699 test-username@host.example.com 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00
|
||||
◉ b51416386f26 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'
|
||||
◉ 1b0049c19762 test-username@host.example.com 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00
|
||||
◉ 9a7d829846af 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
|
||||
◉ 000000000000 root()
|
||||
"###);
|
||||
|
@ -316,11 +316,11 @@ fn test_op_abandon_ancestors() {
|
|||
"###);
|
||||
insta::assert_snapshot!(
|
||||
test_env.jj_cmd_success(&repo_path, &["debug", "workingcopy", "--ignore-working-copy"]), @r###"
|
||||
Current operation: OperationId("8d45b00ca36ad7cf1e50ed595eb1ddf744765ada1e1b11c44544666b1fa11eedb41bb925886894bc6a49332c86299b70cf4c486143935965ef1958d7fc17257b")
|
||||
Current operation: OperationId("10e856d0579c4aca88972ffea0a515f47f8c09dceaa2b1a5d531c83b04350f7aa64a3eff422def01eebd65df26089ef5e0f925f247a8f929c8cc858d16306e53")
|
||||
Current tree: Legacy(TreeId("4b825dc642cb6eb9a060e54bf8d69288fbee4904"))
|
||||
"###);
|
||||
insta::assert_snapshot!(test_env.jj_cmd_success(&repo_path, &["op", "log"]), @r###"
|
||||
@ 8d45b00ca36a test-username@host.example.com 2001-02-03 04:05:09.000 +07:00 - 2001-02-03 04:05:09.000 +07:00
|
||||
@ 10e856d0579c 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'
|
||||
◉ 000000000000 root()
|
||||
|
@ -335,10 +335,10 @@ 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###"
|
||||
@ 49a67606c2ea test-username@host.example.com 2001-02-03 04:05:16.000 +07:00 - 2001-02-03 04:05:16.000 +07:00
|
||||
@ 70112b4447b6 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'
|
||||
◉ 8d45b00ca36a test-username@host.example.com 2001-02-03 04:05:09.000 +07:00 - 2001-02-03 04:05:09.000 +07:00
|
||||
◉ 10e856d0579c 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'
|
||||
◉ 000000000000 root()
|
||||
|
@ -365,14 +365,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("3579f60625d3fc2768dd156488df7ccae6c0076de6ce66cfd02a951de182ac0652bad67c4c5e1f30a3369da8910f3c7cbaef1b5c2781d7c43da2a4404ab470fc")
|
||||
Current operation: OperationId("445e93662d714f53fb97e450eb3793a8e1a9a4cca1e329d5a9096e65085fb96d5bb51659531145c8abf0db5da803cd11c4cecdcf9025391bc97fc6a42204a0fe")
|
||||
Current tree: Legacy(TreeId("4b825dc642cb6eb9a060e54bf8d69288fbee4904"))
|
||||
"###);
|
||||
insta::assert_snapshot!(test_env.jj_cmd_success(&repo_path, &["op", "log"]), @r###"
|
||||
@ 3579f60625d3 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 49a67606c2eacaa4af83229c46652c7d5b5c36abdc5f6480baeb7331a19f418f267911410491f558c3f88345f83540ee5a04eb4e8b818dd662a9f419b5eb8f66
|
||||
@ 445e93662d71 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 70112b4447b65fa811038b2b119fe22e959e3b3194b461a32475f6528c2b684ac6baebc86cce7ad7e0bb92c033852850e561506508ca43e823626f107e81ed76
|
||||
│ args: jj undo
|
||||
◉ 8d45b00ca36a test-username@host.example.com 2001-02-03 04:05:09.000 +07:00 - 2001-02-03 04:05:09.000 +07:00
|
||||
◉ 10e856d0579c 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'
|
||||
◉ 000000000000 root()
|
||||
|
@ -384,8 +384,8 @@ fn test_op_abandon_ancestors() {
|
|||
Nothing changed.
|
||||
"###);
|
||||
insta::assert_snapshot!(test_env.jj_cmd_success(&repo_path, &["op", "log", "-l1"]), @r###"
|
||||
@ 3579f60625d3 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 49a67606c2eacaa4af83229c46652c7d5b5c36abdc5f6480baeb7331a19f418f267911410491f558c3f88345f83540ee5a04eb4e8b818dd662a9f419b5eb8f66
|
||||
@ 445e93662d71 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 70112b4447b65fa811038b2b119fe22e959e3b3194b461a32475f6528c2b684ac6baebc86cce7ad7e0bb92c033852850e561506508ca43e823626f107e81ed76
|
||||
│ args: jj undo
|
||||
"###);
|
||||
}
|
||||
|
@ -410,12 +410,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("880aaeffd50eb8682cd132b6d4a449a79c988ce8ff53fa50dd5b22849c8569ca345e313cd7f52b350d4b08e1567d39a556dbc437c24edbfccc9af23764e9b766")
|
||||
Current operation: OperationId("61aeade2493b190412c61b9b0711025c2cccf95966870a5f7dc2e34ab313fbef64da70d00cab2cd69ad39816faeb80a6bc866927549b84dce6cb5a437e0e515b")
|
||||
Current tree: Legacy(TreeId("4b825dc642cb6eb9a060e54bf8d69288fbee4904"))
|
||||
"###);
|
||||
insta::assert_snapshot!(
|
||||
test_env.jj_cmd_success(&repo_path, &["op", "log", "-l1", "--ignore-working-copy"]), @r###"
|
||||
@ d4f54739fcd7 test-username@host.example.com 2001-02-03 04:05:10.000 +07:00 - 2001-02-03 04:05:10.000 +07:00
|
||||
@ ae6364994418 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'
|
||||
"###);
|
||||
|
@ -426,16 +426,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 880aaeffd50e is not updated because it differs from the repo d4f54739fcd7.
|
||||
The working copy operation 61aeade2493b is not updated because it differs from the repo ae6364994418.
|
||||
"###);
|
||||
insta::assert_snapshot!(
|
||||
test_env.jj_cmd_success(&repo_path, &["debug", "workingcopy", "--ignore-working-copy"]), @r###"
|
||||
Current operation: OperationId("880aaeffd50eb8682cd132b6d4a449a79c988ce8ff53fa50dd5b22849c8569ca345e313cd7f52b350d4b08e1567d39a556dbc437c24edbfccc9af23764e9b766")
|
||||
Current operation: OperationId("61aeade2493b190412c61b9b0711025c2cccf95966870a5f7dc2e34ab313fbef64da70d00cab2cd69ad39816faeb80a6bc866927549b84dce6cb5a437e0e515b")
|
||||
Current tree: Legacy(TreeId("4b825dc642cb6eb9a060e54bf8d69288fbee4904"))
|
||||
"###);
|
||||
insta::assert_snapshot!(
|
||||
test_env.jj_cmd_success(&repo_path, &["op", "log", "-l1", "--ignore-working-copy"]), @r###"
|
||||
@ 1b403259869c test-username@host.example.com 2001-02-03 04:05:10.000 +07:00 - 2001-02-03 04:05:10.000 +07:00
|
||||
@ 51192a90e899 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'
|
||||
"###);
|
||||
|
|
|
@ -89,7 +89,7 @@ fn test_gc_operation_log() {
|
|||
// Now this doesn't work.
|
||||
let stderr = test_env.jj_cmd_failure(&repo_path, &["debug", "operation", &op_to_remove]);
|
||||
insta::assert_snapshot!(stderr, @r###"
|
||||
Error: No operation ID matching "f9400b5274c6f1cfa23afbc1956349897a6975116135a59ab19d941119cc9fad93d9668b8c7d913fbd68c543dcba40a8d44135a53996a9e8ea92d4b78ef52cb6"
|
||||
Error: No operation ID matching "6b842a00d6a5655d32c8a0ee40c4aaaed49337cdcaca98b8d7c1f3a1c82f58b4968c2ed5b13d9d2a5d41f04040f42e6daf77c0f4646d09138bd1e25c754e2411"
|
||||
"###);
|
||||
}
|
||||
|
||||
|
|
|
@ -297,14 +297,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 d93fe4c5a6d1).
|
||||
Error: The working copy is stale (not updated since operation 58b580b12eee).
|
||||
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 d93fe4c5a6d1).
|
||||
Error: The working copy is stale (not updated since operation 58b580b12eee).
|
||||
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.
|
||||
"###);
|
||||
|
@ -384,7 +384,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 d93fe4c5a6d1).
|
||||
Error: The working copy is stale (not updated since operation 58b580b12eee).
|
||||
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.
|
||||
"###);
|
||||
|
@ -436,13 +436,13 @@ fn test_workspaces_current_op_discarded_by_other() {
|
|||
],
|
||||
);
|
||||
insta::assert_snapshot!(stdout, @r###"
|
||||
@ 09350a8134 abandon commit acb4b92517b20aa4ee2f3dc58d7c2373754d0b29a3df310dbabda5813f13c3730d28d6a1b6dd37f3b0c8c5c9adaead5dab242ffe7ecc2e5a6a534fe4c6639f89
|
||||
◉ d8304661a2 Create initial working-copy commit in workspace secondary
|
||||
◉ 4ae0e83b98 add workspace 'secondary'
|
||||
◉ 00cc5ecf50 new empty commit
|
||||
◉ e0be7087ba snapshot working copy
|
||||
◉ d0bd64e0b3 add workspace 'default'
|
||||
◉ 06a74719e6 initialize repo
|
||||
@ f1dc1bf396 abandon commit acb4b92517b20aa4ee2f3dc58d7c2373754d0b29a3df310dbabda5813f13c3730d28d6a1b6dd37f3b0c8c5c9adaead5dab242ffe7ecc2e5a6a534fe4c6639f89
|
||||
◉ 47f1ad5e1a Create initial working-copy commit in workspace secondary
|
||||
◉ fd918ce207 add workspace 'secondary'
|
||||
◉ 5927500c4b new empty commit
|
||||
◉ c86cb4fdf4 snapshot working copy
|
||||
◉ 17dbb2fe40 add workspace 'default'
|
||||
◉ cecfee9647 initialize repo
|
||||
◉ 0000000000
|
||||
"###);
|
||||
|
||||
|
@ -466,7 +466,7 @@ fn test_workspaces_current_op_discarded_by_other() {
|
|||
|
||||
let (stdout, stderr) = test_env.jj_cmd_ok(&secondary_path, &["workspace", "update-stale"]);
|
||||
insta::assert_snapshot!(stderr, @r###"
|
||||
Failed to read working copy's current operation; attempting recovery. Error message from read attempt: Object d8304661a23b0d8b9ecc517a465869d7c8b6563b460f029541fbe5246cc02718145c5ad8f7fed26863b46a68e79d609b878a7ea5a239baf530858e86e81e72d1 of type operation not found
|
||||
Failed to read working copy's current operation; attempting recovery. Error message from read attempt: Object 47f1ad5e1adfaa1e9863181e6e45ae12b9db553e82bde82e278c0c6288053c833b4039a5baf2415871964bcdcd4b7875692979e66f2ec18bfc3896355091cf53 of type operation not found
|
||||
Created and checked out recovery commit 9d040f9a433c
|
||||
"###);
|
||||
insta::assert_snapshot!(stdout, @"");
|
||||
|
@ -658,7 +658,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###"
|
||||
@ ea093f0a1a06 test-username@host.example.com 2001-02-03 04:05:12.000 +07:00 - 2001-02-03 04:05:12.000 +07:00
|
||||
@ c28e1481737d 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
|
||||
"###);
|
||||
|
|
|
@ -388,6 +388,7 @@ impl Operation {
|
|||
description: "".to_string(),
|
||||
hostname: "".to_string(),
|
||||
username: "".to_string(),
|
||||
is_snapshot: false,
|
||||
tags: HashMap::new(),
|
||||
};
|
||||
Operation {
|
||||
|
@ -407,6 +408,8 @@ content_hash! {
|
|||
pub description: String,
|
||||
pub hostname: String,
|
||||
pub username: String,
|
||||
/// Whether this operation represents a pure snapshotting of the working copy.
|
||||
pub is_snapshot: bool,
|
||||
pub tags: HashMap<String, String>,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -111,5 +111,6 @@ message OperationMetadata {
|
|||
string description = 3;
|
||||
string hostname = 4;
|
||||
string username = 5;
|
||||
bool is_snapshot = 7;
|
||||
map<string, string> tags = 6;
|
||||
}
|
||||
|
|
|
@ -157,6 +157,8 @@ pub struct OperationMetadata {
|
|||
pub hostname: ::prost::alloc::string::String,
|
||||
#[prost(string, tag = "5")]
|
||||
pub username: ::prost::alloc::string::String,
|
||||
#[prost(bool, tag = "7")]
|
||||
pub is_snapshot: bool,
|
||||
#[prost(map = "string, string", tag = "6")]
|
||||
pub tags: ::std::collections::HashMap<
|
||||
::prost::alloc::string::String,
|
||||
|
|
|
@ -356,6 +356,7 @@ fn operation_metadata_to_proto(
|
|||
description: metadata.description.clone(),
|
||||
hostname: metadata.hostname.clone(),
|
||||
username: metadata.username.clone(),
|
||||
is_snapshot: metadata.is_snapshot,
|
||||
tags: metadata.tags.clone(),
|
||||
}
|
||||
}
|
||||
|
@ -371,6 +372,7 @@ fn operation_metadata_from_proto(
|
|||
description: proto.description,
|
||||
hostname: proto.hostname,
|
||||
username: proto.username,
|
||||
is_snapshot: proto.is_snapshot,
|
||||
tags: proto.tags,
|
||||
}
|
||||
}
|
||||
|
@ -757,6 +759,7 @@ mod tests {
|
|||
description: "check out foo".to_string(),
|
||||
hostname: "some.host.example.com".to_string(),
|
||||
username: "someone".to_string(),
|
||||
is_snapshot: false,
|
||||
tags: hashmap! {
|
||||
"key1".to_string() => "value1".to_string(),
|
||||
"key2".to_string() => "value2".to_string(),
|
||||
|
@ -779,7 +782,7 @@ mod tests {
|
|||
// Test exact output so we detect regressions in compatibility
|
||||
assert_snapshot!(
|
||||
OperationId::new(blake2b_hash(&create_operation()).to_vec()).hex(),
|
||||
@"3ec986c29ff8eb808ea8f6325d6307cea75ef02987536c8e4645406aba51afc8e229957a6e855170d77a66098c58912309323f5e0b32760caa2b59dc84d45fcf"
|
||||
@"20b495d54aa3be3a672a2ed6dbbf7a711dabce4cc0161d657e5177070491c1e780eec3fd35c2aa9dcc22371462aeb412a502a847f29419e65718f56a0ad1b2d0"
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ pub struct Transaction {
|
|||
impl Transaction {
|
||||
pub fn new(mut_repo: MutableRepo, user_settings: &UserSettings) -> Transaction {
|
||||
let parent_ops = vec![mut_repo.base_repo().operation().clone()];
|
||||
let op_metadata = create_op_metadata(user_settings, "".to_string());
|
||||
let op_metadata = create_op_metadata(user_settings, "".to_string(), false);
|
||||
let end_time = user_settings.operation_timestamp();
|
||||
Transaction {
|
||||
mut_repo,
|
||||
|
@ -80,6 +80,10 @@ impl Transaction {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
pub fn set_is_snapshot(&mut self, is_snapshot: bool) {
|
||||
self.op_metadata.is_snapshot = is_snapshot;
|
||||
}
|
||||
|
||||
/// Writes the transaction to the operation store and publishes it.
|
||||
pub fn commit(self, description: impl Into<String>) -> Arc<ReadonlyRepo> {
|
||||
self.write(description).publish()
|
||||
|
@ -121,7 +125,11 @@ impl Transaction {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn create_op_metadata(user_settings: &UserSettings, description: String) -> OperationMetadata {
|
||||
pub fn create_op_metadata(
|
||||
user_settings: &UserSettings,
|
||||
description: String,
|
||||
is_snapshot: bool,
|
||||
) -> OperationMetadata {
|
||||
let start_time = user_settings
|
||||
.operation_timestamp()
|
||||
.unwrap_or_else(Timestamp::now);
|
||||
|
@ -134,6 +142,7 @@ pub fn create_op_metadata(user_settings: &UserSettings, description: String) ->
|
|||
description,
|
||||
hostname,
|
||||
username,
|
||||
is_snapshot,
|
||||
tags: Default::default(),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -444,16 +444,16 @@ fn test_resolve_op_id() {
|
|||
let repo = tx.commit(format!("transaction {i}"));
|
||||
operations.push(repo.operation().clone());
|
||||
}
|
||||
// "6" and "0" are ambiguous
|
||||
// "2" and "0" are ambiguous
|
||||
insta::assert_debug_snapshot!(operations.iter().map(|op| op.id().hex()).collect_vec(), @r###"
|
||||
[
|
||||
"661239681c88dd0e8037ac010df3917e4fb1b36fdad0586fea09718741552c8d26684821043d5f9423fc618220f7826b2b8d77c13566733e7d591605d0850d0e",
|
||||
"22d5aeb8f2fdda8a782fc589c891b1eea0a73c6685db45d1c7eda5d5c02b99a8679743deb2508a643bb074884363e54cc3ea41a06ec380de3b2c536a5c1ae98f",
|
||||
"3580c377da0dfea738a735777fe3d00569fcf484b0ec4080a337e38d1e008098ed87d50f7c2dad476b828871259d055cec05116cd0a02e323477aeb7df5473e4",
|
||||
"b09c135f3d36357a29246ee3dc86e008ef227186104a2e99524abe601a7bfa8b898a585e9d2b3cbf5131e72043edf0a219ee192bd4a3bff8d6cfc44239a4c206",
|
||||
"820bb7cdbdda7206902391e6b8b08df719156ca9b3eb008a723da6e15cf4056987ac36f42e075a9491ed95dde158925f65c42027700b6bce52ce6f67d69980ee",
|
||||
"08f1e27b776f7709f4a288129758d0104cb0230dc68f3edb8a1227c7b715f36c4079ba19bccb819d4f45e840e19e321e807a89900eeca77da0cad6b5549e3691",
|
||||
"695435d5ab08eaf979d262c01365d9b9c06097a8ba5a9cea530042528d50000d99627633262467d3099ed73617a0bc21f7796376432989174635365798d73a3d",
|
||||
"5aebb24d08d6f5282d9e06bded4b51febbb4ff4bc822cdd4db9043961339955d6af912e783c3864245867d0cf6d609cb004c5ff0cef5e914c15a415ba92e38a2",
|
||||
"ad1cda629b220f2651d972475fba75e47c30cd57862c51a727e57b7b6e2fbaa937d0bcb881cf6fcff30ba1a088a4ad588cf880765b9d9680b551cdc446f3489e",
|
||||
"2feaf9eb61232582d35f1cb0203b69425f7a7d07140a5f8ff0d0bf98dd9f433b941e4c9e0882f65a007266affee275e235ae1614b159ceadbf9fe6879077a5da",
|
||||
"0b183be5767c3ff9945c8a9e3ac7639d249ff9873985a551f4c2070782aea8b5018ebff906036d1658038708ab9de0d867be385b1181aa7a81669e2ef6852355",
|
||||
"d1c3031dff7b1db4db1bfb592a9aa0ea6faae9300033ef20cb6da488e4b90524c22af8e2541cdb99ca0ee2be3299c213c0f8d48390cd5f11462c4f80c5790f68",
|
||||
"2369ba98e2596715606978a72608970287aaa064ec890f87c29b7e7df64fdf02b7f24b8b03ee845e132f3e19e3929de359b6cfe1328b42946c45ac5ff80705ca",
|
||||
"00271842a189d274a2c97ac28f937584a47b84463d5b408c6f998089131e0e1329a287667b2ac5d63f8c576e95323bcf992c99caa4ef4612a1c3798fe8a3f74f",
|
||||
]
|
||||
"###);
|
||||
|
||||
|
@ -474,7 +474,7 @@ fn test_resolve_op_id() {
|
|||
);
|
||||
// Ambiguous id
|
||||
assert_matches!(
|
||||
resolve("6"),
|
||||
resolve("2"),
|
||||
Err(OpsetEvaluationError::OpsetResolution(
|
||||
OpsetResolutionError::AmbiguousIdPrefix(_)
|
||||
))
|
||||
|
@ -500,8 +500,8 @@ fn test_resolve_op_id() {
|
|||
Operation::new(op_store.clone(), id.clone(), data)
|
||||
};
|
||||
assert_eq!(resolve(&root_operation.id().hex()).unwrap(), root_operation);
|
||||
assert_eq!(resolve("00").unwrap(), root_operation);
|
||||
assert_eq!(resolve("69").unwrap(), operations[6]);
|
||||
assert_eq!(resolve("000").unwrap(), root_operation);
|
||||
assert_eq!(resolve("002").unwrap(), operations[6]);
|
||||
assert_matches!(
|
||||
resolve("0"),
|
||||
Err(OpsetEvaluationError::OpsetResolution(
|
||||
|
|
Loading…
Reference in a new issue