| 1 |
// Copyright 2022 The Jujutsu Authors |
| 2 |
// |
| 3 |
// Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 |
// you may not use this file except in compliance with the License. |
| 5 |
// You may obtain a copy of the License at |
| 6 |
// |
| 7 |
// https://www.apache.org/licenses/LICENSE-2.0 |
| 8 |
// |
| 9 |
// Unless required by applicable law or agreed to in writing, software |
| 10 |
// distributed under the License is distributed on an "AS IS" BASIS, |
| 11 |
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 |
// See the License for the specific language governing permissions and |
| 13 |
// limitations under the License. |
| 14 |
|
| 15 |
use std::path::Path; |
| 16 |
use std::path::PathBuf; |
| 17 |
|
| 18 |
use itertools::Itertools as _; |
| 19 |
use regex::Regex; |
| 20 |
use testutils::TestResult; |
| 21 |
use testutils::git; |
| 22 |
|
| 23 |
use crate::common::CommandOutput; |
| 24 |
use crate::common::TestEnvironment; |
| 25 |
use crate::common::TestWorkDir; |
| 26 |
use crate::common::to_toml_value; |
| 27 |
|
| 28 |
#[test] |
| 29 |
fn test_op_log() { |
| 30 |
let test_env = TestEnvironment::default(); |
| 31 |
test_env.run_jj_in(".", ["git", "init", "repo"]).success(); |
| 32 |
let work_dir = test_env.work_dir("repo"); |
| 33 |
work_dir |
| 34 |
.run_jj(["describe", "-m", "description 0"]) |
| 35 |
.success(); |
| 36 |
|
| 37 |
let output = work_dir.run_jj(["op", "log"]); |
| 38 |
insta::assert_snapshot!(output, @" |
| 39 |
@ 7749eb4df93f [email protected] default@ 2001-02-03 04:05:08.000 +07:00 - 2001-02-03 04:05:08.000 +07:00 |
| 40 |
│ describe commit e8849ae12c709f2321908879bc724fdb2ab8a781 |
| 41 |
│ args: jj describe -m 'description 0' |
| 42 |
○ f63ee16f9553 [email protected] 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00 |
| 43 |
│ add workspace 'default' |
| 44 |
○ 000000000000 root() |
| 45 |
[EOF] |
| 46 |
"); |
| 47 |
let op_log_lines = output.stdout.raw().lines().collect_vec(); |
| 48 |
let add_workspace_id = op_log_lines[3].split(' ').nth(2).unwrap(); |
| 49 |
|
| 50 |
// Can load the repo at a specific operation ID |
| 51 |
insta::assert_snapshot!(get_log_output(&work_dir, add_workspace_id), @" |
| 52 |
@ e8849ae12c709f2321908879bc724fdb2ab8a781 |
| 53 |
◆ 0000000000000000000000000000000000000000 |
| 54 |
[EOF] |
| 55 |
"); |
| 56 |
// "@" resolves to the head operation |
| 57 |
insta::assert_snapshot!(get_log_output(&work_dir, "@"), @" |
| 58 |
@ 3ae22e7f50a15d393e412cca72d09a61165d0c84 |
| 59 |
◆ 0000000000000000000000000000000000000000 |
| 60 |
[EOF] |
| 61 |
"); |
| 62 |
// "@-" resolves to the parent of the head operation |
| 63 |
insta::assert_snapshot!(get_log_output(&work_dir, "@-"), @" |
| 64 |
@ e8849ae12c709f2321908879bc724fdb2ab8a781 |
| 65 |
◆ 0000000000000000000000000000000000000000 |
| 66 |
[EOF] |
| 67 |
"); |
| 68 |
insta::assert_snapshot!(work_dir.run_jj(["log", "--at-op", "@---"]), @r#" |
| 69 |
------- stderr ------- |
| 70 |
Error: The "@---" expression resolved to no operations |
| 71 |
[EOF] |
| 72 |
[exit status: 1] |
| 73 |
"#); |
| 74 |
|
| 75 |
// We get a reasonable message if an invalid operation ID is specified |
| 76 |
insta::assert_snapshot!(work_dir.run_jj(["log", "--at-op", "foo"]), @r#" |
| 77 |
------- stderr ------- |
| 78 |
Error: Operation ID "foo" is not a valid hexadecimal prefix |
| 79 |
[EOF] |
| 80 |
[exit status: 1] |
| 81 |
"#); |
| 82 |
|
| 83 |
let output = work_dir.run_jj(["op", "log", "--op-diff"]); |
| 84 |
insta::assert_snapshot!(output, @" |
| 85 |
@ 7749eb4df93f [email protected] default@ 2001-02-03 04:05:08.000 +07:00 - 2001-02-03 04:05:08.000 +07:00 |
| 86 |
│ describe commit e8849ae12c709f2321908879bc724fdb2ab8a781 |
| 87 |
│ args: jj describe -m 'description 0' |
| 88 |
│ |
| 89 |
│ Changed commits: |
| 90 |
│ ○ + qpvuntsm 3ae22e7f (empty) description 0 |
| 91 |
│ - qpvuntsm/1 e8849ae1 (hidden) (empty) (no description set) |
| 92 |
│ |
| 93 |
│ Changed working copy default@: |
| 94 |
│ + qpvuntsm 3ae22e7f (empty) description 0 |
| 95 |
│ - qpvuntsm/1 e8849ae1 (hidden) (empty) (no description set) |
| 96 |
○ f63ee16f9553 [email protected] 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00 |
| 97 |
│ add workspace 'default' |
| 98 |
│ |
| 99 |
│ Changed commits: |
| 100 |
│ ○ + qpvuntsm e8849ae1 (empty) (no description set) |
| 101 |
│ |
| 102 |
│ Changed working copy default@: |
| 103 |
│ + qpvuntsm e8849ae1 (empty) (no description set) |
| 104 |
│ - (absent) |
| 105 |
○ 000000000000 root() |
| 106 |
[EOF] |
| 107 |
"); |
| 108 |
|
| 109 |
let output = work_dir.run_jj(["op", "log", "--op-diff", "--color=always"]); |
| 110 |
insta::assert_snapshot!(output, @" |
| 111 |
[1m[38;5;2m@[0m [1m[38;5;12m7749eb4df93f[39m [38;5;[email protected][39m [38;5;2mdefault@[39m [38;5;14m2001-02-03 04:05:08.000 +07:00[39m - [38;5;14m2001-02-03 04:05:08.000 +07:00[39m[0m |
| 112 |
│ [1mdescribe commit e8849ae12c709f2321908879bc724fdb2ab8a781[0m |
| 113 |
│ [1m[38;5;13margs: jj describe -m 'description 0'[39m[0m |
| 114 |
│ |
| 115 |
│ Changed commits: |
| 116 |
│ ○ [38;5;2m+[39m [1m[38;5;13mq[38;5;8mpvuntsm[39m [38;5;12m3[38;5;8mae22e7f[39m [38;5;10m(empty)[39m description 0[0m |
| 117 |
│ [38;5;1m-[39m [1m[39mq[0m[38;5;8mpvuntsm[1m[39m/1[0m [1m[38;5;4me[0m[38;5;8m8849ae1[39m (hidden) [38;5;2m(empty)[39m [38;5;2m(no description set)[39m |
| 118 |
│ |
| 119 |
│ Changed working copy [38;5;2mdefault@[39m: |
| 120 |
│ [38;5;2m+[39m [1m[38;5;13mq[38;5;8mpvuntsm[39m [38;5;12m3[38;5;8mae22e7f[39m [38;5;10m(empty)[39m description 0[0m |
| 121 |
│ [38;5;1m-[39m [1m[39mq[0m[38;5;8mpvuntsm[1m[39m/1[0m [1m[38;5;4me[0m[38;5;8m8849ae1[39m (hidden) [38;5;2m(empty)[39m [38;5;2m(no description set)[39m |
| 122 |
○ [38;5;4mf63ee16f9553[39m [38;5;[email protected][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 |
| 123 |
│ add workspace 'default' |
| 124 |
│ |
| 125 |
│ Changed commits: |
| 126 |
│ ○ [38;5;2m+[39m [1m[38;5;13mq[38;5;8mpvuntsm[39m [38;5;12me[38;5;8m8849ae1[39m [38;5;10m(empty)[39m [38;5;10m(no description set)[0m |
| 127 |
│ |
| 128 |
│ Changed working copy [38;5;2mdefault@[39m: |
| 129 |
│ [38;5;2m+[39m [1m[38;5;13mq[38;5;8mpvuntsm[39m [38;5;12me[38;5;8m8849ae1[39m [38;5;10m(empty)[39m [38;5;10m(no description set)[0m |
| 130 |
│ [38;5;1m-[39m (absent) |
| 131 |
○ [38;5;4m000000000000[39m [38;5;2mroot()[39m |
| 132 |
[EOF] |
| 133 |
"); |
| 134 |
|
| 135 |
work_dir |
| 136 |
.run_jj(["describe", "-m", "description 1"]) |
| 137 |
.success(); |
| 138 |
work_dir |
| 139 |
.run_jj([ |
| 140 |
"describe", |
| 141 |
"-m", |
| 142 |
"description 2", |
| 143 |
"--at-op", |
| 144 |
add_workspace_id, |
| 145 |
]) |
| 146 |
.success(); |
| 147 |
insta::assert_snapshot!(work_dir.run_jj(["log", "--at-op", "@-"]), @r#" |
| 148 |
------- stderr ------- |
| 149 |
Error: The "@" expression resolved to more than one operation |
| 150 |
Hint: Try specifying one of the operations by ID: 6fba4276d4b7, da58be7f2aaf |
| 151 |
[EOF] |
| 152 |
[exit status: 1] |
| 153 |
"#); |
| 154 |
} |
| 155 |
|
| 156 |
#[test] |
| 157 |
fn test_op_log_with_custom_symbols() { |
| 158 |
let test_env = TestEnvironment::default(); |
| 159 |
test_env.run_jj_in(".", ["git", "init", "repo"]).success(); |
| 160 |
let work_dir = test_env.work_dir("repo"); |
| 161 |
work_dir |
| 162 |
.run_jj(["describe", "-m", "description 0"]) |
| 163 |
.success(); |
| 164 |
|
| 165 |
let output = work_dir.run_jj([ |
| 166 |
"op", |
| 167 |
"log", |
| 168 |
"--config=templates.op_log_node='if(current_operation, \"$\", if(root, \"┴\", \"┝\"))'", |
| 169 |
]); |
| 170 |
insta::assert_snapshot!(output, @" |
| 171 |
$ 7749eb4df93f [email protected] default@ 2001-02-03 04:05:08.000 +07:00 - 2001-02-03 04:05:08.000 +07:00 |
| 172 |
│ describe commit e8849ae12c709f2321908879bc724fdb2ab8a781 |
| 173 |
│ args: jj describe -m 'description 0' |
| 174 |
┝ f63ee16f9553 [email protected] 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00 |
| 175 |
│ add workspace 'default' |
| 176 |
┴ 000000000000 root() |
| 177 |
[EOF] |
| 178 |
"); |
| 179 |
} |
| 180 |
|
| 181 |
#[test] |
| 182 |
fn test_op_log_with_no_template() { |
| 183 |
let test_env = TestEnvironment::default(); |
| 184 |
test_env.run_jj_in(".", ["git", "init", "repo"]).success(); |
| 185 |
let work_dir = test_env.work_dir("repo"); |
| 186 |
|
| 187 |
let output = work_dir.run_jj(["op", "log", "-T"]); |
| 188 |
insta::assert_snapshot!(output, @" |
| 189 |
------- stderr ------- |
| 190 |
error: a value is required for '--template <TEMPLATE>' but none was supplied |
| 191 |
|
| 192 |
For more information, try '--help'. |
| 193 |
Hint: The following template aliases are defined: |
| 194 |
- builtin_config_list |
| 195 |
- builtin_config_list_detailed |
| 196 |
- builtin_draft_commit_description |
| 197 |
- builtin_draft_commit_description_with_diff |
| 198 |
- builtin_evolog_compact |
| 199 |
- builtin_log_comfortable |
| 200 |
- builtin_log_compact |
| 201 |
- builtin_log_compact_full_description |
| 202 |
- builtin_log_detailed |
| 203 |
- builtin_log_node |
| 204 |
- builtin_log_node_ascii |
| 205 |
- builtin_log_oneline |
| 206 |
- builtin_log_redacted |
| 207 |
- builtin_op_log_comfortable |
| 208 |
- builtin_op_log_compact |
| 209 |
- builtin_op_log_node |
| 210 |
- builtin_op_log_node_ascii |
| 211 |
- builtin_op_log_oneline |
| 212 |
- builtin_op_log_redacted |
| 213 |
- builtin_workspace_list |
| 214 |
- commit_summary_separator |
| 215 |
- default_commit_description |
| 216 |
- description_placeholder |
| 217 |
- email_placeholder |
| 218 |
- empty_commit_marker |
| 219 |
- git_format_patch_email_headers |
| 220 |
- name_placeholder |
| 221 |
[EOF] |
| 222 |
[exit status: 2] |
| 223 |
"); |
| 224 |
} |
| 225 |
|
| 226 |
#[test] |
| 227 |
fn test_op_log_limit() { |
| 228 |
let test_env = TestEnvironment::default(); |
| 229 |
test_env.run_jj_in(".", ["git", "init", "repo"]).success(); |
| 230 |
let work_dir = test_env.work_dir("repo"); |
| 231 |
|
| 232 |
let output = work_dir.run_jj(["op", "log", "-Tdescription", "--limit=1"]); |
| 233 |
insta::assert_snapshot!(output, @" |
| 234 |
@ add workspace 'default' |
| 235 |
[EOF] |
| 236 |
"); |
| 237 |
} |
| 238 |
|
| 239 |
#[test] |
| 240 |
fn test_op_log_no_graph() { |
| 241 |
let test_env = TestEnvironment::default(); |
| 242 |
test_env.run_jj_in(".", ["git", "init", "repo"]).success(); |
| 243 |
let work_dir = test_env.work_dir("repo"); |
| 244 |
|
| 245 |
let output = work_dir.run_jj(["op", "log", "--no-graph", "--color=always"]); |
| 246 |
insta::assert_snapshot!(output, @" |
| 247 |
[1m[38;5;12mf63ee16f9553[39m [38;5;[email protected][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 |
| 248 |
[1madd workspace 'default'[0m |
| 249 |
[38;5;4m000000000000[39m [38;5;2mroot()[39m |
| 250 |
[EOF] |
| 251 |
"); |
| 252 |
|
| 253 |
let output = work_dir.run_jj(["op", "log", "--op-diff", "--no-graph"]); |
| 254 |
insta::assert_snapshot!(output, @" |
| 255 |
f63ee16f9553 [email protected] 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00 |
| 256 |
add workspace 'default' |
| 257 |
|
| 258 |
Changed commits: |
| 259 |
+ qpvuntsm e8849ae1 (empty) (no description set) |
| 260 |
|
| 261 |
Changed working copy default@: |
| 262 |
+ qpvuntsm e8849ae1 (empty) (no description set) |
| 263 |
- (absent) |
| 264 |
000000000000 root() |
| 265 |
[EOF] |
| 266 |
"); |
| 267 |
} |
| 268 |
|
| 269 |
#[test] |
| 270 |
fn test_op_log_reversed() { |
| 271 |
let test_env = TestEnvironment::default(); |
| 272 |
test_env.run_jj_in(".", ["git", "init", "repo"]).success(); |
| 273 |
let work_dir = test_env.work_dir("repo"); |
| 274 |
work_dir |
| 275 |
.run_jj(["describe", "-m", "description 0"]) |
| 276 |
.success(); |
| 277 |
|
| 278 |
let output = work_dir.run_jj(["op", "log", "--reversed"]); |
| 279 |
insta::assert_snapshot!(output, @" |
| 280 |
○ 000000000000 root() |
| 281 |
○ f63ee16f9553 [email protected] 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00 |
| 282 |
│ add workspace 'default' |
| 283 |
@ 7749eb4df93f [email protected] default@ 2001-02-03 04:05:08.000 +07:00 - 2001-02-03 04:05:08.000 +07:00 |
| 284 |
describe commit e8849ae12c709f2321908879bc724fdb2ab8a781 |
| 285 |
args: jj describe -m 'description 0' |
| 286 |
[EOF] |
| 287 |
"); |
| 288 |
|
| 289 |
work_dir |
| 290 |
.run_jj(["describe", "-m", "description 1", "--at-op", "@-"]) |
| 291 |
.success(); |
| 292 |
|
| 293 |
// Should be able to display log with fork and branch points |
| 294 |
let output = work_dir.run_jj(["op", "log", "--reversed"]); |
| 295 |
insta::assert_snapshot!(output, @" |
| 296 |
○ 000000000000 root() |
| 297 |
○ f63ee16f9553 [email protected] 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00 |
| 298 |
├─╮ add workspace 'default' |
| 299 |
│ ○ 14a336c68678 [email protected] default@ 2001-02-03 04:05:10.000 +07:00 - 2001-02-03 04:05:10.000 +07:00 |
| 300 |
│ │ describe commit e8849ae12c709f2321908879bc724fdb2ab8a781 |
| 301 |
│ │ args: jj describe -m 'description 1' --at-op @- |
| 302 |
○ │ 7749eb4df93f [email protected] default@ 2001-02-03 04:05:08.000 +07:00 - 2001-02-03 04:05:08.000 +07:00 |
| 303 |
├─╯ describe commit e8849ae12c709f2321908879bc724fdb2ab8a781 |
| 304 |
│ args: jj describe -m 'description 0' |
| 305 |
@ 684841dcf740 [email protected] default@ 2001-02-03 04:05:11.000 +07:00 - 2001-02-03 04:05:11.000 +07:00 |
| 306 |
reconcile divergent operations |
| 307 |
args: jj op log --reversed |
| 308 |
[EOF] |
| 309 |
------- stderr ------- |
| 310 |
Concurrent modification detected, resolving automatically. |
| 311 |
[EOF] |
| 312 |
"); |
| 313 |
|
| 314 |
// Should work correctly with `--no-graph` |
| 315 |
let output = work_dir.run_jj(["op", "log", "--reversed", "--no-graph"]); |
| 316 |
insta::assert_snapshot!(output, @" |
| 317 |
000000000000 root() |
| 318 |
f63ee16f9553 [email protected] 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00 |
| 319 |
add workspace 'default' |
| 320 |
14a336c68678 [email protected] default@ 2001-02-03 04:05:10.000 +07:00 - 2001-02-03 04:05:10.000 +07:00 |
| 321 |
describe commit e8849ae12c709f2321908879bc724fdb2ab8a781 |
| 322 |
args: jj describe -m 'description 1' --at-op @- |
| 323 |
7749eb4df93f [email protected] default@ 2001-02-03 04:05:08.000 +07:00 - 2001-02-03 04:05:08.000 +07:00 |
| 324 |
describe commit e8849ae12c709f2321908879bc724fdb2ab8a781 |
| 325 |
args: jj describe -m 'description 0' |
| 326 |
684841dcf740 [email protected] default@ 2001-02-03 04:05:11.000 +07:00 - 2001-02-03 04:05:11.000 +07:00 |
| 327 |
reconcile divergent operations |
| 328 |
args: jj op log --reversed |
| 329 |
[EOF] |
| 330 |
"); |
| 331 |
|
| 332 |
// Should work correctly with `--limit` |
| 333 |
let output = work_dir.run_jj(["op", "log", "--reversed", "--limit=3"]); |
| 334 |
insta::assert_snapshot!(output, @" |
| 335 |
○ 14a336c68678 [email protected] default@ 2001-02-03 04:05:10.000 +07:00 - 2001-02-03 04:05:10.000 +07:00 |
| 336 |
│ describe commit e8849ae12c709f2321908879bc724fdb2ab8a781 |
| 337 |
│ args: jj describe -m 'description 1' --at-op @- |
| 338 |
│ ○ 7749eb4df93f [email protected] default@ 2001-02-03 04:05:08.000 +07:00 - 2001-02-03 04:05:08.000 +07:00 |
| 339 |
├─╯ describe commit e8849ae12c709f2321908879bc724fdb2ab8a781 |
| 340 |
│ args: jj describe -m 'description 0' |
| 341 |
@ 684841dcf740 [email protected] default@ 2001-02-03 04:05:11.000 +07:00 - 2001-02-03 04:05:11.000 +07:00 |
| 342 |
reconcile divergent operations |
| 343 |
args: jj op log --reversed |
| 344 |
[EOF] |
| 345 |
"); |
| 346 |
|
| 347 |
// Should work correctly with `--limit` and `--no-graph` |
| 348 |
let output = work_dir.run_jj(["op", "log", "--reversed", "--limit=2", "--no-graph"]); |
| 349 |
insta::assert_snapshot!(output, @" |
| 350 |
7749eb4df93f [email protected] default@ 2001-02-03 04:05:08.000 +07:00 - 2001-02-03 04:05:08.000 +07:00 |
| 351 |
describe commit e8849ae12c709f2321908879bc724fdb2ab8a781 |
| 352 |
args: jj describe -m 'description 0' |
| 353 |
684841dcf740 [email protected] default@ 2001-02-03 04:05:11.000 +07:00 - 2001-02-03 04:05:11.000 +07:00 |
| 354 |
reconcile divergent operations |
| 355 |
args: jj op log --reversed |
| 356 |
[EOF] |
| 357 |
"); |
| 358 |
} |
| 359 |
|
| 360 |
#[test] |
| 361 |
fn test_op_log_no_graph_null_terminated() { |
| 362 |
let test_env = TestEnvironment::default(); |
| 363 |
test_env.run_jj_in(".", ["git", "init", "repo"]).success(); |
| 364 |
let work_dir = test_env.work_dir("repo"); |
| 365 |
work_dir.run_jj(["commit", "-m", "message1"]).success(); |
| 366 |
work_dir.run_jj(["commit", "-m", "message2"]).success(); |
| 367 |
|
| 368 |
let output = work_dir |
| 369 |
.run_jj([ |
| 370 |
"op", |
| 371 |
"log", |
| 372 |
"--no-graph", |
| 373 |
"--template", |
| 374 |
r#"id.short(4) ++ "\0""#, |
| 375 |
]) |
| 376 |
.success(); |
| 377 |
insta::assert_debug_snapshot!(output.stdout.normalized(), @r#""bdb7\0a4de\0f63e\00000\0""#); |
| 378 |
} |
| 379 |
|
| 380 |
#[test] |
| 381 |
fn test_op_log_template() -> TestResult { |
| 382 |
let test_env = TestEnvironment::default(); |
| 383 |
test_env.run_jj_in(".", ["git", "init", "repo"]).success(); |
| 384 |
let work_dir = test_env.work_dir("repo"); |
| 385 |
let render = |template| work_dir.run_jj(["op", "log", "-T", template]); |
| 386 |
|
| 387 |
insta::assert_snapshot!(render(r#"id ++ "\n""#), @" |
| 388 |
@ f63ee16f95539ec5bda4a7178aa3ace2bf594719aa2cc3410cfc4d070cb31ae31225bef146eb2428baf760180976c936cd60891e7a9087e6836d3a315fe81030 |
| 389 |
○ 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 |
| 390 |
[EOF] |
| 391 |
"); |
| 392 |
insta::assert_snapshot!( |
| 393 |
render(r#"separate(" ", id.short(5), current_operation, user, |
| 394 |
time.start(), time.end(), time.duration()) ++ "\n""#), @" |
| 395 |
@ f63ee true [email protected] 2001-02-03 04:05:07.000 +07:00 2001-02-03 04:05:07.000 +07:00 less than a microsecond |
| 396 |
○ 00000 false @ 1970-01-01 00:00:00.000 +00:00 1970-01-01 00:00:00.000 +00:00 less than a microsecond |
| 397 |
[EOF] |
| 398 |
"); |
| 399 |
|
| 400 |
// Negative length shouldn't cause panic. |
| 401 |
insta::assert_snapshot!(render(r#"id.short(-1) ++ "|""#), @" |
| 402 |
@ <Error: out of range integral type conversion attempted>| |
| 403 |
○ <Error: out of range integral type conversion attempted>| |
| 404 |
[EOF] |
| 405 |
"); |
| 406 |
|
| 407 |
insta::assert_snapshot!(render(r#"json(self) ++ "\n""#), @r#" |
| 408 |
@ {"id":"f63ee16f95539ec5bda4a7178aa3ace2bf594719aa2cc3410cfc4d070cb31ae31225bef146eb2428baf760180976c936cd60891e7a9087e6836d3a315fe81030","parents":["00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"],"time":{"start":"2001-02-03T04:05:07+07:00","end":"2001-02-03T04:05:07+07:00"},"description":"add workspace 'default'","hostname":"host.example.com","username":"test-username","is_snapshot":false,"workspace_name":null,"attributes":{}} |
| 409 |
○ {"id":"00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","parents":[],"time":{"start":"1970-01-01T00:00:00Z","end":"1970-01-01T00:00:00Z"},"description":"","hostname":"","username":"","is_snapshot":false,"workspace_name":null,"attributes":{}} |
| 410 |
[EOF] |
| 411 |
"#); |
| 412 |
|
| 413 |
// Test the default template, i.e. with relative start time and duration. We |
| 414 |
// don't generally use that template because it depends on the current time, |
| 415 |
// so we need to reset the time range format here. |
| 416 |
test_env.add_config( |
| 417 |
r#" |
| 418 |
[template-aliases] |
| 419 |
'format_time_range(time_range)' = 'time_range.end().ago() ++ ", lasted " ++ time_range.duration()' |
| 420 |
"#, |
| 421 |
); |
| 422 |
let regex = Regex::new(r"\d\d years")?; |
| 423 |
let output = work_dir.run_jj(["op", "log"]); |
| 424 |
insta::assert_snapshot!( |
| 425 |
output.normalize_stdout_with(|s| regex.replace_all(&s, "NN years").into_owned()), @" |
| 426 |
@ f63ee16f9553 [email protected] NN years ago, lasted less than a microsecond |
| 427 |
│ add workspace 'default' |
| 428 |
○ 000000000000 root() |
| 429 |
[EOF] |
| 430 |
"); |
| 431 |
Ok(()) |
| 432 |
} |
| 433 |
|
| 434 |
#[test] |
| 435 |
fn test_op_log_builtin_templates() { |
| 436 |
let test_env = TestEnvironment::default(); |
| 437 |
test_env.run_jj_in(".", ["git", "init", "repo"]).success(); |
| 438 |
let work_dir = test_env.work_dir("repo"); |
| 439 |
// Render without graph to test line ending |
| 440 |
let render = |template| work_dir.run_jj(["op", "log", "-T", template, "--no-graph"]); |
| 441 |
work_dir |
| 442 |
.run_jj(["describe", "-m", "description 0"]) |
| 443 |
.success(); |
| 444 |
|
| 445 |
insta::assert_snapshot!(render(r#"builtin_op_log_compact"#), @" |
| 446 |
7749eb4df93f [email protected] default@ 2001-02-03 04:05:08.000 +07:00 - 2001-02-03 04:05:08.000 +07:00 |
| 447 |
describe commit e8849ae12c709f2321908879bc724fdb2ab8a781 |
| 448 |
args: jj describe -m 'description 0' |
| 449 |
f63ee16f9553 [email protected] 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00 |
| 450 |
add workspace 'default' |
| 451 |
000000000000 root() |
| 452 |
[EOF] |
| 453 |
"); |
| 454 |
|
| 455 |
insta::assert_snapshot!(render(r#"builtin_op_log_comfortable"#), @" |
| 456 |
7749eb4df93f [email protected] default@ 2001-02-03 04:05:08.000 +07:00 - 2001-02-03 04:05:08.000 +07:00 |
| 457 |
describe commit e8849ae12c709f2321908879bc724fdb2ab8a781 |
| 458 |
args: jj describe -m 'description 0' |
| 459 |
|
| 460 |
f63ee16f9553 [email protected] 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00 |
| 461 |
add workspace 'default' |
| 462 |
|
| 463 |
000000000000 root() |
| 464 |
|
| 465 |
[EOF] |
| 466 |
"); |
| 467 |
|
| 468 |
insta::assert_snapshot!(render(r#"builtin_op_log_oneline"#), @" |
| 469 |
7749eb4df93f [email protected] default@ 2001-02-03 04:05:08.000 +07:00 - 2001-02-03 04:05:08.000 +07:00 describe commit e8849ae12c709f2321908879bc724fdb2ab8a781 args: jj describe -m 'description 0' |
| 470 |
f63ee16f9553 [email protected] 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00 add workspace 'default' |
| 471 |
000000000000 root() |
| 472 |
[EOF] |
| 473 |
"); |
| 474 |
} |
| 475 |
|
| 476 |
#[test] |
| 477 |
fn test_op_log_word_wrap() { |
| 478 |
let test_env = TestEnvironment::default(); |
| 479 |
test_env.run_jj_in(".", ["git", "init", "repo"]).success(); |
| 480 |
let work_dir = test_env.work_dir("repo"); |
| 481 |
work_dir.write_file("file1", "foo\n".repeat(100)); |
| 482 |
work_dir.run_jj(["debug", "snapshot"]).success(); |
| 483 |
|
| 484 |
let render = |args: &[&str], columns: u32, word_wrap: bool| { |
| 485 |
let word_wrap = to_toml_value(word_wrap); |
| 486 |
work_dir.run_jj_with(|cmd| { |
| 487 |
cmd.args(args) |
| 488 |
.arg(format!("--config=ui.log-word-wrap={word_wrap}")) |
| 489 |
.env("COLUMNS", columns.to_string()) |
| 490 |
}) |
| 491 |
}; |
| 492 |
|
| 493 |
// ui.log-word-wrap option works |
| 494 |
insta::assert_snapshot!(render(&["op", "log"], 40, false), @" |
| 495 |
@ 2c5632322012 [email protected] default@ 2001-02-03 04:05:08.000 +07:00 - 2001-02-03 04:05:08.000 +07:00 |
| 496 |
│ snapshot working copy |
| 497 |
│ args: jj debug snapshot |
| 498 |
○ f63ee16f9553 [email protected] 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00 |
| 499 |
│ add workspace 'default' |
| 500 |
○ 000000000000 root() |
| 501 |
[EOF] |
| 502 |
"); |
| 503 |
insta::assert_snapshot!(render(&["op", "log"], 40, true), @" |
| 504 |
@ 2c5632322012 |
| 505 |
│ [email protected] |
| 506 |
│ default@ 2001-02-03 04:05:08.000 |
| 507 |
│ +07:00 - 2001-02-03 04:05:08.000 |
| 508 |
│ +07:00 |
| 509 |
│ snapshot working copy |
| 510 |
│ args: jj debug snapshot |
| 511 |
○ f63ee16f9553 |
| 512 |
│ [email protected] |
| 513 |
│ 2001-02-03 04:05:07.000 +07:00 - |
| 514 |
│ 2001-02-03 04:05:07.000 +07:00 |
| 515 |
│ add workspace 'default' |
| 516 |
○ 000000000000 root() |
| 517 |
[EOF] |
| 518 |
"); |
| 519 |
|
| 520 |
// Nested graph should be wrapped |
| 521 |
insta::assert_snapshot!(render(&["op", "log", "--op-diff"], 40, true), @" |
| 522 |
@ 2c5632322012 |
| 523 |
│ [email protected] |
| 524 |
│ default@ 2001-02-03 04:05:08.000 |
| 525 |
│ +07:00 - 2001-02-03 04:05:08.000 |
| 526 |
│ +07:00 |
| 527 |
│ snapshot working copy |
| 528 |
│ args: jj debug snapshot |
| 529 |
│ |
| 530 |
│ Changed commits: |
| 531 |
│ ○ + qpvuntsm 79f0968d (no |
| 532 |
│ description set) |
| 533 |
│ - qpvuntsm/1 e8849ae1 (hidden) |
| 534 |
│ (empty) (no description set) |
| 535 |
│ |
| 536 |
│ Changed working copy default@: |
| 537 |
│ + qpvuntsm 79f0968d (no description |
| 538 |
│ set) |
| 539 |
│ - qpvuntsm/1 e8849ae1 (hidden) |
| 540 |
│ (empty) (no description set) |
| 541 |
○ f63ee16f9553 |
| 542 |
│ [email protected] |
| 543 |
│ 2001-02-03 04:05:07.000 +07:00 - |
| 544 |
│ 2001-02-03 04:05:07.000 +07:00 |
| 545 |
│ add workspace 'default' |
| 546 |
│ |
| 547 |
│ Changed commits: |
| 548 |
│ ○ + qpvuntsm e8849ae1 (empty) (no |
| 549 |
│ description set) |
| 550 |
│ |
| 551 |
│ Changed working copy default@: |
| 552 |
│ + qpvuntsm e8849ae1 (empty) (no |
| 553 |
│ description set) |
| 554 |
│ - (absent) |
| 555 |
○ 000000000000 root() |
| 556 |
[EOF] |
| 557 |
"); |
| 558 |
|
| 559 |
// Nested diff stat shouldn't exceed the terminal width |
| 560 |
insta::assert_snapshot!(render(&["op", "log", "-n1", "--stat"], 40, true), @" |
| 561 |
@ 2c5632322012 |
| 562 |
│ [email protected] |
| 563 |
│ default@ 2001-02-03 04:05:08.000 |
| 564 |
│ +07:00 - 2001-02-03 04:05:08.000 |
| 565 |
│ +07:00 |
| 566 |
│ snapshot working copy |
| 567 |
│ args: jj debug snapshot |
| 568 |
│ |
| 569 |
│ Changed commits: |
| 570 |
│ ○ + qpvuntsm 79f0968d (no |
| 571 |
│ description set) |
| 572 |
│ - qpvuntsm/1 e8849ae1 (hidden) |
| 573 |
│ (empty) (no description set) |
| 574 |
│ file1 | 100 ++++++++++++++++++++++ |
| 575 |
│ 1 file changed, 100 insertions(+), 0 deletions(-) |
| 576 |
│ |
| 577 |
│ Changed working copy default@: |
| 578 |
│ + qpvuntsm 79f0968d (no description |
| 579 |
│ set) |
| 580 |
│ - qpvuntsm/1 e8849ae1 (hidden) |
| 581 |
│ (empty) (no description set) |
| 582 |
[EOF] |
| 583 |
"); |
| 584 |
insta::assert_snapshot!(render(&["op", "log", "-n1", "--no-graph", "--stat"], 40, true), @" |
| 585 |
2c5632322012 |
| 586 |
[email protected] default@ |
| 587 |
2001-02-03 04:05:08.000 +07:00 - |
| 588 |
2001-02-03 04:05:08.000 +07:00 |
| 589 |
snapshot working copy |
| 590 |
args: jj debug snapshot |
| 591 |
|
| 592 |
Changed commits: |
| 593 |
+ qpvuntsm 79f0968d (no description set) |
| 594 |
- qpvuntsm/1 e8849ae1 (hidden) (empty) |
| 595 |
(no description set) |
| 596 |
file1 | 100 ++++++++++++++++++++++++++++ |
| 597 |
1 file changed, 100 insertions(+), 0 deletions(-) |
| 598 |
|
| 599 |
Changed working copy default@: |
| 600 |
+ qpvuntsm 79f0968d (no description set) |
| 601 |
- qpvuntsm/1 e8849ae1 (hidden) (empty) |
| 602 |
(no description set) |
| 603 |
[EOF] |
| 604 |
"); |
| 605 |
|
| 606 |
// Nested graph widths should be subtracted from the term width |
| 607 |
let config = r#"templates.commit_summary='"0 1 2 3 4 5 6 7 8 9"'"#; |
| 608 |
insta::assert_snapshot!( |
| 609 |
render(&["op", "log", "-T''", "--op-diff", "-n1", "--config", config], 15, true), @" |
| 610 |
@ |
| 611 |
│ Changed |
| 612 |
│ commits: |
| 613 |
│ ○ + 0 1 2 3 |
| 614 |
│ 4 5 6 7 8 |
| 615 |
│ 9 |
| 616 |
│ - 0 1 2 3 |
| 617 |
│ 4 5 6 7 8 |
| 618 |
│ 9 |
| 619 |
│ |
| 620 |
│ Changed |
| 621 |
│ working copy |
| 622 |
│ default@: |
| 623 |
│ + 0 1 2 3 4 |
| 624 |
│ 5 6 7 8 9 |
| 625 |
│ - 0 1 2 3 4 |
| 626 |
│ 5 6 7 8 9 |
| 627 |
[EOF] |
| 628 |
"); |
| 629 |
} |
| 630 |
|
| 631 |
#[test] |
| 632 |
fn test_op_log_configurable() { |
| 633 |
let test_env = TestEnvironment::default(); |
| 634 |
test_env.add_config( |
| 635 |
r#"operation.hostname = "my-hostname" |
| 636 |
operation.username = "my-username" |
| 637 |
"#, |
| 638 |
); |
| 639 |
test_env |
| 640 |
.run_jj_with(|cmd| { |
| 641 |
cmd.args(["git", "init", "repo"]) |
| 642 |
.env_remove("JJ_OP_HOSTNAME") |
| 643 |
.env_remove("JJ_OP_USERNAME") |
| 644 |
}) |
| 645 |
.success(); |
| 646 |
let work_dir = test_env.work_dir("repo"); |
| 647 |
|
| 648 |
let output = work_dir.run_jj(["op", "log"]); |
| 649 |
insta::assert_snapshot!(output, @" |
| 650 |
@ 37978585dec5 my-username@my-hostname 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00 |
| 651 |
│ add workspace 'default' |
| 652 |
○ 000000000000 root() |
| 653 |
[EOF] |
| 654 |
"); |
| 655 |
} |
| 656 |
|
| 657 |
#[test] |
| 658 |
fn test_op_abandon_invalid() { |
| 659 |
let test_env = TestEnvironment::default(); |
| 660 |
test_env.run_jj_in(".", ["git", "init", "repo"]).success(); |
| 661 |
let work_dir = test_env.work_dir("repo"); |
| 662 |
|
| 663 |
// Create a merge operation |
| 664 |
work_dir.run_jj(["commit", "-m", "commit 1"]).success(); |
| 665 |
work_dir |
| 666 |
.run_jj(["commit", "--at-op=@-", "-m", "commit 2"]) |
| 667 |
.success(); |
| 668 |
work_dir.run_jj(["commit", "-m", "commit 3"]).success(); |
| 669 |
|
| 670 |
insta::assert_snapshot!(work_dir.run_jj(["op", "log", "-T", "description"]), @" |
| 671 |
@ commit 4e0592f3dd52e7a4998a97d9a1f354e2727a856b |
| 672 |
○ reconcile divergent operations |
| 673 |
├─╮ |
| 674 |
○ │ commit e8849ae12c709f2321908879bc724fdb2ab8a781 |
| 675 |
│ ○ commit e8849ae12c709f2321908879bc724fdb2ab8a781 |
| 676 |
├─╯ |
| 677 |
○ add workspace 'default' |
| 678 |
○ |
| 679 |
[EOF] |
| 680 |
"); |
| 681 |
|
| 682 |
// Cannot abandon the root operation |
| 683 |
let output = work_dir.run_jj(["op", "abandon", "000000000000"]); |
| 684 |
insta::assert_snapshot!(output, @" |
| 685 |
------- stderr ------- |
| 686 |
Error: Cannot abandon the root operation |
| 687 |
[EOF] |
| 688 |
[exit status: 1] |
| 689 |
"); |
| 690 |
|
| 691 |
// Cannot abandon merge operations |
| 692 |
let output = work_dir.run_jj(["op", "abandon", "@-"]); |
| 693 |
insta::assert_snapshot!(output, @" |
| 694 |
------- stderr ------- |
| 695 |
Error: Cannot abandon a merge operation |
| 696 |
[EOF] |
| 697 |
[exit status: 1] |
| 698 |
"); |
| 699 |
|
| 700 |
// Cannot abandon the current operation (specified via "..") |
| 701 |
let output = work_dir.run_jj(["op", "abandon", "@-.."]); |
| 702 |
insta::assert_snapshot!(output, @" |
| 703 |
------- stderr ------- |
| 704 |
Error: Cannot abandon the current operation 0facabbe7f97 |
| 705 |
Hint: Run `jj undo` to revert the current operation, then use `jj op abandon` |
| 706 |
[EOF] |
| 707 |
[exit status: 1] |
| 708 |
"); |
| 709 |
|
| 710 |
// Confirm no change |
| 711 |
insta::assert_snapshot!(work_dir.run_jj(["op", "log", "-T", "description"]), @" |
| 712 |
@ commit 4e0592f3dd52e7a4998a97d9a1f354e2727a856b |
| 713 |
○ reconcile divergent operations |
| 714 |
├─╮ |
| 715 |
○ │ commit e8849ae12c709f2321908879bc724fdb2ab8a781 |
| 716 |
│ ○ commit e8849ae12c709f2321908879bc724fdb2ab8a781 |
| 717 |
├─╯ |
| 718 |
○ add workspace 'default' |
| 719 |
○ |
| 720 |
[EOF] |
| 721 |
"); |
| 722 |
} |
| 723 |
|
| 724 |
#[test] |
| 725 |
fn test_op_abandon_ancestors() { |
| 726 |
let test_env = TestEnvironment::default(); |
| 727 |
test_env.run_jj_in(".", ["git", "init", "repo"]).success(); |
| 728 |
let work_dir = test_env.work_dir("repo"); |
| 729 |
|
| 730 |
work_dir.run_jj(["commit", "-m", "commit 1"]).success(); |
| 731 |
work_dir.run_jj(["commit", "-m", "commit 2"]).success(); |
| 732 |
insta::assert_snapshot!(work_dir.run_jj(["op", "log"]), @" |
| 733 |
@ b004de1c8d83 [email protected] default@ 2001-02-03 04:05:09.000 +07:00 - 2001-02-03 04:05:09.000 +07:00 |
| 734 |
│ commit 4e0592f3dd52e7a4998a97d9a1f354e2727a856b |
| 735 |
│ args: jj commit -m 'commit 2' |
| 736 |
○ 5d7c2b4596e3 [email protected] default@ 2001-02-03 04:05:08.000 +07:00 - 2001-02-03 04:05:08.000 +07:00 |
| 737 |
│ commit e8849ae12c709f2321908879bc724fdb2ab8a781 |
| 738 |
│ args: jj commit -m 'commit 1' |
| 739 |
○ f63ee16f9553 [email protected] 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00 |
| 740 |
│ add workspace 'default' |
| 741 |
○ 000000000000 root() |
| 742 |
[EOF] |
| 743 |
"); |
| 744 |
|
| 745 |
// Abandon old operations. The working-copy operation id should be updated. |
| 746 |
let output = work_dir.run_jj(["op", "abandon", "..@-"]); |
| 747 |
insta::assert_snapshot!(output, @" |
| 748 |
------- stderr ------- |
| 749 |
Abandoned 2 operations and reparented 1 descendant operations. |
| 750 |
[EOF] |
| 751 |
"); |
| 752 |
insta::assert_snapshot!(work_dir.run_jj(["debug", "local-working-copy", "--ignore-working-copy"]), @r#" |
| 753 |
Current operation: OperationId("16e498947b26cdd5e09fd250167d03254f6a9d8ce555e3838bbf432e2c5d7b90d5d80414f11aa67df1ecb8074eadf3fd79336feeb2c5e564c9dc711de5d38d96") |
| 754 |
Current tree: MergedTree { tree_ids: Resolved(TreeId("4b825dc642cb6eb9a060e54bf8d69288fbee4904")), labels: Unlabeled, .. } |
| 755 |
[EOF] |
| 756 |
"#); |
| 757 |
insta::assert_snapshot!(work_dir.run_jj(["op", "log"]), @" |
| 758 |
@ 16e498947b26 [email protected] default@ 2001-02-03 04:05:09.000 +07:00 - 2001-02-03 04:05:09.000 +07:00 |
| 759 |
│ commit 4e0592f3dd52e7a4998a97d9a1f354e2727a856b |
| 760 |
│ args: jj commit -m 'commit 2' |
| 761 |
○ 000000000000 root() |
| 762 |
[EOF] |
| 763 |
"); |
| 764 |
|
| 765 |
// Abandon operation range. |
| 766 |
work_dir.run_jj(["commit", "-m", "commit 3"]).success(); |
| 767 |
work_dir.run_jj(["commit", "-m", "commit 4"]).success(); |
| 768 |
work_dir.run_jj(["commit", "-m", "commit 5"]).success(); |
| 769 |
let output = work_dir.run_jj(["op", "abandon", "@---..@-"]); |
| 770 |
insta::assert_snapshot!(output, @" |
| 771 |
------- stderr ------- |
| 772 |
Abandoned 2 operations and reparented 1 descendant operations. |
| 773 |
[EOF] |
| 774 |
"); |
| 775 |
insta::assert_snapshot!(work_dir.run_jj(["op", "log"]), @" |
| 776 |
@ 563693e8149d [email protected] default@ 2001-02-03 04:05:16.000 +07:00 - 2001-02-03 04:05:16.000 +07:00 |
| 777 |
│ commit 2f3e935ade915272ccdce9e43e5a5c82fc336aee |
| 778 |
│ args: jj commit -m 'commit 5' |
| 779 |
○ 16e498947b26 [email protected] default@ 2001-02-03 04:05:09.000 +07:00 - 2001-02-03 04:05:09.000 +07:00 |
| 780 |
│ commit 4e0592f3dd52e7a4998a97d9a1f354e2727a856b |
| 781 |
│ args: jj commit -m 'commit 2' |
| 782 |
○ 000000000000 root() |
| 783 |
[EOF] |
| 784 |
"); |
| 785 |
|
| 786 |
// Can't abandon the current operation. |
| 787 |
let output = work_dir.run_jj(["op", "abandon", "..@"]); |
| 788 |
insta::assert_snapshot!(output, @" |
| 789 |
------- stderr ------- |
| 790 |
Error: Cannot abandon the current operation 563693e8149d |
| 791 |
Hint: Run `jj undo` to revert the current operation, then use `jj op abandon` |
| 792 |
[EOF] |
| 793 |
[exit status: 1] |
| 794 |
"); |
| 795 |
|
| 796 |
// Can't create concurrent abandoned operations explicitly. |
| 797 |
let output = work_dir.run_jj(["op", "abandon", "--at-op=@-", "@"]); |
| 798 |
insta::assert_snapshot!(output, @" |
| 799 |
------- stderr ------- |
| 800 |
Error: --at-op is not respected |
| 801 |
[EOF] |
| 802 |
[exit status: 2] |
| 803 |
"); |
| 804 |
|
| 805 |
// Abandon the current operation by reverting it first. |
| 806 |
work_dir.run_jj(["op", "revert"]).success(); |
| 807 |
let output = work_dir.run_jj(["op", "abandon", "@-"]); |
| 808 |
insta::assert_snapshot!(output, @" |
| 809 |
------- stderr ------- |
| 810 |
Abandoned 1 operations and reparented 1 descendant operations. |
| 811 |
[EOF] |
| 812 |
"); |
| 813 |
insta::assert_snapshot!(work_dir.run_jj(["debug", "local-working-copy", "--ignore-working-copy"]), @r#" |
| 814 |
Current operation: OperationId("76472b5d1bf3739c027318ab349ce8531cfedc3738f87abf78dd9e5482fdb165aa34a4edba3a281bab884d9df551a731512702fc43096a59c3569568fa9b0dba") |
| 815 |
Current tree: MergedTree { tree_ids: Resolved(TreeId("4b825dc642cb6eb9a060e54bf8d69288fbee4904")), labels: Unlabeled, .. } |
| 816 |
[EOF] |
| 817 |
"#); |
| 818 |
insta::assert_snapshot!(work_dir.run_jj(["op", "log"]), @" |
| 819 |
@ 76472b5d1bf3 [email protected] default@ 2001-02-03 04:05:21.000 +07:00 - 2001-02-03 04:05:21.000 +07:00 |
| 820 |
│ revert operation 563693e8149d715c5ef70b1d98df1f6d9329f4318250a65d8bebddd8b671774b71a8874e61702f704e7aef07b9f1b2210341b8d1eba163d455ad63bb65b74bfc |
| 821 |
│ args: jj op revert |
| 822 |
○ 16e498947b26 [email protected] default@ 2001-02-03 04:05:09.000 +07:00 - 2001-02-03 04:05:09.000 +07:00 |
| 823 |
│ commit 4e0592f3dd52e7a4998a97d9a1f354e2727a856b |
| 824 |
│ args: jj commit -m 'commit 2' |
| 825 |
○ 000000000000 root() |
| 826 |
[EOF] |
| 827 |
"); |
| 828 |
|
| 829 |
// Abandon empty range. |
| 830 |
let output = work_dir.run_jj(["op", "abandon", "@-..@-"]); |
| 831 |
insta::assert_snapshot!(output, @" |
| 832 |
------- stderr ------- |
| 833 |
Nothing changed. |
| 834 |
[EOF] |
| 835 |
"); |
| 836 |
insta::assert_snapshot!(work_dir.run_jj(["op", "log", "-n1"]), @" |
| 837 |
@ 76472b5d1bf3 [email protected] default@ 2001-02-03 04:05:21.000 +07:00 - 2001-02-03 04:05:21.000 +07:00 |
| 838 |
│ revert operation 563693e8149d715c5ef70b1d98df1f6d9329f4318250a65d8bebddd8b671774b71a8874e61702f704e7aef07b9f1b2210341b8d1eba163d455ad63bb65b74bfc |
| 839 |
│ args: jj op revert |
| 840 |
[EOF] |
| 841 |
"); |
| 842 |
} |
| 843 |
|
| 844 |
#[test] |
| 845 |
fn test_op_abandon_without_updating_working_copy() { |
| 846 |
let test_env = TestEnvironment::default(); |
| 847 |
test_env.run_jj_in(".", ["git", "init", "repo"]).success(); |
| 848 |
let work_dir = test_env.work_dir("repo"); |
| 849 |
|
| 850 |
work_dir.run_jj(["commit", "-m", "commit 1"]).success(); |
| 851 |
work_dir.run_jj(["commit", "-m", "commit 2"]).success(); |
| 852 |
work_dir.run_jj(["commit", "-m", "commit 3"]).success(); |
| 853 |
|
| 854 |
// Abandon without updating the working copy. |
| 855 |
let output = work_dir.run_jj(["op", "abandon", "@-", "--ignore-working-copy"]); |
| 856 |
insta::assert_snapshot!(output, @" |
| 857 |
------- stderr ------- |
| 858 |
Abandoned 1 operations and reparented 1 descendant operations. |
| 859 |
[EOF] |
| 860 |
"); |
| 861 |
insta::assert_snapshot!(work_dir.run_jj(["debug", "local-working-copy", "--ignore-working-copy"]), @r#" |
| 862 |
Current operation: OperationId("62f41230e57ec67e2181e49cbc7c2e43c42aaddd5ea7f10c401ba6e0e92c20c22815994ff9993e0e0625561c7f9e0d9b2e9817cdcedb3d19dce5609be43a0859") |
| 863 |
Current tree: MergedTree { tree_ids: Resolved(TreeId("4b825dc642cb6eb9a060e54bf8d69288fbee4904")), labels: Unlabeled, .. } |
| 864 |
[EOF] |
| 865 |
"#); |
| 866 |
insta::assert_snapshot!(work_dir.run_jj(["op", "log", "-n1", "--ignore-working-copy"]), @" |
| 867 |
@ 057d224b4c7c [email protected] default@ 2001-02-03 04:05:10.000 +07:00 - 2001-02-03 04:05:10.000 +07:00 |
| 868 |
│ commit 4b087e94a5d14530c3953d617623d075a13294c8 |
| 869 |
│ args: jj commit -m 'commit 3' |
| 870 |
[EOF] |
| 871 |
"); |
| 872 |
|
| 873 |
// The working-copy operation id isn't updated if it differs from the repo. |
| 874 |
// It could be updated if the tree matches, but there's no extra logic for |
| 875 |
// that. |
| 876 |
let output = work_dir.run_jj(["op", "abandon", "@-"]); |
| 877 |
insta::assert_snapshot!(output, @" |
| 878 |
------- stderr ------- |
| 879 |
Abandoned 1 operations and reparented 1 descendant operations. |
| 880 |
Warning: The working copy operation 62f41230e57e is not updated because it differs from the repo 057d224b4c7c. |
| 881 |
[EOF] |
| 882 |
"); |
| 883 |
insta::assert_snapshot!(work_dir.run_jj(["debug", "local-working-copy", "--ignore-working-copy"]), @r#" |
| 884 |
Current operation: OperationId("62f41230e57ec67e2181e49cbc7c2e43c42aaddd5ea7f10c401ba6e0e92c20c22815994ff9993e0e0625561c7f9e0d9b2e9817cdcedb3d19dce5609be43a0859") |
| 885 |
Current tree: MergedTree { tree_ids: Resolved(TreeId("4b825dc642cb6eb9a060e54bf8d69288fbee4904")), labels: Unlabeled, .. } |
| 886 |
[EOF] |
| 887 |
"#); |
| 888 |
insta::assert_snapshot!(work_dir.run_jj(["op", "log", "-n1", "--ignore-working-copy"]), @" |
| 889 |
@ 1ac7ef4d119c [email protected] default@ 2001-02-03 04:05:10.000 +07:00 - 2001-02-03 04:05:10.000 +07:00 |
| 890 |
│ commit 4b087e94a5d14530c3953d617623d075a13294c8 |
| 891 |
│ args: jj commit -m 'commit 3' |
| 892 |
[EOF] |
| 893 |
"); |
| 894 |
} |
| 895 |
|
| 896 |
#[test] |
| 897 |
fn test_op_abandon_multiple_heads() { |
| 898 |
let test_env = TestEnvironment::default(); |
| 899 |
test_env.run_jj_in(".", ["git", "init", "repo"]).success(); |
| 900 |
let work_dir = test_env.work_dir("repo"); |
| 901 |
|
| 902 |
// Create 1 base operation + 2 operations to be diverged. |
| 903 |
work_dir.run_jj(["commit", "-m", "commit 1"]).success(); |
| 904 |
work_dir.run_jj(["commit", "-m", "commit 2"]).success(); |
| 905 |
work_dir.run_jj(["commit", "-m", "commit 3"]).success(); |
| 906 |
let output = work_dir |
| 907 |
.run_jj(["op", "log", "--no-graph", r#"-Tid.short() ++ "\n""#]) |
| 908 |
.success(); |
| 909 |
let [head_op_id, prev_op_id] = output.stdout.raw().lines().next_array().unwrap(); |
| 910 |
insta::assert_snapshot!(head_op_id, @"62f41230e57e"); |
| 911 |
insta::assert_snapshot!(prev_op_id, @"b004de1c8d83"); |
| 912 |
|
| 913 |
// Create 1 other concurrent operation. |
| 914 |
work_dir |
| 915 |
.run_jj(["commit", "--at-op=@--", "-m", "commit 4"]) |
| 916 |
.success(); |
| 917 |
|
| 918 |
// Can't resolve operation relative to @. |
| 919 |
let output = work_dir.run_jj(["op", "abandon", "@-"]); |
| 920 |
insta::assert_snapshot!(output, @r#" |
| 921 |
------- stderr ------- |
| 922 |
Error: The "@" expression resolved to more than one operation |
| 923 |
Hint: Try specifying one of the operations by ID: 62f41230e57e, ad3c8fd39dc6 |
| 924 |
[EOF] |
| 925 |
[exit status: 1] |
| 926 |
"#); |
| 927 |
let (_, other_head_op_id) = output.stderr.raw().trim_end().rsplit_once(", ").unwrap(); |
| 928 |
insta::assert_snapshot!(other_head_op_id, @"ad3c8fd39dc6"); |
| 929 |
assert_ne!(head_op_id, other_head_op_id); |
| 930 |
|
| 931 |
// Can't abandon one of the head operations. |
| 932 |
let output = work_dir.run_jj(["op", "abandon", head_op_id]); |
| 933 |
insta::assert_snapshot!(output, @" |
| 934 |
------- stderr ------- |
| 935 |
Error: Cannot abandon the current operation 62f41230e57e |
| 936 |
[EOF] |
| 937 |
[exit status: 1] |
| 938 |
"); |
| 939 |
|
| 940 |
// Can't abandon the other head operation. |
| 941 |
let output = work_dir.run_jj(["op", "abandon", other_head_op_id]); |
| 942 |
insta::assert_snapshot!(output, @" |
| 943 |
------- stderr ------- |
| 944 |
Error: Cannot abandon the current operation ad3c8fd39dc6 |
| 945 |
[EOF] |
| 946 |
[exit status: 1] |
| 947 |
"); |
| 948 |
|
| 949 |
// Can abandon the operation which is not an ancestor of the other head. |
| 950 |
// This would crash if we attempted to remap the unchanged op in the op |
| 951 |
// heads store. |
| 952 |
let output = work_dir.run_jj(["op", "abandon", prev_op_id]); |
| 953 |
insta::assert_snapshot!(output, @" |
| 954 |
------- stderr ------- |
| 955 |
Abandoned 1 operations and reparented 2 descendant operations. |
| 956 |
[EOF] |
| 957 |
"); |
| 958 |
|
| 959 |
let output = work_dir.run_jj(["op", "log"]); |
| 960 |
insta::assert_snapshot!(output, @" |
| 961 |
@ b584562d7baf [email protected] default@ 2001-02-03 04:05:17.000 +07:00 - 2001-02-03 04:05:17.000 +07:00 |
| 962 |
├─╮ reconcile divergent operations |
| 963 |
│ │ args: jj op log |
| 964 |
○ │ 057d224b4c7c [email protected] default@ 2001-02-03 04:05:10.000 +07:00 - 2001-02-03 04:05:10.000 +07:00 |
| 965 |
│ │ commit 4b087e94a5d14530c3953d617623d075a13294c8 |
| 966 |
│ │ args: jj commit -m 'commit 3' |
| 967 |
│ ○ ad3c8fd39dc6 [email protected] default@ 2001-02-03 04:05:12.000 +07:00 - 2001-02-03 04:05:12.000 +07:00 |
| 968 |
├─╯ commit 4e0592f3dd52e7a4998a97d9a1f354e2727a856b |
| 969 |
│ args: jj commit '--at-op=@--' -m 'commit 4' |
| 970 |
○ 5d7c2b4596e3 [email protected] default@ 2001-02-03 04:05:08.000 +07:00 - 2001-02-03 04:05:08.000 +07:00 |
| 971 |
│ commit e8849ae12c709f2321908879bc724fdb2ab8a781 |
| 972 |
│ args: jj commit -m 'commit 1' |
| 973 |
○ f63ee16f9553 [email protected] 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00 |
| 974 |
│ add workspace 'default' |
| 975 |
○ 000000000000 root() |
| 976 |
[EOF] |
| 977 |
------- stderr ------- |
| 978 |
Concurrent modification detected, resolving automatically. |
| 979 |
[EOF] |
| 980 |
"); |
| 981 |
} |
| 982 |
|
| 983 |
#[test] |
| 984 |
fn test_op_recover_from_bad_gc() -> TestResult { |
| 985 |
let test_env = TestEnvironment::default(); |
| 986 |
test_env |
| 987 |
.run_jj_in(".", ["git", "init", "repo", "--colocate"]) |
| 988 |
.success(); |
| 989 |
let work_dir = test_env.work_dir("repo"); |
| 990 |
let git_object_path = |hex: &str| { |
| 991 |
let (shard, file_name) = hex.split_at(2); |
| 992 |
let mut file_path = work_dir.root().to_owned(); |
| 993 |
file_path.extend([".git", "objects", shard, file_name]); |
| 994 |
file_path |
| 995 |
}; |
| 996 |
|
| 997 |
work_dir.run_jj(["describe", "-m1"]).success(); |
| 998 |
work_dir.run_jj(["describe", "-m2"]).success(); // victim |
| 999 |
work_dir.run_jj(["abandon"]).success(); // break predecessors chain |
| 1000 |
work_dir.run_jj(["new", "-m3"]).success(); |
| 1001 |
work_dir.run_jj(["describe", "-m4"]).success(); |
| 1002 |
|
| 1003 |
let output = work_dir |
| 1004 |
.run_jj(["op", "log", "--no-graph", r#"-Tid.short() ++ "\n""#]) |
| 1005 |
.success(); |
| 1006 |
let [head_op_id, _, _, bad_op_id] = output.stdout.raw().lines().next_array().unwrap(); |
| 1007 |
insta::assert_snapshot!(head_op_id, @"f578e4970373"); |
| 1008 |
insta::assert_snapshot!(bad_op_id, @"ed13d7dc6cbe"); |
| 1009 |
|
| 1010 |
// Corrupt the repo by removing hidden but reachable commit object. |
| 1011 |
let output = work_dir |
| 1012 |
.run_jj([ |
| 1013 |
"log", |
| 1014 |
"--at-op", |
| 1015 |
bad_op_id, |
| 1016 |
"--no-graph", |
| 1017 |
"-r@", |
| 1018 |
"-Tcommit_id", |
| 1019 |
]) |
| 1020 |
.success(); |
| 1021 |
let bad_commit_id = output.stdout.into_raw(); |
| 1022 |
insta::assert_snapshot!(bad_commit_id, @"4e123bae951c3216a145dbcd56d60522739d362e"); |
| 1023 |
std::fs::remove_file(git_object_path(&bad_commit_id))?; |
| 1024 |
|
| 1025 |
// Do concurrent modification to make the situation even worse. At this |
| 1026 |
// point, the index can be loaded, so this command succeeds. |
| 1027 |
work_dir |
| 1028 |
.run_jj(["--at-op=@-", "describe", "-m4.1"]) |
| 1029 |
.success(); |
| 1030 |
|
| 1031 |
let output = work_dir.run_jj(["--at-op", head_op_id, "debug", "reindex"]); |
| 1032 |
insta::assert_snapshot!(output.strip_stderr_last_line(), @" |
| 1033 |
------- stderr ------- |
| 1034 |
Internal error: Failed to index commits at operation ed13d7dc6cbe8904f205438fa5c7462eb06dc0b81f24d90a2d0976d1c08c72435e680e9e4aa445634b069e5641329efb97a6c73707cd8936d6129d1a0fb4da7c |
| 1035 |
Caused by: |
| 1036 |
1: Object 4e123bae951c3216a145dbcd56d60522739d362e of type commit not found |
| 1037 |
[EOF] |
| 1038 |
[exit status: 255] |
| 1039 |
"); |
| 1040 |
|
| 1041 |
// "op log" should still be usable. |
| 1042 |
let output = work_dir.run_jj(["op", "log", "--ignore-working-copy", "--at-op", head_op_id]); |
| 1043 |
insta::assert_snapshot!(output, @" |
| 1044 |
@ f578e4970373 [email protected] default@ 2001-02-03 04:05:12.000 +07:00 - 2001-02-03 04:05:12.000 +07:00 |
| 1045 |
│ describe commit a053bc8736064a739ab73f2c775a6ac2851bf1a3 |
| 1046 |
│ args: jj describe -m4 |
| 1047 |
○ de6bde308963 [email protected] default@ 2001-02-03 04:05:11.000 +07:00 - 2001-02-03 04:05:11.000 +07:00 |
| 1048 |
│ new empty commit |
| 1049 |
│ args: jj new -m3 |
| 1050 |
○ f4ad3f1e8317 [email protected] default@ 2001-02-03 04:05:10.000 +07:00 - 2001-02-03 04:05:10.000 +07:00 |
| 1051 |
│ abandon commit 4e123bae951c3216a145dbcd56d60522739d362e |
| 1052 |
│ args: jj abandon |
| 1053 |
○ ed13d7dc6cbe [email protected] default@ 2001-02-03 04:05:09.000 +07:00 - 2001-02-03 04:05:09.000 +07:00 |
| 1054 |
│ describe commit 884fe9b9c65602d724c7c0f2a238d5549efbe5e6 |
| 1055 |
│ args: jj describe -m2 |
| 1056 |
○ e77fac23262c [email protected] default@ 2001-02-03 04:05:08.000 +07:00 - 2001-02-03 04:05:08.000 +07:00 |
| 1057 |
│ describe commit e8849ae12c709f2321908879bc724fdb2ab8a781 |
| 1058 |
│ args: jj describe -m1 |
| 1059 |
○ f63ee16f9553 [email protected] 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00 |
| 1060 |
│ add workspace 'default' |
| 1061 |
○ 000000000000 root() |
| 1062 |
[EOF] |
| 1063 |
"); |
| 1064 |
|
| 1065 |
// "op abandon" should work. |
| 1066 |
let output = work_dir.run_jj(["op", "abandon", &format!("..{bad_op_id}")]); |
| 1067 |
insta::assert_snapshot!(output, @" |
| 1068 |
------- stderr ------- |
| 1069 |
Abandoned 3 operations and reparented 4 descendant operations. |
| 1070 |
[EOF] |
| 1071 |
"); |
| 1072 |
|
| 1073 |
// The repo should no longer be corrupt. |
| 1074 |
let output = work_dir.run_jj(["log"]); |
| 1075 |
insta::assert_snapshot!(output, @" |
| 1076 |
@ mzvwutvl/1 [email protected] 2001-02-03 08:05:12 29d07a2d (divergent) |
| 1077 |
│ (empty) 4 |
| 1078 |
│ ○ mzvwutvl/0 [email protected] 2001-02-03 08:05:15 bc027e2c (divergent) |
| 1079 |
├─╯ (empty) 4.1 |
| 1080 |
○ zsuskuln [email protected] 2001-02-03 08:05:10 c2934cfb |
| 1081 |
│ (empty) (no description set) |
| 1082 |
◆ zzzzzzzz root() 00000000 |
| 1083 |
[EOF] |
| 1084 |
------- stderr ------- |
| 1085 |
Concurrent modification detected, resolving automatically. |
| 1086 |
[EOF] |
| 1087 |
"); |
| 1088 |
Ok(()) |
| 1089 |
} |
| 1090 |
|
| 1091 |
#[test] |
| 1092 |
fn test_op_corrupted_operation_file() -> TestResult { |
| 1093 |
let test_env = TestEnvironment::default(); |
| 1094 |
test_env.run_jj_in(".", ["git", "init", "repo"]).success(); |
| 1095 |
let work_dir = test_env.work_dir("repo"); |
| 1096 |
let op_store_path = work_dir |
| 1097 |
.root() |
| 1098 |
.join(PathBuf::from_iter([".jj", "repo", "op_store"])); |
| 1099 |
|
| 1100 |
let op_id = work_dir.current_operation_id(); |
| 1101 |
insta::assert_snapshot!(op_id, @"f63ee16f95539ec5bda4a7178aa3ace2bf594719aa2cc3410cfc4d070cb31ae31225bef146eb2428baf760180976c936cd60891e7a9087e6836d3a315fe81030"); |
| 1102 |
|
| 1103 |
let op_file_path = op_store_path.join("operations").join(&op_id); |
| 1104 |
assert!(op_file_path.exists()); |
| 1105 |
|
| 1106 |
// truncated |
| 1107 |
std::fs::write(&op_file_path, b"")?; |
| 1108 |
let output = work_dir.run_jj(["op", "log"]); |
| 1109 |
insta::assert_snapshot!(output, @" |
| 1110 |
------- stderr ------- |
| 1111 |
Internal error: Failed to load an operation |
| 1112 |
Caused by: |
| 1113 |
1: Error when reading object f63ee16f95539ec5bda4a7178aa3ace2bf594719aa2cc3410cfc4d070cb31ae31225bef146eb2428baf760180976c936cd60891e7a9087e6836d3a315fe81030 of type operation |
| 1114 |
2: Invalid hash length (expected 64 bytes, got 0 bytes) |
| 1115 |
[EOF] |
| 1116 |
[exit status: 255] |
| 1117 |
"); |
| 1118 |
|
| 1119 |
// undecodable |
| 1120 |
std::fs::write(&op_file_path, b"\0")?; |
| 1121 |
let output = work_dir.run_jj(["op", "log"]); |
| 1122 |
insta::assert_snapshot!(output, @" |
| 1123 |
------- stderr ------- |
| 1124 |
Internal error: Failed to load an operation |
| 1125 |
Caused by: |
| 1126 |
1: Error when reading object f63ee16f95539ec5bda4a7178aa3ace2bf594719aa2cc3410cfc4d070cb31ae31225bef146eb2428baf760180976c936cd60891e7a9087e6836d3a315fe81030 of type operation |
| 1127 |
2: failed to decode Protobuf message: invalid tag value: 0 |
| 1128 |
[EOF] |
| 1129 |
[exit status: 255] |
| 1130 |
"); |
| 1131 |
Ok(()) |
| 1132 |
} |
| 1133 |
|
| 1134 |
#[test] |
| 1135 |
fn test_op_summary_diff_template() { |
| 1136 |
let test_env = TestEnvironment::default(); |
| 1137 |
test_env.run_jj_in(".", ["git", "init", "repo"]).success(); |
| 1138 |
let work_dir = test_env.work_dir("repo"); |
| 1139 |
|
| 1140 |
// Tests in color (easier to read with `less -R`) |
| 1141 |
work_dir |
| 1142 |
.run_jj(["new", "--no-edit", "-m=scratch"]) |
| 1143 |
.success(); |
| 1144 |
let output = work_dir.run_jj(["op", "revert", "--color=always"]); |
| 1145 |
insta::assert_snapshot!(output, @" |
| 1146 |
------- stderr ------- |
| 1147 |
Reverted operation: [38;5;4m159a7c4ed8f0[39m ([38;5;6m2001-02-03 08:05:08[39m) new empty commit |
| 1148 |
[EOF] |
| 1149 |
"); |
| 1150 |
let output = work_dir.run_jj([ |
| 1151 |
"op", |
| 1152 |
"diff", |
| 1153 |
"--from", |
| 1154 |
"0000000", |
| 1155 |
"--to", |
| 1156 |
"@", |
| 1157 |
"--color=always", |
| 1158 |
]); |
| 1159 |
insta::assert_snapshot!(output, @" |
| 1160 |
From operation: [38;5;4m000000000000[39m [38;5;2mroot()[39m |
| 1161 |
To operation: [38;5;4m061a71fe581b[39m ([38;5;6m2001-02-03 08:05:09[39m) revert operation 159a7c4ed8f06f25ac71abe76feb50bbd09df439685eea6c0cbec19e29e54a604af0eb57487b454451177ba0851e2eb22d88f918a44412a5c38230cb2d3b86b5 |
| 1162 |
|
| 1163 |
Changed commits: |
| 1164 |
○ [38;5;2m+[39m [1m[38;5;13mq[38;5;8mpvuntsm[39m [38;5;12me[38;5;8m8849ae1[39m [38;5;10m(empty)[39m [38;5;10m(no description set)[0m |
| 1165 |
|
| 1166 |
Changed working copy [38;5;2mdefault@[39m: |
| 1167 |
[38;5;2m+[39m [1m[38;5;13mq[38;5;8mpvuntsm[39m [38;5;12me[38;5;8m8849ae1[39m [38;5;10m(empty)[39m [38;5;10m(no description set)[0m |
| 1168 |
[38;5;1m-[39m (absent) |
| 1169 |
[EOF] |
| 1170 |
"); |
| 1171 |
|
| 1172 |
// Tests with templates |
| 1173 |
work_dir |
| 1174 |
.run_jj(["new", "--no-edit", "-m=scratch"]) |
| 1175 |
.success(); |
| 1176 |
let output = work_dir.run_jj(["op", "revert", "--color=debug"]); |
| 1177 |
insta::assert_snapshot!(output, @" |
| 1178 |
------- stderr ------- |
| 1179 |
Reverted operation: [38;5;4m<<operation id short::638404783baf>>[39m<<operation:: (>>[38;5;6m<<operation time end local format::2001-02-03 08:05:11>>[39m<<operation::) >><<operation description first_line::new empty commit>> |
| 1180 |
[EOF] |
| 1181 |
"); |
| 1182 |
let output = work_dir.run_jj([ |
| 1183 |
"op", |
| 1184 |
"diff", |
| 1185 |
"--from", |
| 1186 |
"0000000", |
| 1187 |
"--to", |
| 1188 |
"@", |
| 1189 |
"--color=debug", |
| 1190 |
]); |
| 1191 |
insta::assert_snapshot!(output, @" |
| 1192 |
From operation: [38;5;4m<<op_diff operation id short::000000000000>>[39m<<op_diff operation:: >>[38;5;2m<<op_diff operation root::root()>>[39m |
| 1193 |
To operation: [38;5;4m<<op_diff operation id short::5a6f74212543>>[39m<<op_diff operation:: (>>[38;5;6m<<op_diff operation time end local format::2001-02-03 08:05:12>>[39m<<op_diff operation::) >><<op_diff operation description first_line::revert operation 638404783baf5583f13d006a7844053ddeefdf4a3ca6de80dc34a30261990a884a3e517726bac64f3d154b95c286071558279cc76bf147a94ce6685a3e78d19f>> |
| 1194 |
|
| 1195 |
Changed commits: |
| 1196 |
○ [38;5;2m<<diff added::+>>[39m [1m[38;5;13m<<op_diff commit working_copy change_id shortest prefix::q>>[38;5;8m<<op_diff commit working_copy change_id shortest rest::pvuntsm>>[39m<<op_diff commit working_copy:: >>[38;5;12m<<op_diff commit working_copy commit_id shortest prefix::e>>[38;5;8m<<op_diff commit working_copy commit_id shortest rest::8849ae1>>[39m<<op_diff commit working_copy:: >>[38;5;10m<<op_diff commit working_copy empty::(empty)>>[39m<<op_diff commit working_copy:: >>[38;5;10m<<op_diff commit working_copy empty description placeholder::(no description set)>>[0m |
| 1197 |
|
| 1198 |
Changed working copy [38;5;2m<<working_copies::default@>>[39m: |
| 1199 |
[38;5;2m<<diff added::+>>[39m [1m[38;5;13m<<op_diff commit working_copy change_id shortest prefix::q>>[38;5;8m<<op_diff commit working_copy change_id shortest rest::pvuntsm>>[39m<<op_diff commit working_copy:: >>[38;5;12m<<op_diff commit working_copy commit_id shortest prefix::e>>[38;5;8m<<op_diff commit working_copy commit_id shortest rest::8849ae1>>[39m<<op_diff commit working_copy:: >>[38;5;10m<<op_diff commit working_copy empty::(empty)>>[39m<<op_diff commit working_copy:: >>[38;5;10m<<op_diff commit working_copy empty description placeholder::(no description set)>>[0m |
| 1200 |
[38;5;1m<<diff removed::->>[39m (absent) |
| 1201 |
[EOF] |
| 1202 |
"); |
| 1203 |
} |
| 1204 |
|
| 1205 |
#[test] |
| 1206 |
fn test_op_diff() { |
| 1207 |
let test_env = TestEnvironment::default(); |
| 1208 |
let git_repo_path = test_env.env_root().join("git-repo"); |
| 1209 |
let git_repo = init_bare_git_repo(&git_repo_path); |
| 1210 |
test_env.run_jj_in(".", ["git", "init", "repo"]).success(); |
| 1211 |
let work_dir = test_env.work_dir("repo"); |
| 1212 |
work_dir |
| 1213 |
.run_jj(["git", "remote", "add", "origin", "../git-repo"]) |
| 1214 |
.success(); |
| 1215 |
work_dir.run_jj(["git", "fetch"]).success(); |
| 1216 |
work_dir |
| 1217 |
.run_jj(["bookmark", "track", "bookmark-1"]) |
| 1218 |
.success(); |
| 1219 |
|
| 1220 |
// Overview of op log. |
| 1221 |
let output = work_dir.run_jj(["op", "log"]); |
| 1222 |
insta::assert_snapshot!(output, @" |
| 1223 |
@ c398dc66e5f4 [email protected] default@ 2001-02-03 04:05:10.000 +07:00 - 2001-02-03 04:05:10.000 +07:00 |
| 1224 |
│ track remote bookmark bookmark-1@origin |
| 1225 |
│ args: jj bookmark track bookmark-1 |
| 1226 |
○ 47cfe27aee78 [email protected] default@ 2001-02-03 04:05:09.000 +07:00 - 2001-02-03 04:05:09.000 +07:00 |
| 1227 |
│ fetch from git remote(s) origin |
| 1228 |
│ args: jj git fetch |
| 1229 |
○ 0dcdecd46a3d [email protected] default@ 2001-02-03 04:05:08.000 +07:00 - 2001-02-03 04:05:08.000 +07:00 |
| 1230 |
│ add git remote origin |
| 1231 |
│ args: jj git remote add origin ../git-repo |
| 1232 |
○ f63ee16f9553 [email protected] 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00 |
| 1233 |
│ add workspace 'default' |
| 1234 |
○ 000000000000 root() |
| 1235 |
[EOF] |
| 1236 |
"); |
| 1237 |
|
| 1238 |
// Diff between the same operation should be empty. |
| 1239 |
let output = work_dir.run_jj(["op", "diff", "--from", "0000000", "--to", "0000000"]); |
| 1240 |
insta::assert_snapshot!(output, @" |
| 1241 |
From operation: 000000000000 root() |
| 1242 |
To operation: 000000000000 root() |
| 1243 |
[EOF] |
| 1244 |
"); |
| 1245 |
let output = work_dir.run_jj(["op", "diff", "--from", "@", "--to", "@"]); |
| 1246 |
insta::assert_snapshot!(output, @" |
| 1247 |
From operation: c398dc66e5f4 (2001-02-03 08:05:10) track remote bookmark bookmark-1@origin |
| 1248 |
To operation: c398dc66e5f4 (2001-02-03 08:05:10) track remote bookmark bookmark-1@origin |
| 1249 |
[EOF] |
| 1250 |
"); |
| 1251 |
|
| 1252 |
// Diff from parent operation to latest operation. |
| 1253 |
// `jj op diff --op @` should behave identically to `jj op diff --from |
| 1254 |
// @- --to @` (if `@` is not a merge commit). |
| 1255 |
let output = work_dir.run_jj(["op", "diff", "--from", "@-", "--to", "@"]); |
| 1256 |
insta::assert_snapshot!(output, @" |
| 1257 |
From operation: 47cfe27aee78 (2001-02-03 08:05:09) fetch from git remote(s) origin |
| 1258 |
To operation: c398dc66e5f4 (2001-02-03 08:05:10) track remote bookmark bookmark-1@origin |
| 1259 |
|
| 1260 |
Changed local bookmarks: |
| 1261 |
bookmark-1: |
| 1262 |
+ pukowqtp 0cb7e07e bookmark-1 | Commit 1 |
| 1263 |
- (absent) |
| 1264 |
|
| 1265 |
Changed remote bookmarks: |
| 1266 |
bookmark-1@origin: |
| 1267 |
+ tracked pukowqtp 0cb7e07e bookmark-1 | Commit 1 |
| 1268 |
- untracked pukowqtp 0cb7e07e bookmark-1 | Commit 1 |
| 1269 |
[EOF] |
| 1270 |
"); |
| 1271 |
let output_without_from_to = work_dir.run_jj(["op", "diff"]); |
| 1272 |
assert_eq!(output, output_without_from_to); |
| 1273 |
|
| 1274 |
// Diff from root operation to latest operation |
| 1275 |
let output = work_dir.run_jj(["op", "diff", "--from", "0000000"]); |
| 1276 |
insta::assert_snapshot!(output, @" |
| 1277 |
From operation: 000000000000 root() |
| 1278 |
To operation: c398dc66e5f4 (2001-02-03 08:05:10) track remote bookmark bookmark-1@origin |
| 1279 |
|
| 1280 |
Changed commits: |
| 1281 |
○ + skovwzlu 854c38b8 Commit 4 |
| 1282 |
○ + rnnslrkn 4ff62539 bookmark-2@origin | Commit 2 |
| 1283 |
○ + rnnkyono 11671e4c bookmark-3@origin | Commit 3 |
| 1284 |
○ + pukowqtp 0cb7e07e bookmark-1 | Commit 1 |
| 1285 |
○ + qpvuntsm e8849ae1 (empty) (no description set) |
| 1286 |
|
| 1287 |
Changed working copy default@: |
| 1288 |
+ qpvuntsm e8849ae1 (empty) (no description set) |
| 1289 |
- (absent) |
| 1290 |
|
| 1291 |
Changed local bookmarks: |
| 1292 |
bookmark-1: |
| 1293 |
+ pukowqtp 0cb7e07e bookmark-1 | Commit 1 |
| 1294 |
- (absent) |
| 1295 |
|
| 1296 |
Changed local tags: |
| 1297 |
tag-1: |
| 1298 |
+ skovwzlu 854c38b8 Commit 4 |
| 1299 |
- (absent) |
| 1300 |
|
| 1301 |
Changed remote bookmarks: |
| 1302 |
bookmark-1@origin: |
| 1303 |
+ tracked pukowqtp 0cb7e07e bookmark-1 | Commit 1 |
| 1304 |
- untracked (absent) |
| 1305 |
bookmark-2@origin: |
| 1306 |
+ untracked rnnslrkn 4ff62539 bookmark-2@origin | Commit 2 |
| 1307 |
- untracked (absent) |
| 1308 |
bookmark-3@origin: |
| 1309 |
+ untracked rnnkyono 11671e4c bookmark-3@origin | Commit 3 |
| 1310 |
- untracked (absent) |
| 1311 |
|
| 1312 |
Changed remote tags: |
| 1313 |
tag-1@origin: |
| 1314 |
+ tracked skovwzlu 854c38b8 Commit 4 |
| 1315 |
- untracked (absent) |
| 1316 |
[EOF] |
| 1317 |
"); |
| 1318 |
|
| 1319 |
// Diff from latest operation to root operation |
| 1320 |
let output = work_dir.run_jj(["op", "diff", "--to", "0000000"]); |
| 1321 |
insta::assert_snapshot!(output, @" |
| 1322 |
From operation: c398dc66e5f4 (2001-02-03 08:05:10) track remote bookmark bookmark-1@origin |
| 1323 |
To operation: 000000000000 root() |
| 1324 |
|
| 1325 |
Changed commits: |
| 1326 |
○ - skovwzlu/0 854c38b8 (hidden) Commit 4 |
| 1327 |
○ - rnnslrkn/0 4ff62539 (hidden) Commit 2 |
| 1328 |
○ - rnnkyono/0 11671e4c (hidden) Commit 3 |
| 1329 |
○ - pukowqtp/0 0cb7e07e (hidden) Commit 1 |
| 1330 |
○ - qpvuntsm/0 e8849ae1 (hidden) (empty) (no description set) |
| 1331 |
|
| 1332 |
Changed working copy default@: |
| 1333 |
+ (absent) |
| 1334 |
- qpvuntsm/0 e8849ae1 (hidden) (empty) (no description set) |
| 1335 |
|
| 1336 |
Changed local bookmarks: |
| 1337 |
bookmark-1: |
| 1338 |
+ (absent) |
| 1339 |
- pukowqtp/0 0cb7e07e (hidden) Commit 1 |
| 1340 |
|
| 1341 |
Changed local tags: |
| 1342 |
tag-1: |
| 1343 |
+ (absent) |
| 1344 |
- skovwzlu/0 854c38b8 (hidden) Commit 4 |
| 1345 |
|
| 1346 |
Changed remote bookmarks: |
| 1347 |
bookmark-1@origin: |
| 1348 |
+ untracked (absent) |
| 1349 |
- tracked pukowqtp/0 0cb7e07e (hidden) Commit 1 |
| 1350 |
bookmark-2@origin: |
| 1351 |
+ untracked (absent) |
| 1352 |
- untracked rnnslrkn/0 4ff62539 (hidden) Commit 2 |
| 1353 |
bookmark-3@origin: |
| 1354 |
+ untracked (absent) |
| 1355 |
- untracked rnnkyono/0 11671e4c (hidden) Commit 3 |
| 1356 |
|
| 1357 |
Changed remote tags: |
| 1358 |
tag-1@origin: |
| 1359 |
+ untracked (absent) |
| 1360 |
- tracked skovwzlu/0 854c38b8 (hidden) Commit 4 |
| 1361 |
[EOF] |
| 1362 |
"); |
| 1363 |
let output = work_dir.run_jj(["log"]); |
| 1364 |
insta::assert_snapshot!(output, @" |
| 1365 |
@ qpvuntsm [email protected] 2001-02-03 08:05:07 e8849ae1 |
| 1366 |
│ (empty) (no description set) |
| 1367 |
│ ○ pukowqtp [email protected] 1970-01-01 11:00:00 bookmark-1 0cb7e07e |
| 1368 |
├─╯ Commit 1 |
| 1369 |
◆ zzzzzzzz root() 00000000 |
| 1370 |
[EOF] |
| 1371 |
"); |
| 1372 |
|
| 1373 |
// Create a conflicted bookmark using a concurrent operation. |
| 1374 |
// Conflict with a move so the target references change (not just adds) |
| 1375 |
work_dir |
| 1376 |
.run_jj([ |
| 1377 |
"bookmark", |
| 1378 |
"move", |
| 1379 |
"bookmark-1", |
| 1380 |
"--to", |
| 1381 |
"@", |
| 1382 |
"--allow-backwards", |
| 1383 |
]) |
| 1384 |
.success(); |
| 1385 |
work_dir |
| 1386 |
.run_jj([ |
| 1387 |
"bookmark", |
| 1388 |
"set", |
| 1389 |
"bookmark-1", |
| 1390 |
"-r", |
| 1391 |
"bookmark-2@origin", |
| 1392 |
"--allow-backwards", |
| 1393 |
"--at-op", |
| 1394 |
"@-", |
| 1395 |
]) |
| 1396 |
.success(); |
| 1397 |
let output = work_dir.run_jj(["log"]); |
| 1398 |
insta::assert_snapshot!(output, @" |
| 1399 |
@ qpvuntsm [email protected] 2001-02-03 08:05:07 bookmark-1?? e8849ae1 |
| 1400 |
│ (empty) (no description set) |
| 1401 |
│ ○ pukowqtp [email protected] 1970-01-01 11:00:00 bookmark-1@origin 0cb7e07e |
| 1402 |
├─╯ Commit 1 |
| 1403 |
◆ zzzzzzzz root() 00000000 |
| 1404 |
[EOF] |
| 1405 |
------- stderr ------- |
| 1406 |
Concurrent modification detected, resolving automatically. |
| 1407 |
[EOF] |
| 1408 |
"); |
| 1409 |
let output = work_dir.run_jj(["op", "log"]); |
| 1410 |
insta::assert_snapshot!(output, @" |
| 1411 |
@ 3cf9a7f329ef [email protected] default@ 2001-02-03 04:05:21.000 +07:00 - 2001-02-03 04:05:21.000 +07:00 |
| 1412 |
├─╮ reconcile divergent operations |
| 1413 |
│ │ args: jj log |
| 1414 |
○ │ 68d99f04e273 [email protected] default@ 2001-02-03 04:05:19.000 +07:00 - 2001-02-03 04:05:19.000 +07:00 |
| 1415 |
│ │ point bookmark bookmark-1 to commit e8849ae12c709f2321908879bc724fdb2ab8a781 |
| 1416 |
│ │ args: jj bookmark move bookmark-1 --to @ --allow-backwards |
| 1417 |
│ ○ 89bdf3a23553 [email protected] default@ 2001-02-03 04:05:20.000 +07:00 - 2001-02-03 04:05:20.000 +07:00 |
| 1418 |
├─╯ point bookmark bookmark-1 to commit 4ff6253913375c6ebdddd8423c11df3b3f17e331 |
| 1419 |
│ args: jj bookmark set bookmark-1 -r bookmark-2@origin --allow-backwards --at-op @- |
| 1420 |
○ c398dc66e5f4 [email protected] default@ 2001-02-03 04:05:10.000 +07:00 - 2001-02-03 04:05:10.000 +07:00 |
| 1421 |
│ track remote bookmark bookmark-1@origin |
| 1422 |
│ args: jj bookmark track bookmark-1 |
| 1423 |
○ 47cfe27aee78 [email protected] default@ 2001-02-03 04:05:09.000 +07:00 - 2001-02-03 04:05:09.000 +07:00 |
| 1424 |
│ fetch from git remote(s) origin |
| 1425 |
│ args: jj git fetch |
| 1426 |
○ 0dcdecd46a3d [email protected] default@ 2001-02-03 04:05:08.000 +07:00 - 2001-02-03 04:05:08.000 +07:00 |
| 1427 |
│ add git remote origin |
| 1428 |
│ args: jj git remote add origin ../git-repo |
| 1429 |
○ f63ee16f9553 [email protected] 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00 |
| 1430 |
│ add workspace 'default' |
| 1431 |
○ 000000000000 root() |
| 1432 |
[EOF] |
| 1433 |
"); |
| 1434 |
let op_log_lines = output.stdout.raw().lines().collect_vec(); |
| 1435 |
let op_id = op_log_lines[0].split(' ').nth(4).unwrap(); |
| 1436 |
let first_parent_id = op_log_lines[3].split(' ').nth(3).unwrap(); |
| 1437 |
let second_parent_id = op_log_lines[6].split(' ').nth(3).unwrap(); |
| 1438 |
|
| 1439 |
// Diff between the first parent of the merge operation and the merge operation. |
| 1440 |
let output = work_dir.run_jj(["op", "diff", "--from", first_parent_id, "--to", op_id]); |
| 1441 |
insta::assert_snapshot!(output, @" |
| 1442 |
From operation: 68d99f04e273 (2001-02-03 08:05:19) point bookmark bookmark-1 to commit e8849ae12c709f2321908879bc724fdb2ab8a781 |
| 1443 |
To operation: 3cf9a7f329ef (2001-02-03 08:05:21) reconcile divergent operations |
| 1444 |
|
| 1445 |
Changed local bookmarks: |
| 1446 |
bookmark-1: |
| 1447 |
+ (added) qpvuntsm e8849ae1 bookmark-1?? | (empty) (no description set) |
| 1448 |
+ (added) rnnslrkn 4ff62539 bookmark-1?? bookmark-2@origin | Commit 2 |
| 1449 |
+ (removed) pukowqtp 0cb7e07e bookmark-1@origin | Commit 1 |
| 1450 |
- qpvuntsm e8849ae1 bookmark-1?? | (empty) (no description set) |
| 1451 |
[EOF] |
| 1452 |
"); |
| 1453 |
|
| 1454 |
// Diff between the second parent of the merge operation and the merge |
| 1455 |
// operation. |
| 1456 |
let output = work_dir.run_jj(["op", "diff", "--from", second_parent_id, "--to", op_id]); |
| 1457 |
insta::assert_snapshot!(output, @" |
| 1458 |
From operation: 89bdf3a23553 (2001-02-03 08:05:20) point bookmark bookmark-1 to commit 4ff6253913375c6ebdddd8423c11df3b3f17e331 |
| 1459 |
To operation: 3cf9a7f329ef (2001-02-03 08:05:21) reconcile divergent operations |
| 1460 |
|
| 1461 |
Changed local bookmarks: |
| 1462 |
bookmark-1: |
| 1463 |
+ (added) qpvuntsm e8849ae1 bookmark-1?? | (empty) (no description set) |
| 1464 |
+ (added) rnnslrkn 4ff62539 bookmark-1?? bookmark-2@origin | Commit 2 |
| 1465 |
+ (removed) pukowqtp 0cb7e07e bookmark-1@origin | Commit 1 |
| 1466 |
- rnnslrkn 4ff62539 bookmark-1?? bookmark-2@origin | Commit 2 |
| 1467 |
[EOF] |
| 1468 |
"); |
| 1469 |
|
| 1470 |
// Test fetching from git remote. |
| 1471 |
modify_git_repo(git_repo); |
| 1472 |
let output = work_dir.run_jj(["git", "fetch"]); |
| 1473 |
insta::assert_snapshot!(output, @" |
| 1474 |
------- stderr ------- |
| 1475 |
bookmark: bookmark-1@origin [updated] tracked |
| 1476 |
bookmark: bookmark-2@origin [updated] untracked |
| 1477 |
bookmark: bookmark-3@origin [deleted] untracked |
| 1478 |
Abandoned 1 commits that are no longer reachable: |
| 1479 |
rnnkyono 11671e4c Commit 3 |
| 1480 |
[EOF] |
| 1481 |
"); |
| 1482 |
let output = work_dir.run_jj(["op", "diff"]); |
| 1483 |
insta::assert_snapshot!(output, @" |
| 1484 |
From operation: 3cf9a7f329ef (2001-02-03 08:05:21) reconcile divergent operations |
| 1485 |
To operation: b43ad427fa47 (2001-02-03 08:05:25) fetch from git remote(s) origin |
| 1486 |
|
| 1487 |
Changed commits: |
| 1488 |
○ + kulxwnxm e1a239a5 bookmark-2@origin | Commit 5 |
| 1489 |
○ + zkmtkqvo 0dee6313 bookmark-1?? bookmark-1@origin | Commit 4 |
| 1490 |
○ - rnnkyono/0 11671e4c (hidden) Commit 3 |
| 1491 |
|
| 1492 |
Changed local bookmarks: |
| 1493 |
bookmark-1: |
| 1494 |
+ (added) qpvuntsm e8849ae1 bookmark-1?? | (empty) (no description set) |
| 1495 |
+ (added) rnnslrkn 4ff62539 bookmark-1?? | Commit 2 |
| 1496 |
+ (added) zkmtkqvo 0dee6313 bookmark-1?? bookmark-1@origin | Commit 4 |
| 1497 |
+ (removed) pukowqtp 0cb7e07e Commit 1 |
| 1498 |
+ (removed) pukowqtp 0cb7e07e Commit 1 |
| 1499 |
- (added) qpvuntsm e8849ae1 bookmark-1?? | (empty) (no description set) |
| 1500 |
- (added) rnnslrkn 4ff62539 bookmark-1?? | Commit 2 |
| 1501 |
- (removed) pukowqtp 0cb7e07e Commit 1 |
| 1502 |
|
| 1503 |
Changed remote bookmarks: |
| 1504 |
bookmark-1@origin: |
| 1505 |
+ tracked zkmtkqvo 0dee6313 bookmark-1?? bookmark-1@origin | Commit 4 |
| 1506 |
- tracked pukowqtp 0cb7e07e Commit 1 |
| 1507 |
bookmark-2@origin: |
| 1508 |
+ untracked kulxwnxm e1a239a5 bookmark-2@origin | Commit 5 |
| 1509 |
- untracked rnnslrkn 4ff62539 bookmark-1?? | Commit 2 |
| 1510 |
bookmark-3@origin: |
| 1511 |
+ untracked (absent) |
| 1512 |
- untracked rnnkyono/0 11671e4c (hidden) Commit 3 |
| 1513 |
[EOF] |
| 1514 |
"); |
| 1515 |
|
| 1516 |
// Test creation of bookmark. |
| 1517 |
let output = work_dir.run_jj([ |
| 1518 |
"bookmark", |
| 1519 |
"create", |
| 1520 |
"bookmark-2", |
| 1521 |
"-r", |
| 1522 |
"bookmark-2@origin", |
| 1523 |
]); |
| 1524 |
insta::assert_snapshot!(output, @" |
| 1525 |
------- stderr ------- |
| 1526 |
Created 1 bookmarks pointing to kulxwnxm e1a239a5 bookmark-2 bookmark-2@origin | Commit 5 |
| 1527 |
[EOF] |
| 1528 |
"); |
| 1529 |
let output = work_dir.run_jj(["op", "diff"]); |
| 1530 |
insta::assert_snapshot!(output, @" |
| 1531 |
From operation: b43ad427fa47 (2001-02-03 08:05:25) fetch from git remote(s) origin |
| 1532 |
To operation: 3ea62256d9f4 (2001-02-03 08:05:27) create bookmark bookmark-2 pointing to commit e1a239a57eb15cefc5910198befbbbe2b43c47af |
| 1533 |
|
| 1534 |
Changed local bookmarks: |
| 1535 |
bookmark-2: |
| 1536 |
+ kulxwnxm e1a239a5 bookmark-2 bookmark-2@origin | Commit 5 |
| 1537 |
- (absent) |
| 1538 |
[EOF] |
| 1539 |
"); |
| 1540 |
|
| 1541 |
// Test tracking of bookmark. |
| 1542 |
let output = work_dir.run_jj(["bookmark", "track", "bookmark-2"]); |
| 1543 |
insta::assert_snapshot!(output, @" |
| 1544 |
------- stderr ------- |
| 1545 |
Started tracking 1 remote bookmarks. |
| 1546 |
[EOF] |
| 1547 |
"); |
| 1548 |
let output = work_dir.run_jj(["op", "diff"]); |
| 1549 |
insta::assert_snapshot!(output, @" |
| 1550 |
From operation: 3ea62256d9f4 (2001-02-03 08:05:27) create bookmark bookmark-2 pointing to commit e1a239a57eb15cefc5910198befbbbe2b43c47af |
| 1551 |
To operation: ef77f2e3c512 (2001-02-03 08:05:29) track remote bookmark bookmark-2@origin |
| 1552 |
|
| 1553 |
Changed remote bookmarks: |
| 1554 |
bookmark-2@origin: |
| 1555 |
+ tracked kulxwnxm e1a239a5 bookmark-2 | Commit 5 |
| 1556 |
- untracked kulxwnxm e1a239a5 bookmark-2 | Commit 5 |
| 1557 |
[EOF] |
| 1558 |
"); |
| 1559 |
|
| 1560 |
// Test tracking of bookmark. |
| 1561 |
let output = work_dir.run_jj(["bookmark", "track", "bookmark-2"]); |
| 1562 |
insta::assert_snapshot!(output, @" |
| 1563 |
------- stderr ------- |
| 1564 |
Warning: Remote bookmark already tracked: bookmark-2@origin |
| 1565 |
Nothing changed. |
| 1566 |
[EOF] |
| 1567 |
"); |
| 1568 |
let output = work_dir.run_jj(["op", "diff"]); |
| 1569 |
insta::assert_snapshot!(output, @" |
| 1570 |
From operation: 3ea62256d9f4 (2001-02-03 08:05:27) create bookmark bookmark-2 pointing to commit e1a239a57eb15cefc5910198befbbbe2b43c47af |
| 1571 |
To operation: ef77f2e3c512 (2001-02-03 08:05:29) track remote bookmark bookmark-2@origin |
| 1572 |
|
| 1573 |
Changed remote bookmarks: |
| 1574 |
bookmark-2@origin: |
| 1575 |
+ tracked kulxwnxm e1a239a5 bookmark-2 | Commit 5 |
| 1576 |
- untracked kulxwnxm e1a239a5 bookmark-2 | Commit 5 |
| 1577 |
[EOF] |
| 1578 |
"); |
| 1579 |
|
| 1580 |
// Test creation of new commit. |
| 1581 |
let output = work_dir.run_jj(["new", "bookmark-1@origin", "-m", "new commit"]); |
| 1582 |
insta::assert_snapshot!(output, @" |
| 1583 |
------- stderr ------- |
| 1584 |
Working copy (@) now at: qmkrwlvp 96f3a57c (empty) new commit |
| 1585 |
Parent commit (@-) : zkmtkqvo 0dee6313 bookmark-1?? bookmark-1@origin | Commit 4 |
| 1586 |
Added 2 files, modified 0 files, removed 0 files |
| 1587 |
[EOF] |
| 1588 |
"); |
| 1589 |
let output = work_dir.run_jj(["op", "diff"]); |
| 1590 |
insta::assert_snapshot!(output, @" |
| 1591 |
From operation: ef77f2e3c512 (2001-02-03 08:05:29) track remote bookmark bookmark-2@origin |
| 1592 |
To operation: 29f574cb7ec8 (2001-02-03 08:05:33) new empty commit |
| 1593 |
|
| 1594 |
Changed commits: |
| 1595 |
○ + qmkrwlvp 96f3a57c (empty) new commit |
| 1596 |
|
| 1597 |
Changed working copy default@: |
| 1598 |
+ qmkrwlvp 96f3a57c (empty) new commit |
| 1599 |
- qpvuntsm e8849ae1 bookmark-1?? | (empty) (no description set) |
| 1600 |
[EOF] |
| 1601 |
"); |
| 1602 |
|
| 1603 |
// Test updating of local bookmark. |
| 1604 |
let output = work_dir.run_jj(["bookmark", "set", "bookmark-1", "-r", "@"]); |
| 1605 |
insta::assert_snapshot!(output, @" |
| 1606 |
------- stderr ------- |
| 1607 |
Moved 1 bookmarks to qmkrwlvp 96f3a57c bookmark-1* | (empty) new commit |
| 1608 |
[EOF] |
| 1609 |
"); |
| 1610 |
let output = work_dir.run_jj(["op", "diff"]); |
| 1611 |
insta::assert_snapshot!(output, @" |
| 1612 |
From operation: 29f574cb7ec8 (2001-02-03 08:05:33) new empty commit |
| 1613 |
To operation: 01a4d5f22fb6 (2001-02-03 08:05:35) point bookmark bookmark-1 to commit 96f3a57c9a4a4ae7bb45d1eafe32fe3b6e33f458 |
| 1614 |
|
| 1615 |
Changed local bookmarks: |
| 1616 |
bookmark-1: |
| 1617 |
+ qmkrwlvp 96f3a57c bookmark-1* | (empty) new commit |
| 1618 |
- (added) qpvuntsm e8849ae1 (empty) (no description set) |
| 1619 |
- (added) rnnslrkn 4ff62539 Commit 2 |
| 1620 |
- (added) zkmtkqvo 0dee6313 bookmark-1@origin | Commit 4 |
| 1621 |
- (removed) pukowqtp 0cb7e07e Commit 1 |
| 1622 |
- (removed) pukowqtp 0cb7e07e Commit 1 |
| 1623 |
[EOF] |
| 1624 |
"); |
| 1625 |
|
| 1626 |
// Test deletion of local bookmark. |
| 1627 |
let output = work_dir.run_jj(["bookmark", "delete", "bookmark-2"]); |
| 1628 |
insta::assert_snapshot!(output, @" |
| 1629 |
------- stderr ------- |
| 1630 |
Deleted 1 bookmarks. |
| 1631 |
[EOF] |
| 1632 |
"); |
| 1633 |
let output = work_dir.run_jj(["op", "diff"]); |
| 1634 |
insta::assert_snapshot!(output, @" |
| 1635 |
From operation: 01a4d5f22fb6 (2001-02-03 08:05:35) point bookmark bookmark-1 to commit 96f3a57c9a4a4ae7bb45d1eafe32fe3b6e33f458 |
| 1636 |
To operation: 127e7e5ef5ff (2001-02-03 08:05:37) delete bookmark bookmark-2 |
| 1637 |
|
| 1638 |
Changed local bookmarks: |
| 1639 |
bookmark-2: |
| 1640 |
+ (absent) |
| 1641 |
- kulxwnxm e1a239a5 bookmark-2@origin | Commit 5 |
| 1642 |
[EOF] |
| 1643 |
"); |
| 1644 |
|
| 1645 |
// Test pushing to Git remote. |
| 1646 |
let output = work_dir.run_jj(["git", "push", "--tracked", "--deleted"]); |
| 1647 |
insta::assert_snapshot!(output, @" |
| 1648 |
------- stderr ------- |
| 1649 |
Changes to push to origin: |
| 1650 |
bookmark: bookmark-1 [move forward from 0dee631320b1 to 96f3a57c9a4a] |
| 1651 |
bookmark: bookmark-2 [delete from e1a239a57eb1] |
| 1652 |
[EOF] |
| 1653 |
"); |
| 1654 |
let output = work_dir.run_jj(["op", "diff"]); |
| 1655 |
insta::assert_snapshot!(output, @" |
| 1656 |
From operation: 127e7e5ef5ff (2001-02-03 08:05:37) delete bookmark bookmark-2 |
| 1657 |
To operation: fa7799465b41 (2001-02-03 08:05:39) push all tracked bookmarks/tags to git remote origin |
| 1658 |
|
| 1659 |
Changed remote bookmarks: |
| 1660 |
bookmark-1@origin: |
| 1661 |
+ tracked qmkrwlvp 96f3a57c bookmark-1 | (empty) new commit |
| 1662 |
- tracked zkmtkqvo 0dee6313 Commit 4 |
| 1663 |
bookmark-2@origin: |
| 1664 |
+ untracked (absent) |
| 1665 |
- tracked kulxwnxm e1a239a5 Commit 5 |
| 1666 |
[EOF] |
| 1667 |
"); |
| 1668 |
|
| 1669 |
// Test creation of tag. |
| 1670 |
work_dir.run_jj(["new"]).success(); |
| 1671 |
work_dir.run_jj(["tag", "set", "-r@-", "tag1"]).success(); |
| 1672 |
let output = work_dir.run_jj(["op", "diff"]); |
| 1673 |
insta::assert_snapshot!(output, @" |
| 1674 |
From operation: b2360e223641 (2001-02-03 08:05:41) new empty commit |
| 1675 |
To operation: b499a1375446 (2001-02-03 08:05:42) set tag tag1 to commit 96f3a57c9a4a4ae7bb45d1eafe32fe3b6e33f458 |
| 1676 |
|
| 1677 |
Changed local tags: |
| 1678 |
tag1: |
| 1679 |
+ qmkrwlvp 96f3a57c bookmark-1 | (empty) new commit |
| 1680 |
- (absent) |
| 1681 |
[EOF] |
| 1682 |
"); |
| 1683 |
|
| 1684 |
// Test tag movement. |
| 1685 |
work_dir |
| 1686 |
.run_jj(["tag", "set", "tag1", "-r=@--", "--allow-move"]) |
| 1687 |
.success(); |
| 1688 |
let output = work_dir.run_jj(["op", "diff"]); |
| 1689 |
insta::assert_snapshot!(output, @" |
| 1690 |
From operation: b499a1375446 (2001-02-03 08:05:42) set tag tag1 to commit 96f3a57c9a4a4ae7bb45d1eafe32fe3b6e33f458 |
| 1691 |
To operation: 151ccd561835 (2001-02-03 08:05:44) set tag tag1 to commit 0dee631320b13c6a6542c80bced33b9dd29f6bf0 |
| 1692 |
|
| 1693 |
Changed local tags: |
| 1694 |
tag1: |
| 1695 |
+ zkmtkqvo 0dee6313 Commit 4 |
| 1696 |
- qmkrwlvp 96f3a57c bookmark-1 | (empty) new commit |
| 1697 |
[EOF] |
| 1698 |
"); |
| 1699 |
|
| 1700 |
// Test tag deletion. |
| 1701 |
work_dir.run_jj(["tag", "delete", "tag1"]).success(); |
| 1702 |
let output = work_dir.run_jj(["op", "diff"]); |
| 1703 |
insta::assert_snapshot!(output, @" |
| 1704 |
From operation: 151ccd561835 (2001-02-03 08:05:44) set tag tag1 to commit 0dee631320b13c6a6542c80bced33b9dd29f6bf0 |
| 1705 |
To operation: a35f3152e574 (2001-02-03 08:05:46) delete tag tag1 |
| 1706 |
|
| 1707 |
Changed local tags: |
| 1708 |
tag1: |
| 1709 |
+ (absent) |
| 1710 |
- zkmtkqvo 0dee6313 Commit 4 |
| 1711 |
[EOF] |
| 1712 |
"); |
| 1713 |
} |
| 1714 |
|
| 1715 |
#[test] |
| 1716 |
fn test_op_diff_patch() { |
| 1717 |
let test_env = TestEnvironment::default(); |
| 1718 |
test_env.run_jj_in(".", ["git", "init", "repo"]).success(); |
| 1719 |
let work_dir = test_env.work_dir("repo"); |
| 1720 |
|
| 1721 |
// Update working copy with a single file and create new commit. |
| 1722 |
work_dir.write_file("file", "a\n"); |
| 1723 |
let output = work_dir.run_jj(["new"]); |
| 1724 |
insta::assert_snapshot!(output, @" |
| 1725 |
------- stderr ------- |
| 1726 |
Working copy (@) now at: rlvkpnrz c1c924b8 (empty) (no description set) |
| 1727 |
Parent commit (@-) : qpvuntsm 6b57e33c (no description set) |
| 1728 |
[EOF] |
| 1729 |
"); |
| 1730 |
let output = work_dir.run_jj(["op", "diff", "--op", "@-", "-p", "--git"]); |
| 1731 |
insta::assert_snapshot!(output, @" |
| 1732 |
From operation: f63ee16f9553 (2001-02-03 08:05:07) add workspace 'default' |
| 1733 |
To operation: 494872ff8b1e (2001-02-03 08:05:08) snapshot working copy |
| 1734 |
|
| 1735 |
Changed commits: |
| 1736 |
○ + qpvuntsm 6b57e33c (no description set) |
| 1737 |
- qpvuntsm/1 e8849ae1 (hidden) (empty) (no description set) |
| 1738 |
diff --git a/file b/file |
| 1739 |
new file mode 100644 |
| 1740 |
index 0000000000..7898192261 |
| 1741 |
--- /dev/null |
| 1742 |
+++ b/file |
| 1743 |
@@ -0,0 +1,1 @@ |
| 1744 |
+a |
| 1745 |
|
| 1746 |
Changed working copy default@: |
| 1747 |
+ qpvuntsm 6b57e33c (no description set) |
| 1748 |
- qpvuntsm/1 e8849ae1 (hidden) (empty) (no description set) |
| 1749 |
[EOF] |
| 1750 |
"); |
| 1751 |
let output = work_dir.run_jj(["op", "diff", "--op", "@", "-p", "--git"]); |
| 1752 |
insta::assert_snapshot!(output, @" |
| 1753 |
From operation: 494872ff8b1e (2001-02-03 08:05:08) snapshot working copy |
| 1754 |
To operation: eb50f4ba33f8 (2001-02-03 08:05:08) new empty commit |
| 1755 |
|
| 1756 |
Changed commits: |
| 1757 |
○ + rlvkpnrz c1c924b8 (empty) (no description set) |
| 1758 |
|
| 1759 |
Changed working copy default@: |
| 1760 |
+ rlvkpnrz c1c924b8 (empty) (no description set) |
| 1761 |
- qpvuntsm 6b57e33c (no description set) |
| 1762 |
[EOF] |
| 1763 |
"); |
| 1764 |
|
| 1765 |
// Squash the working copy commit. |
| 1766 |
work_dir.write_file("file", "b\n"); |
| 1767 |
let output = work_dir.run_jj(["squash"]); |
| 1768 |
insta::assert_snapshot!(output, @" |
| 1769 |
------- stderr ------- |
| 1770 |
Working copy (@) now at: mzvwutvl 6cbd01ae (empty) (no description set) |
| 1771 |
Parent commit (@-) : qpvuntsm 7aa2ec5d (no description set) |
| 1772 |
[EOF] |
| 1773 |
"); |
| 1774 |
let output = work_dir.run_jj(["op", "diff", "-p", "--git"]); |
| 1775 |
insta::assert_snapshot!(output, @" |
| 1776 |
From operation: 5a7a78e63d4a (2001-02-03 08:05:11) snapshot working copy |
| 1777 |
To operation: f8b489c34565 (2001-02-03 08:05:11) squash commits into 6b57e33cc56babbeaa6bcd6e2a296236b52ad93c |
| 1778 |
|
| 1779 |
Changed commits: |
| 1780 |
○ + mzvwutvl 6cbd01ae (empty) (no description set) |
| 1781 |
○ + qpvuntsm 7aa2ec5d (no description set) |
| 1782 |
- qpvuntsm/1 6b57e33c (hidden) (no description set) |
| 1783 |
- rlvkpnrz/0 05a2969e (hidden) (no description set) |
| 1784 |
diff --git a/file b/file |
| 1785 |
index 7898192261..6178079822 100644 |
| 1786 |
--- a/file |
| 1787 |
+++ b/file |
| 1788 |
@@ -1,1 +1,1 @@ |
| 1789 |
-a |
| 1790 |
+b |
| 1791 |
|
| 1792 |
Changed working copy default@: |
| 1793 |
+ mzvwutvl 6cbd01ae (empty) (no description set) |
| 1794 |
- rlvkpnrz/0 05a2969e (hidden) (no description set) |
| 1795 |
[EOF] |
| 1796 |
"); |
| 1797 |
|
| 1798 |
// Abandon the working copy commit. |
| 1799 |
let output = work_dir.run_jj(["abandon"]); |
| 1800 |
insta::assert_snapshot!(output, @" |
| 1801 |
------- stderr ------- |
| 1802 |
Abandoned 1 commits: |
| 1803 |
mzvwutvl 6cbd01ae (empty) (no description set) |
| 1804 |
Working copy (@) now at: yqosqzyt c97a8573 (empty) (no description set) |
| 1805 |
Parent commit (@-) : qpvuntsm 7aa2ec5d (no description set) |
| 1806 |
[EOF] |
| 1807 |
"); |
| 1808 |
let output = work_dir.run_jj(["op", "diff", "-p", "--git"]); |
| 1809 |
insta::assert_snapshot!(output, @" |
| 1810 |
From operation: f8b489c34565 (2001-02-03 08:05:11) squash commits into 6b57e33cc56babbeaa6bcd6e2a296236b52ad93c |
| 1811 |
To operation: cad7943bb3ae (2001-02-03 08:05:13) abandon commit 6cbd01aefe5ae05a015328311dbd63b7305b8ebe |
| 1812 |
|
| 1813 |
Changed commits: |
| 1814 |
○ + yqosqzyt c97a8573 (empty) (no description set) |
| 1815 |
○ - mzvwutvl/0 6cbd01ae (hidden) (empty) (no description set) |
| 1816 |
|
| 1817 |
Changed working copy default@: |
| 1818 |
+ yqosqzyt c97a8573 (empty) (no description set) |
| 1819 |
- mzvwutvl/0 6cbd01ae (hidden) (empty) (no description set) |
| 1820 |
[EOF] |
| 1821 |
"); |
| 1822 |
} |
| 1823 |
|
| 1824 |
#[test] |
| 1825 |
fn test_op_diff_sibling() { |
| 1826 |
let test_env = TestEnvironment::default(); |
| 1827 |
test_env.run_jj_in(".", ["git", "init", "repo"]).success(); |
| 1828 |
let work_dir = test_env.work_dir("repo"); |
| 1829 |
|
| 1830 |
let output = work_dir |
| 1831 |
.run_jj(["op", "log", "--no-graph", r#"-Tid.short() ++ "\n""#]) |
| 1832 |
.success(); |
| 1833 |
let base_op_id = output.stdout.raw().lines().next().unwrap(); |
| 1834 |
insta::assert_snapshot!(base_op_id, @"f63ee16f9553"); |
| 1835 |
|
| 1836 |
// Create merge commit at one operation side. The parent trees will have to |
| 1837 |
// be merged when diffing, which requires the commit index of this side. |
| 1838 |
work_dir.run_jj(["new", "root()", "-mA.1"]).success(); |
| 1839 |
work_dir.write_file("file1", "a\n"); |
| 1840 |
work_dir.run_jj(["new", "root()", "-mA.2"]).success(); |
| 1841 |
work_dir.write_file("file2", "a\n"); |
| 1842 |
work_dir.run_jj(["new", "@-+", "-mA"]).success(); |
| 1843 |
|
| 1844 |
// Create another operation diverged from the base operation. |
| 1845 |
work_dir |
| 1846 |
.run_jj(["describe", "--at-op", base_op_id, "-mB"]) |
| 1847 |
.success(); |
| 1848 |
|
| 1849 |
let output = work_dir.run_jj(["op", "log"]); |
| 1850 |
insta::assert_snapshot!(output, @" |
| 1851 |
@ 5e539df77fe9 [email protected] default@ 2001-02-03 04:05:13.000 +07:00 - 2001-02-03 04:05:13.000 +07:00 |
| 1852 |
├─╮ reconcile divergent operations |
| 1853 |
│ │ args: jj op log |
| 1854 |
○ │ 49d9da1d20b9 [email protected] default@ 2001-02-03 04:05:11.000 +07:00 - 2001-02-03 04:05:11.000 +07:00 |
| 1855 |
│ │ new empty commit |
| 1856 |
│ │ args: jj new '@-+' -mA |
| 1857 |
○ │ eb1736b75b47 [email protected] default@ 2001-02-03 04:05:11.000 +07:00 - 2001-02-03 04:05:11.000 +07:00 |
| 1858 |
│ │ snapshot working copy |
| 1859 |
│ │ args: jj new '@-+' -mA |
| 1860 |
○ │ 7d3a3c0079f2 [email protected] default@ 2001-02-03 04:05:10.000 +07:00 - 2001-02-03 04:05:10.000 +07:00 |
| 1861 |
│ │ new empty commit |
| 1862 |
│ │ args: jj new 'root()' -mA.2 |
| 1863 |
○ │ 7891168620e2 [email protected] default@ 2001-02-03 04:05:10.000 +07:00 - 2001-02-03 04:05:10.000 +07:00 |
| 1864 |
│ │ snapshot working copy |
| 1865 |
│ │ args: jj new 'root()' -mA.2 |
| 1866 |
○ │ 7edadff416f8 [email protected] default@ 2001-02-03 04:05:09.000 +07:00 - 2001-02-03 04:05:09.000 +07:00 |
| 1867 |
│ │ new empty commit |
| 1868 |
│ │ args: jj new 'root()' -mA.1 |
| 1869 |
│ ○ cbb094fbfea4 [email protected] default@ 2001-02-03 04:05:12.000 +07:00 - 2001-02-03 04:05:12.000 +07:00 |
| 1870 |
├─╯ describe commit e8849ae12c709f2321908879bc724fdb2ab8a781 |
| 1871 |
│ args: jj describe --at-op f63ee16f9553 -mB |
| 1872 |
○ f63ee16f9553 [email protected] 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00 |
| 1873 |
│ add workspace 'default' |
| 1874 |
○ 000000000000 root() |
| 1875 |
[EOF] |
| 1876 |
------- stderr ------- |
| 1877 |
Concurrent modification detected, resolving automatically. |
| 1878 |
[EOF] |
| 1879 |
"); |
| 1880 |
let output = work_dir |
| 1881 |
.run_jj(["op", "log", "--no-graph", r#"-Tid.short() ++ "\n""#]) |
| 1882 |
.success(); |
| 1883 |
let [head_op_id, p1_op_id, _, _, _, _, p2_op_id] = |
| 1884 |
output.stdout.raw().lines().next_array().unwrap(); |
| 1885 |
insta::assert_snapshot!(head_op_id, @"5e539df77fe9"); |
| 1886 |
insta::assert_snapshot!(p1_op_id, @"49d9da1d20b9"); |
| 1887 |
insta::assert_snapshot!(p2_op_id, @"cbb094fbfea4"); |
| 1888 |
|
| 1889 |
// Diff between p1 and p2 operations should work no matter if p2 is chosen |
| 1890 |
// as a base operation. |
| 1891 |
let output = work_dir.run_jj([ |
| 1892 |
"op", |
| 1893 |
"diff", |
| 1894 |
"--at-op", |
| 1895 |
p1_op_id, |
| 1896 |
"--from", |
| 1897 |
p1_op_id, |
| 1898 |
"--to", |
| 1899 |
p2_op_id, |
| 1900 |
"--summary", |
| 1901 |
]); |
| 1902 |
insta::assert_snapshot!(output, @" |
| 1903 |
From operation: 49d9da1d20b9 (2001-02-03 08:05:11) new empty commit |
| 1904 |
To operation: cbb094fbfea4 (2001-02-03 08:05:12) describe commit e8849ae12c709f2321908879bc724fdb2ab8a781 |
| 1905 |
|
| 1906 |
Changed commits: |
| 1907 |
○ - mzvwutvl/0 08c63613 (hidden) (empty) A |
| 1908 |
├─╮ |
| 1909 |
│ ○ - kkmpptxz/0 6c70a4f7 (hidden) A.1 |
| 1910 |
│ A file1 |
| 1911 |
○ - zsuskuln/0 47b9525e (hidden) A.2 |
| 1912 |
A file2 |
| 1913 |
○ + qpvuntsm b1ca67e2 (empty) B |
| 1914 |
- qpvuntsm/1 e8849ae1 (hidden) (empty) (no description set) |
| 1915 |
|
| 1916 |
Changed working copy default@: |
| 1917 |
+ qpvuntsm b1ca67e2 (empty) B |
| 1918 |
- mzvwutvl/0 08c63613 (hidden) (empty) A |
| 1919 |
[EOF] |
| 1920 |
"); |
| 1921 |
let output = work_dir.run_jj([ |
| 1922 |
"op", |
| 1923 |
"diff", |
| 1924 |
"--at-op", |
| 1925 |
p2_op_id, |
| 1926 |
"--from", |
| 1927 |
p2_op_id, |
| 1928 |
"--to", |
| 1929 |
p1_op_id, |
| 1930 |
"--summary", |
| 1931 |
]); |
| 1932 |
insta::assert_snapshot!(output, @" |
| 1933 |
From operation: cbb094fbfea4 (2001-02-03 08:05:12) describe commit e8849ae12c709f2321908879bc724fdb2ab8a781 |
| 1934 |
To operation: 49d9da1d20b9 (2001-02-03 08:05:11) new empty commit |
| 1935 |
|
| 1936 |
Changed commits: |
| 1937 |
○ - qpvuntsm/0 b1ca67e2 (hidden) (empty) B |
| 1938 |
○ + mzvwutvl 08c63613 (empty) A |
| 1939 |
├─╮ |
| 1940 |
│ ○ + kkmpptxz 6c70a4f7 A.1 |
| 1941 |
│ A file1 |
| 1942 |
○ + zsuskuln 47b9525e A.2 |
| 1943 |
A file2 |
| 1944 |
|
| 1945 |
Changed working copy default@: |
| 1946 |
+ mzvwutvl 08c63613 (empty) A |
| 1947 |
- qpvuntsm/0 b1ca67e2 (hidden) (empty) B |
| 1948 |
[EOF] |
| 1949 |
"); |
| 1950 |
|
| 1951 |
// no graph |
| 1952 |
let output = work_dir.run_jj([ |
| 1953 |
"op", |
| 1954 |
"diff", |
| 1955 |
"--at-op", |
| 1956 |
p2_op_id, |
| 1957 |
"--from", |
| 1958 |
p2_op_id, |
| 1959 |
"--to", |
| 1960 |
p1_op_id, |
| 1961 |
"--summary", |
| 1962 |
"--no-graph", |
| 1963 |
]); |
| 1964 |
insta::assert_snapshot!(output, @" |
| 1965 |
From operation: cbb094fbfea4 (2001-02-03 08:05:12) describe commit e8849ae12c709f2321908879bc724fdb2ab8a781 |
| 1966 |
To operation: 49d9da1d20b9 (2001-02-03 08:05:11) new empty commit |
| 1967 |
|
| 1968 |
Changed commits: |
| 1969 |
- qpvuntsm/0 b1ca67e2 (hidden) (empty) B |
| 1970 |
+ mzvwutvl 08c63613 (empty) A |
| 1971 |
+ zsuskuln 47b9525e A.2 |
| 1972 |
A file2 |
| 1973 |
+ kkmpptxz 6c70a4f7 A.1 |
| 1974 |
A file1 |
| 1975 |
|
| 1976 |
Changed working copy default@: |
| 1977 |
+ mzvwutvl 08c63613 (empty) A |
| 1978 |
- qpvuntsm/0 b1ca67e2 (hidden) (empty) B |
| 1979 |
[EOF] |
| 1980 |
"); |
| 1981 |
} |
| 1982 |
|
| 1983 |
#[test] |
| 1984 |
fn test_op_diff_divergent_change() { |
| 1985 |
let test_env = TestEnvironment::default(); |
| 1986 |
test_env.run_jj_in(".", ["git", "init", "repo"]).success(); |
| 1987 |
let work_dir = test_env.work_dir("repo"); |
| 1988 |
|
| 1989 |
// Initial change |
| 1990 |
work_dir.write_file("file", "1\n"); |
| 1991 |
work_dir.run_jj(["commit", "-m1"]).success(); |
| 1992 |
let initial_op_id = work_dir.current_operation_id(); |
| 1993 |
|
| 1994 |
// Create divergent change |
| 1995 |
work_dir.write_file("file", "2a\n1\n"); |
| 1996 |
work_dir.run_jj(["desc", "-m2a"]).success(); |
| 1997 |
work_dir.run_jj(["edit", "at_operation(@--, @)"]).success(); |
| 1998 |
work_dir.write_file("file", "1\n2b\n"); |
| 1999 |
work_dir.run_jj(["desc", "-m2b"]).success(); |
| 2000 |
insta::assert_snapshot!(work_dir.run_jj(["log"]), @" |
| 2001 |
@ rlvkpnrz/0 [email protected] 2001-02-03 08:05:11 c5cad9ab (divergent) |
| 2002 |
│ 2b |
| 2003 |
│ ○ rlvkpnrz/2 [email protected] 2001-02-03 08:05:09 f189cafa (divergent) |
| 2004 |
├─╯ 2a |
| 2005 |
○ qpvuntsm [email protected] 2001-02-03 08:05:08 8a06f3b3 |
| 2006 |
│ 1 |
| 2007 |
◆ zzzzzzzz root() 00000000 |
| 2008 |
[EOF] |
| 2009 |
"); |
| 2010 |
let divergent_op_id = work_dir.current_operation_id(); |
| 2011 |
|
| 2012 |
// Resolve divergence by squashing commits |
| 2013 |
work_dir |
| 2014 |
.run_jj(["squash", "--from=subject(2a)", "--to=@", "-m2ab"]) |
| 2015 |
.success(); |
| 2016 |
insta::assert_snapshot!(work_dir.run_jj(["log"]), @" |
| 2017 |
@ rlvkpnrz [email protected] 2001-02-03 08:05:13 17d68d92 |
| 2018 |
│ 2ab |
| 2019 |
○ qpvuntsm [email protected] 2001-02-03 08:05:08 8a06f3b3 |
| 2020 |
│ 1 |
| 2021 |
◆ zzzzzzzz root() 00000000 |
| 2022 |
[EOF] |
| 2023 |
"); |
| 2024 |
let resolved_op_id = work_dir.current_operation_id(); |
| 2025 |
|
| 2026 |
// Diff of new divergence |
| 2027 |
let output = work_dir.run_jj([ |
| 2028 |
"op", |
| 2029 |
"diff", |
| 2030 |
"--from", |
| 2031 |
&initial_op_id, |
| 2032 |
"--to", |
| 2033 |
&divergent_op_id, |
| 2034 |
]); |
| 2035 |
insta::assert_snapshot!(output, @" |
| 2036 |
From operation: 6f308a91623b (2001-02-03 08:05:08) commit 5d86d4b609080a15077fcd723e537582d5ea6559 |
| 2037 |
To operation: 1259e1240aef (2001-02-03 08:05:11) describe commit 7a72a9ad7f4d8aa8b613a9840313b0ef0632842b |
| 2038 |
|
| 2039 |
Changed commits: |
| 2040 |
○ + rlvkpnrz/0 c5cad9ab (divergent) 2b |
| 2041 |
- rlvkpnrz/4 4f7a567a (hidden) (empty) (no description set) |
| 2042 |
○ + rlvkpnrz/2 f189cafa (divergent) 2a |
| 2043 |
- rlvkpnrz/4 4f7a567a (hidden) (empty) (no description set) |
| 2044 |
|
| 2045 |
Changed working copy default@: |
| 2046 |
+ rlvkpnrz/0 c5cad9ab (divergent) 2b |
| 2047 |
- rlvkpnrz/4 4f7a567a (hidden) (empty) (no description set) |
| 2048 |
[EOF] |
| 2049 |
"); |
| 2050 |
|
| 2051 |
// Diff of old divergence |
| 2052 |
let output = work_dir.run_jj([ |
| 2053 |
"op", |
| 2054 |
"diff", |
| 2055 |
"--from", |
| 2056 |
&divergent_op_id, |
| 2057 |
"--to", |
| 2058 |
&resolved_op_id, |
| 2059 |
]); |
| 2060 |
insta::assert_snapshot!(output, @" |
| 2061 |
From operation: 1259e1240aef (2001-02-03 08:05:11) describe commit 7a72a9ad7f4d8aa8b613a9840313b0ef0632842b |
| 2062 |
To operation: c570e82e2625 (2001-02-03 08:05:13) squash commits into c5cad9ab7772714178c158a133a0243908545b48 |
| 2063 |
|
| 2064 |
Changed commits: |
| 2065 |
○ + rlvkpnrz 17d68d92 2ab |
| 2066 |
- rlvkpnrz/1 c5cad9ab (hidden) 2b |
| 2067 |
- rlvkpnrz/3 f189cafa (hidden) 2a |
| 2068 |
|
| 2069 |
Changed working copy default@: |
| 2070 |
+ rlvkpnrz 17d68d92 2ab |
| 2071 |
- rlvkpnrz/1 c5cad9ab (hidden) 2b |
| 2072 |
[EOF] |
| 2073 |
"); |
| 2074 |
|
| 2075 |
// Diff of new divergence with patch |
| 2076 |
let output = work_dir.run_jj([ |
| 2077 |
"op", |
| 2078 |
"diff", |
| 2079 |
"--git", |
| 2080 |
"--from", |
| 2081 |
&initial_op_id, |
| 2082 |
"--to", |
| 2083 |
&divergent_op_id, |
| 2084 |
]); |
| 2085 |
insta::assert_snapshot!(output, @" |
| 2086 |
From operation: 6f308a91623b (2001-02-03 08:05:08) commit 5d86d4b609080a15077fcd723e537582d5ea6559 |
| 2087 |
To operation: 1259e1240aef (2001-02-03 08:05:11) describe commit 7a72a9ad7f4d8aa8b613a9840313b0ef0632842b |
| 2088 |
|
| 2089 |
Changed commits: |
| 2090 |
○ + rlvkpnrz/0 c5cad9ab (divergent) 2b |
| 2091 |
- rlvkpnrz/4 4f7a567a (hidden) (empty) (no description set) |
| 2092 |
diff --git a/JJ-COMMIT-DESCRIPTION b/JJ-COMMIT-DESCRIPTION |
| 2093 |
--- JJ-COMMIT-DESCRIPTION |
| 2094 |
+++ JJ-COMMIT-DESCRIPTION |
| 2095 |
@@ -0,0 +1,1 @@ |
| 2096 |
+2b |
| 2097 |
diff --git a/file b/file |
| 2098 |
index d00491fd7e..5e0f51b37b 100644 |
| 2099 |
--- a/file |
| 2100 |
+++ b/file |
| 2101 |
@@ -1,1 +1,2 @@ |
| 2102 |
1 |
| 2103 |
+2b |
| 2104 |
○ + rlvkpnrz/2 f189cafa (divergent) 2a |
| 2105 |
- rlvkpnrz/4 4f7a567a (hidden) (empty) (no description set) |
| 2106 |
diff --git a/JJ-COMMIT-DESCRIPTION b/JJ-COMMIT-DESCRIPTION |
| 2107 |
--- JJ-COMMIT-DESCRIPTION |
| 2108 |
+++ JJ-COMMIT-DESCRIPTION |
| 2109 |
@@ -0,0 +1,1 @@ |
| 2110 |
+2a |
| 2111 |
diff --git a/file b/file |
| 2112 |
index d00491fd7e..13a46f22fa 100644 |
| 2113 |
--- a/file |
| 2114 |
+++ b/file |
| 2115 |
@@ -1,1 +1,2 @@ |
| 2116 |
+2a |
| 2117 |
1 |
| 2118 |
|
| 2119 |
Changed working copy default@: |
| 2120 |
+ rlvkpnrz/0 c5cad9ab (divergent) 2b |
| 2121 |
- rlvkpnrz/4 4f7a567a (hidden) (empty) (no description set) |
| 2122 |
[EOF] |
| 2123 |
"); |
| 2124 |
|
| 2125 |
// Diff of old divergence with patch |
| 2126 |
let output = work_dir.run_jj([ |
| 2127 |
"op", |
| 2128 |
"diff", |
| 2129 |
"--git", |
| 2130 |
"--from", |
| 2131 |
&divergent_op_id, |
| 2132 |
"--to", |
| 2133 |
&resolved_op_id, |
| 2134 |
]); |
| 2135 |
insta::assert_snapshot!(output, @" |
| 2136 |
From operation: 1259e1240aef (2001-02-03 08:05:11) describe commit 7a72a9ad7f4d8aa8b613a9840313b0ef0632842b |
| 2137 |
To operation: c570e82e2625 (2001-02-03 08:05:13) squash commits into c5cad9ab7772714178c158a133a0243908545b48 |
| 2138 |
|
| 2139 |
Changed commits: |
| 2140 |
○ + rlvkpnrz 17d68d92 2ab |
| 2141 |
- rlvkpnrz/1 c5cad9ab (hidden) 2b |
| 2142 |
- rlvkpnrz/3 f189cafa (hidden) 2a |
| 2143 |
diff --git a/JJ-COMMIT-DESCRIPTION b/JJ-COMMIT-DESCRIPTION |
| 2144 |
--- JJ-COMMIT-DESCRIPTION |
| 2145 |
+++ JJ-COMMIT-DESCRIPTION |
| 2146 |
@@ -1,1 +1,1 @@ |
| 2147 |
-2b |
| 2148 |
+2ab |
| 2149 |
diff --git a/file b/file |
| 2150 |
index 5e0f51b37b..60327514e0 100644 |
| 2151 |
--- a/file |
| 2152 |
+++ b/file |
| 2153 |
@@ -1,2 +1,3 @@ |
| 2154 |
+2a |
| 2155 |
1 |
| 2156 |
2b |
| 2157 |
|
| 2158 |
Changed working copy default@: |
| 2159 |
+ rlvkpnrz 17d68d92 2ab |
| 2160 |
- rlvkpnrz/1 c5cad9ab (hidden) 2b |
| 2161 |
[EOF] |
| 2162 |
"); |
| 2163 |
|
| 2164 |
// Reverse diff of old divergence |
| 2165 |
let output = work_dir.run_jj([ |
| 2166 |
"op", |
| 2167 |
"diff", |
| 2168 |
"--from", |
| 2169 |
&resolved_op_id, |
| 2170 |
"--to", |
| 2171 |
&divergent_op_id, |
| 2172 |
]); |
| 2173 |
insta::assert_snapshot!(output, @" |
| 2174 |
From operation: c570e82e2625 (2001-02-03 08:05:13) squash commits into c5cad9ab7772714178c158a133a0243908545b48 |
| 2175 |
To operation: 1259e1240aef (2001-02-03 08:05:11) describe commit 7a72a9ad7f4d8aa8b613a9840313b0ef0632842b |
| 2176 |
|
| 2177 |
Changed commits: |
| 2178 |
○ + rlvkpnrz/1 c5cad9ab (divergent) 2b |
| 2179 |
- rlvkpnrz/0 17d68d92 (hidden) 2ab |
| 2180 |
○ + rlvkpnrz/3 f189cafa (divergent) 2a |
| 2181 |
- rlvkpnrz/0 17d68d92 (hidden) 2ab |
| 2182 |
|
| 2183 |
Changed working copy default@: |
| 2184 |
+ rlvkpnrz/1 c5cad9ab (divergent) 2b |
| 2185 |
- rlvkpnrz/0 17d68d92 (hidden) 2ab |
| 2186 |
[EOF] |
| 2187 |
"); |
| 2188 |
|
| 2189 |
// Reverse diff of new divergence |
| 2190 |
let output = work_dir.run_jj([ |
| 2191 |
"op", |
| 2192 |
"diff", |
| 2193 |
"--from", |
| 2194 |
&divergent_op_id, |
| 2195 |
"--to", |
| 2196 |
&initial_op_id, |
| 2197 |
]); |
| 2198 |
insta::assert_snapshot!(output, @" |
| 2199 |
From operation: 1259e1240aef (2001-02-03 08:05:11) describe commit 7a72a9ad7f4d8aa8b613a9840313b0ef0632842b |
| 2200 |
To operation: 6f308a91623b (2001-02-03 08:05:08) commit 5d86d4b609080a15077fcd723e537582d5ea6559 |
| 2201 |
|
| 2202 |
Changed commits: |
| 2203 |
○ + rlvkpnrz 4f7a567a (empty) (no description set) |
| 2204 |
- rlvkpnrz/2 f189cafa (hidden) 2a |
| 2205 |
- rlvkpnrz/0 c5cad9ab (hidden) 2b |
| 2206 |
|
| 2207 |
Changed working copy default@: |
| 2208 |
+ rlvkpnrz 4f7a567a (empty) (no description set) |
| 2209 |
- rlvkpnrz/0 c5cad9ab (hidden) 2b |
| 2210 |
[EOF] |
| 2211 |
"); |
| 2212 |
} |
| 2213 |
|
| 2214 |
#[test] |
| 2215 |
fn test_op_diff_at_merge_op_with_rebased_commits() { |
| 2216 |
let test_env = TestEnvironment::default(); |
| 2217 |
test_env.run_jj_in(".", ["git", "init", "repo"]).success(); |
| 2218 |
let work_dir = test_env.work_dir("repo"); |
| 2219 |
|
| 2220 |
// Create merge operation that rebases descendant commits |
| 2221 |
work_dir.run_jj(["new", "-m2a"]).success(); |
| 2222 |
work_dir.run_jj(["desc", "-r@-", "-m1"]).success(); |
| 2223 |
work_dir.run_jj(["desc", "--at-op=@-", "-m2b"]).success(); |
| 2224 |
|
| 2225 |
insta::assert_snapshot!(work_dir.run_jj(["log"]), @r" |
| 2226 |
@ rlvkpnrz/2 [email protected] 2001-02-03 08:05:09 7ed5a610 (divergent) |
| 2227 |
│ (empty) 2a |
| 2228 |
│ ○ rlvkpnrz/0 [email protected] 2001-02-03 08:05:11 8f35f6a6 (divergent) |
| 2229 |
├─╯ (empty) 2b |
| 2230 |
○ qpvuntsm [email protected] 2001-02-03 08:05:09 6666e5c3 |
| 2231 |
│ (empty) 1 |
| 2232 |
◆ zzzzzzzz root() 00000000 |
| 2233 |
[EOF] |
| 2234 |
------- stderr ------- |
| 2235 |
Concurrent modification detected, resolving automatically. |
| 2236 |
Rebased 1 descendant commits onto commits rewritten by other operation. |
| 2237 |
[EOF] |
| 2238 |
"); |
| 2239 |
|
| 2240 |
// FIXME: the diff should be empty |
| 2241 |
let output = work_dir.run_jj(["op", "diff"]); |
| 2242 |
insta::assert_snapshot!(output, @" |
| 2243 |
From operation: e20b9b9f8704 (2001-02-03 08:05:09) describe commit e8849ae12c709f2321908879bc724fdb2ab8a781 |
| 2244 |
From operation: 71ec13d562f6 (2001-02-03 08:05:10) describe commit ab92d1a87bebb4300165a16a753c5403bd7bc578 |
| 2245 |
To operation: 110aea121037 (2001-02-03 08:05:11) reconcile divergent operations |
| 2246 |
|
| 2247 |
Changed commits: |
| 2248 |
○ + rlvkpnrz/1 8f35f6a6 (divergent) (empty) 2b |
| 2249 |
- rlvkpnrz/0 4545eaf5 (hidden) (empty) 2b |
| 2250 |
[EOF] |
| 2251 |
"); |
| 2252 |
|
| 2253 |
let output = work_dir.run_jj(["op", "show"]); |
| 2254 |
insta::assert_snapshot!(output, @" |
| 2255 |
110aea121037 [email protected] default@ 2001-02-03 04:05:11.000 +07:00 - 2001-02-03 04:05:11.000 +07:00 |
| 2256 |
reconcile divergent operations |
| 2257 |
args: jj log |
| 2258 |
[EOF] |
| 2259 |
"); |
| 2260 |
|
| 2261 |
let output = work_dir.run_jj(["op", "log", "--op-diff", "--limit=3"]); |
| 2262 |
insta::assert_snapshot!(output, @" |
| 2263 |
@ 110aea121037 [email protected] default@ 2001-02-03 04:05:11.000 +07:00 - 2001-02-03 04:05:11.000 +07:00 |
| 2264 |
├─╮ reconcile divergent operations |
| 2265 |
│ │ args: jj log |
| 2266 |
○ │ e20b9b9f8704 [email protected] default@ 2001-02-03 04:05:09.000 +07:00 - 2001-02-03 04:05:09.000 +07:00 |
| 2267 |
│ │ describe commit e8849ae12c709f2321908879bc724fdb2ab8a781 |
| 2268 |
│ │ args: jj describe -r@- -m1 |
| 2269 |
│ │ |
| 2270 |
│ │ Changed commits: |
| 2271 |
│ │ ○ + rlvkpnrz 7ed5a610 (empty) 2a |
| 2272 |
│ │ │ - rlvkpnrz/1 ab92d1a8 (hidden) (empty) 2a |
| 2273 |
│ │ ○ + qpvuntsm 6666e5c3 (empty) 1 |
| 2274 |
│ │ - qpvuntsm/1 e8849ae1 (hidden) (empty) (no description set) |
| 2275 |
│ │ |
| 2276 |
│ │ Changed working copy default@: |
| 2277 |
│ │ + rlvkpnrz 7ed5a610 (empty) 2a |
| 2278 |
│ │ - rlvkpnrz/1 ab92d1a8 (hidden) (empty) 2a |
| 2279 |
│ ○ 71ec13d562f6 [email protected] default@ 2001-02-03 04:05:10.000 +07:00 - 2001-02-03 04:05:10.000 +07:00 |
| 2280 |
├─╯ describe commit ab92d1a87bebb4300165a16a753c5403bd7bc578 |
| 2281 |
│ args: jj describe '--at-op=@-' -m2b |
| 2282 |
│ |
| 2283 |
│ Changed commits: |
| 2284 |
│ ○ + rlvkpnrz 50ec12eb (empty) 2b |
| 2285 |
│ - rlvkpnrz/1 ab92d1a8 (hidden) (empty) 2a |
| 2286 |
│ |
| 2287 |
│ Changed working copy default@: |
| 2288 |
│ + rlvkpnrz 50ec12eb (empty) 2b |
| 2289 |
│ - rlvkpnrz/1 ab92d1a8 (hidden) (empty) 2a |
| 2290 |
[EOF] |
| 2291 |
"); |
| 2292 |
} |
| 2293 |
|
| 2294 |
#[test] |
| 2295 |
fn test_op_diff_word_wrap() { |
| 2296 |
let test_env = TestEnvironment::default(); |
| 2297 |
let git_repo_path = test_env.env_root().join("git-repo"); |
| 2298 |
init_bare_git_repo(&git_repo_path); |
| 2299 |
test_env |
| 2300 |
.run_jj_in(".", ["git", "clone", "git-repo", "repo"]) |
| 2301 |
.success(); |
| 2302 |
let work_dir = test_env.work_dir("repo"); |
| 2303 |
let render = |args: &[&str], columns: u32, word_wrap: bool| { |
| 2304 |
let word_wrap = to_toml_value(word_wrap); |
| 2305 |
work_dir.run_jj_with(|cmd| { |
| 2306 |
cmd.args(args) |
| 2307 |
.arg(format!("--config=ui.log-word-wrap={word_wrap}")) |
| 2308 |
.arg("--config=revset-aliases.'immutable_heads()'='root()'") |
| 2309 |
.env("COLUMNS", columns.to_string()) |
| 2310 |
}) |
| 2311 |
}; |
| 2312 |
|
| 2313 |
// Add some file content changes |
| 2314 |
work_dir.write_file("file1", "foo\n".repeat(100)); |
| 2315 |
work_dir.run_jj(["debug", "snapshot"]).success(); |
| 2316 |
|
| 2317 |
// ui.log-word-wrap option works, and diff stat respects content width |
| 2318 |
insta::assert_snapshot!(render(&["op", "diff", "--from=@---", "--stat"], 40, true), @" |
| 2319 |
From operation: 267d2e28edfc (2001-02-03 08:05:07) add git remote origin |
| 2320 |
To operation: 668558c2bb9b (2001-02-03 08:05:08) snapshot working copy |
| 2321 |
|
| 2322 |
Changed commits: |
| 2323 |
○ + sqpuoqvx f6f32c19 (no description |
| 2324 |
│ set) |
| 2325 |
│ file1 | 100 +++++++++++++++++++++++++ |
| 2326 |
│ 1 file changed, 100 insertions(+), 0 deletions(-) |
| 2327 |
○ + pukowqtp 0cb7e07e bookmark-1 | |
| 2328 |
Commit 1 |
| 2329 |
some-file | 1 + |
| 2330 |
1 file changed, 1 insertion(+), 0 deletions(-) |
| 2331 |
○ + skovwzlu 854c38b8 Commit 4 |
| 2332 |
some-file | 1 + |
| 2333 |
1 file changed, 1 insertion(+), 0 deletions(-) |
| 2334 |
○ + rnnslrkn 4ff62539 bookmark-2@origin |
| 2335 |
| Commit 2 |
| 2336 |
some-file | 1 + |
| 2337 |
1 file changed, 1 insertion(+), 0 deletions(-) |
| 2338 |
○ + rnnkyono 11671e4c bookmark-3@origin |
| 2339 |
| Commit 3 |
| 2340 |
some-file | 1 + |
| 2341 |
1 file changed, 1 insertion(+), 0 deletions(-) |
| 2342 |
○ - qpvuntsm/0 e8849ae1 (hidden) |
| 2343 |
(empty) (no description set) |
| 2344 |
0 files changed, 0 insertions(+), 0 deletions(-) |
| 2345 |
|
| 2346 |
Changed working copy default@: |
| 2347 |
+ sqpuoqvx f6f32c19 (no description set) |
| 2348 |
- qpvuntsm/0 e8849ae1 (hidden) (empty) |
| 2349 |
(no description set) |
| 2350 |
|
| 2351 |
Changed local bookmarks: |
| 2352 |
bookmark-1: |
| 2353 |
+ pukowqtp 0cb7e07e bookmark-1 | Commit |
| 2354 |
1 |
| 2355 |
- (absent) |
| 2356 |
|
| 2357 |
Changed local tags: |
| 2358 |
tag-1: |
| 2359 |
+ skovwzlu 854c38b8 Commit 4 |
| 2360 |
- (absent) |
| 2361 |
|
| 2362 |
Changed remote bookmarks: |
| 2363 |
bookmark-1@origin: |
| 2364 |
+ tracked pukowqtp 0cb7e07e bookmark-1 | |
| 2365 |
Commit 1 |
| 2366 |
- untracked (absent) |
| 2367 |
bookmark-2@origin: |
| 2368 |
+ untracked rnnslrkn 4ff62539 |
| 2369 |
bookmark-2@origin | Commit 2 |
| 2370 |
- untracked (absent) |
| 2371 |
bookmark-3@origin: |
| 2372 |
+ untracked rnnkyono 11671e4c |
| 2373 |
bookmark-3@origin | Commit 3 |
| 2374 |
- untracked (absent) |
| 2375 |
|
| 2376 |
Changed remote tags: |
| 2377 |
tag-1@origin: |
| 2378 |
+ tracked skovwzlu 854c38b8 Commit 4 |
| 2379 |
- untracked (absent) |
| 2380 |
[EOF] |
| 2381 |
"); |
| 2382 |
|
| 2383 |
// Graph width should be subtracted from the term width |
| 2384 |
let config = r#"templates.commit_summary='"0 1 2 3 4 5 6 7 8 9"'"#; |
| 2385 |
insta::assert_snapshot!( |
| 2386 |
render(&["op", "diff", "--from=@---", "--config", config], 10, true), @" |
| 2387 |
From operation: 267d2e28edfc (2001-02-03 08:05:07) add git remote origin |
| 2388 |
To operation: 668558c2bb9b (2001-02-03 08:05:08) snapshot working copy |
| 2389 |
|
| 2390 |
Changed |
| 2391 |
commits: |
| 2392 |
○ + 0 1 2 |
| 2393 |
│ 3 4 5 6 |
| 2394 |
│ 7 8 9 |
| 2395 |
○ + 0 1 2 |
| 2396 |
3 4 5 6 |
| 2397 |
7 8 9 |
| 2398 |
○ + 0 1 2 |
| 2399 |
3 4 5 6 |
| 2400 |
7 8 9 |
| 2401 |
○ + 0 1 2 |
| 2402 |
3 4 5 6 |
| 2403 |
7 8 9 |
| 2404 |
○ + 0 1 2 |
| 2405 |
3 4 5 6 |
| 2406 |
7 8 9 |
| 2407 |
○ - 0 1 2 |
| 2408 |
3 4 5 6 |
| 2409 |
7 8 9 |
| 2410 |
|
| 2411 |
Changed |
| 2412 |
working |
| 2413 |
copy |
| 2414 |
default@: |
| 2415 |
+ 0 1 2 3 |
| 2416 |
4 5 6 7 8 |
| 2417 |
9 |
| 2418 |
- 0 1 2 3 |
| 2419 |
4 5 6 7 8 |
| 2420 |
9 |
| 2421 |
|
| 2422 |
Changed |
| 2423 |
local |
| 2424 |
bookmarks: |
| 2425 |
bookmark-1: |
| 2426 |
+ 0 1 2 3 |
| 2427 |
4 5 6 7 8 |
| 2428 |
9 |
| 2429 |
- (absent) |
| 2430 |
|
| 2431 |
Changed |
| 2432 |
local |
| 2433 |
tags: |
| 2434 |
tag-1: |
| 2435 |
+ 0 1 2 3 |
| 2436 |
4 5 6 7 8 |
| 2437 |
9 |
| 2438 |
- (absent) |
| 2439 |
|
| 2440 |
Changed |
| 2441 |
remote |
| 2442 |
bookmarks: |
| 2443 |
bookmark-1@origin: |
| 2444 |
+ tracked |
| 2445 |
0 1 2 3 4 |
| 2446 |
5 6 7 8 9 |
| 2447 |
- |
| 2448 |
untracked |
| 2449 |
(absent) |
| 2450 |
bookmark-2@origin: |
| 2451 |
+ |
| 2452 |
untracked |
| 2453 |
0 1 2 3 4 |
| 2454 |
5 6 7 8 9 |
| 2455 |
- |
| 2456 |
untracked |
| 2457 |
(absent) |
| 2458 |
bookmark-3@origin: |
| 2459 |
+ |
| 2460 |
untracked |
| 2461 |
0 1 2 3 4 |
| 2462 |
5 6 7 8 9 |
| 2463 |
- |
| 2464 |
untracked |
| 2465 |
(absent) |
| 2466 |
|
| 2467 |
Changed |
| 2468 |
remote |
| 2469 |
tags: |
| 2470 |
tag-1@origin: |
| 2471 |
+ tracked |
| 2472 |
0 1 2 3 4 |
| 2473 |
5 6 7 8 9 |
| 2474 |
- |
| 2475 |
untracked |
| 2476 |
(absent) |
| 2477 |
[EOF] |
| 2478 |
"); |
| 2479 |
} |
| 2480 |
|
| 2481 |
#[test] |
| 2482 |
fn test_op_show() { |
| 2483 |
let test_env = TestEnvironment::default(); |
| 2484 |
let git_repo_path = test_env.env_root().join("git-repo"); |
| 2485 |
let git_repo = init_bare_git_repo(&git_repo_path); |
| 2486 |
test_env.run_jj_in(".", ["git", "init", "repo"]).success(); |
| 2487 |
let work_dir = test_env.work_dir("repo"); |
| 2488 |
work_dir |
| 2489 |
.run_jj(["git", "remote", "add", "origin", "../git-repo"]) |
| 2490 |
.success(); |
| 2491 |
work_dir.run_jj(["git", "fetch"]).success(); |
| 2492 |
work_dir |
| 2493 |
.run_jj(["bookmark", "track", "bookmark-1"]) |
| 2494 |
.success(); |
| 2495 |
|
| 2496 |
// Overview of op log. |
| 2497 |
let output = work_dir.run_jj(["op", "log"]); |
| 2498 |
insta::assert_snapshot!(output, @" |
| 2499 |
@ c398dc66e5f4 [email protected] default@ 2001-02-03 04:05:10.000 +07:00 - 2001-02-03 04:05:10.000 +07:00 |
| 2500 |
│ track remote bookmark bookmark-1@origin |
| 2501 |
│ args: jj bookmark track bookmark-1 |
| 2502 |
○ 47cfe27aee78 [email protected] default@ 2001-02-03 04:05:09.000 +07:00 - 2001-02-03 04:05:09.000 +07:00 |
| 2503 |
│ fetch from git remote(s) origin |
| 2504 |
│ args: jj git fetch |
| 2505 |
○ 0dcdecd46a3d [email protected] default@ 2001-02-03 04:05:08.000 +07:00 - 2001-02-03 04:05:08.000 +07:00 |
| 2506 |
│ add git remote origin |
| 2507 |
│ args: jj git remote add origin ../git-repo |
| 2508 |
○ f63ee16f9553 [email protected] 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00 |
| 2509 |
│ add workspace 'default' |
| 2510 |
○ 000000000000 root() |
| 2511 |
[EOF] |
| 2512 |
"); |
| 2513 |
|
| 2514 |
// The root operation is empty. |
| 2515 |
let output = work_dir.run_jj(["op", "show", "0000000"]); |
| 2516 |
insta::assert_snapshot!(output, @" |
| 2517 |
000000000000 root() |
| 2518 |
[EOF] |
| 2519 |
"); |
| 2520 |
|
| 2521 |
// Showing the latest operation. |
| 2522 |
let output = work_dir.run_jj(["op", "show", "@"]); |
| 2523 |
insta::assert_snapshot!(output, @" |
| 2524 |
c398dc66e5f4 [email protected] default@ 2001-02-03 04:05:10.000 +07:00 - 2001-02-03 04:05:10.000 +07:00 |
| 2525 |
track remote bookmark bookmark-1@origin |
| 2526 |
args: jj bookmark track bookmark-1 |
| 2527 |
|
| 2528 |
Changed local bookmarks: |
| 2529 |
bookmark-1: |
| 2530 |
+ pukowqtp 0cb7e07e bookmark-1 | Commit 1 |
| 2531 |
- (absent) |
| 2532 |
|
| 2533 |
Changed remote bookmarks: |
| 2534 |
bookmark-1@origin: |
| 2535 |
+ tracked pukowqtp 0cb7e07e bookmark-1 | Commit 1 |
| 2536 |
- untracked pukowqtp 0cb7e07e bookmark-1 | Commit 1 |
| 2537 |
[EOF] |
| 2538 |
"); |
| 2539 |
// `jj op show @` should behave identically to `jj op show`. |
| 2540 |
let output_without_op_id = work_dir.run_jj(["op", "show"]); |
| 2541 |
assert_eq!(output, output_without_op_id); |
| 2542 |
|
| 2543 |
// Showing a given operation. |
| 2544 |
let output = work_dir.run_jj(["op", "show", "@-"]); |
| 2545 |
insta::assert_snapshot!(output, @" |
| 2546 |
47cfe27aee78 [email protected] default@ 2001-02-03 04:05:09.000 +07:00 - 2001-02-03 04:05:09.000 +07:00 |
| 2547 |
fetch from git remote(s) origin |
| 2548 |
args: jj git fetch |
| 2549 |
|
| 2550 |
Changed commits: |
| 2551 |
○ + skovwzlu 854c38b8 Commit 4 |
| 2552 |
○ + rnnslrkn 4ff62539 bookmark-2@origin | Commit 2 |
| 2553 |
○ + rnnkyono 11671e4c bookmark-3@origin | Commit 3 |
| 2554 |
○ + pukowqtp 0cb7e07e bookmark-1@origin | Commit 1 |
| 2555 |
|
| 2556 |
Changed local tags: |
| 2557 |
tag-1: |
| 2558 |
+ skovwzlu 854c38b8 Commit 4 |
| 2559 |
- (absent) |
| 2560 |
|
| 2561 |
Changed remote bookmarks: |
| 2562 |
bookmark-1@origin: |
| 2563 |
+ untracked pukowqtp 0cb7e07e bookmark-1@origin | Commit 1 |
| 2564 |
- untracked (absent) |
| 2565 |
bookmark-2@origin: |
| 2566 |
+ untracked rnnslrkn 4ff62539 bookmark-2@origin | Commit 2 |
| 2567 |
- untracked (absent) |
| 2568 |
bookmark-3@origin: |
| 2569 |
+ untracked rnnkyono 11671e4c bookmark-3@origin | Commit 3 |
| 2570 |
- untracked (absent) |
| 2571 |
|
| 2572 |
Changed remote tags: |
| 2573 |
tag-1@origin: |
| 2574 |
+ tracked skovwzlu 854c38b8 Commit 4 |
| 2575 |
- untracked (absent) |
| 2576 |
[EOF] |
| 2577 |
"); |
| 2578 |
|
| 2579 |
// Create a conflicted bookmark using a concurrent operation. |
| 2580 |
work_dir |
| 2581 |
.run_jj([ |
| 2582 |
"bookmark", |
| 2583 |
"set", |
| 2584 |
"bookmark-1", |
| 2585 |
"-r", |
| 2586 |
"bookmark-2@origin", |
| 2587 |
"--at-op", |
| 2588 |
"@-", |
| 2589 |
]) |
| 2590 |
.success(); |
| 2591 |
let output = work_dir.run_jj(["log"]); |
| 2592 |
insta::assert_snapshot!(output, @" |
| 2593 |
@ qpvuntsm [email protected] 2001-02-03 08:05:07 e8849ae1 |
| 2594 |
│ (empty) (no description set) |
| 2595 |
│ ○ pukowqtp [email protected] 1970-01-01 11:00:00 bookmark-1?? bookmark-1@origin 0cb7e07e |
| 2596 |
├─╯ Commit 1 |
| 2597 |
◆ zzzzzzzz root() 00000000 |
| 2598 |
[EOF] |
| 2599 |
------- stderr ------- |
| 2600 |
Concurrent modification detected, resolving automatically. |
| 2601 |
[EOF] |
| 2602 |
"); |
| 2603 |
// Showing a merge operation is empty. |
| 2604 |
let output = work_dir.run_jj(["op", "show"]); |
| 2605 |
insta::assert_snapshot!(output, @" |
| 2606 |
92b44996917e [email protected] default@ 2001-02-03 04:05:17.000 +07:00 - 2001-02-03 04:05:17.000 +07:00 |
| 2607 |
reconcile divergent operations |
| 2608 |
args: jj log |
| 2609 |
[EOF] |
| 2610 |
"); |
| 2611 |
|
| 2612 |
// Test fetching from git remote. |
| 2613 |
modify_git_repo(git_repo); |
| 2614 |
let output = work_dir.run_jj(["git", "fetch"]); |
| 2615 |
insta::assert_snapshot!(output, @" |
| 2616 |
------- stderr ------- |
| 2617 |
bookmark: bookmark-1@origin [updated] tracked |
| 2618 |
bookmark: bookmark-2@origin [updated] untracked |
| 2619 |
bookmark: bookmark-3@origin [deleted] untracked |
| 2620 |
Abandoned 1 commits that are no longer reachable: |
| 2621 |
rnnkyono 11671e4c Commit 3 |
| 2622 |
[EOF] |
| 2623 |
"); |
| 2624 |
let output = work_dir.run_jj(["op", "show"]); |
| 2625 |
insta::assert_snapshot!(output, @" |
| 2626 |
e4311180b383 [email protected] default@ 2001-02-03 04:05:19.000 +07:00 - 2001-02-03 04:05:19.000 +07:00 |
| 2627 |
fetch from git remote(s) origin |
| 2628 |
args: jj git fetch |
| 2629 |
|
| 2630 |
Changed commits: |
| 2631 |
○ + kulxwnxm e1a239a5 bookmark-2@origin | Commit 5 |
| 2632 |
○ + zkmtkqvo 0dee6313 bookmark-1?? bookmark-1@origin | Commit 4 |
| 2633 |
○ - rnnkyono/0 11671e4c (hidden) Commit 3 |
| 2634 |
|
| 2635 |
Changed local bookmarks: |
| 2636 |
bookmark-1: |
| 2637 |
+ (added) zkmtkqvo 0dee6313 bookmark-1?? bookmark-1@origin | Commit 4 |
| 2638 |
+ (added) rnnslrkn 4ff62539 bookmark-1?? | Commit 2 |
| 2639 |
- (added) pukowqtp 0cb7e07e Commit 1 |
| 2640 |
- (added) rnnslrkn 4ff62539 bookmark-1?? | Commit 2 |
| 2641 |
|
| 2642 |
Changed remote bookmarks: |
| 2643 |
bookmark-1@origin: |
| 2644 |
+ tracked zkmtkqvo 0dee6313 bookmark-1?? bookmark-1@origin | Commit 4 |
| 2645 |
- tracked pukowqtp 0cb7e07e Commit 1 |
| 2646 |
bookmark-2@origin: |
| 2647 |
+ untracked kulxwnxm e1a239a5 bookmark-2@origin | Commit 5 |
| 2648 |
- untracked rnnslrkn 4ff62539 bookmark-1?? | Commit 2 |
| 2649 |
bookmark-3@origin: |
| 2650 |
+ untracked (absent) |
| 2651 |
- untracked rnnkyono/0 11671e4c (hidden) Commit 3 |
| 2652 |
[EOF] |
| 2653 |
"); |
| 2654 |
|
| 2655 |
// Test creation of bookmark. |
| 2656 |
let output = work_dir.run_jj([ |
| 2657 |
"bookmark", |
| 2658 |
"create", |
| 2659 |
"bookmark-2", |
| 2660 |
"-r", |
| 2661 |
"bookmark-2@origin", |
| 2662 |
]); |
| 2663 |
insta::assert_snapshot!(output, @" |
| 2664 |
------- stderr ------- |
| 2665 |
Created 1 bookmarks pointing to kulxwnxm e1a239a5 bookmark-2 bookmark-2@origin | Commit 5 |
| 2666 |
[EOF] |
| 2667 |
"); |
| 2668 |
let output = work_dir.run_jj(["op", "show"]); |
| 2669 |
insta::assert_snapshot!(output, @" |
| 2670 |
ce4b2e34b24c [email protected] default@ 2001-02-03 04:05:21.000 +07:00 - 2001-02-03 04:05:21.000 +07:00 |
| 2671 |
create bookmark bookmark-2 pointing to commit e1a239a57eb15cefc5910198befbbbe2b43c47af |
| 2672 |
args: jj bookmark create bookmark-2 -r bookmark-2@origin |
| 2673 |
|
| 2674 |
Changed local bookmarks: |
| 2675 |
bookmark-2: |
| 2676 |
+ kulxwnxm e1a239a5 bookmark-2 bookmark-2@origin | Commit 5 |
| 2677 |
- (absent) |
| 2678 |
[EOF] |
| 2679 |
"); |
| 2680 |
|
| 2681 |
// Test tracking of a bookmark. |
| 2682 |
let output = work_dir.run_jj(["bookmark", "track", "bookmark-2"]); |
| 2683 |
insta::assert_snapshot!(output, @" |
| 2684 |
------- stderr ------- |
| 2685 |
Started tracking 1 remote bookmarks. |
| 2686 |
[EOF] |
| 2687 |
"); |
| 2688 |
let output = work_dir.run_jj(["op", "show"]); |
| 2689 |
insta::assert_snapshot!(output, @" |
| 2690 |
07b2b85e64f5 [email protected] default@ 2001-02-03 04:05:23.000 +07:00 - 2001-02-03 04:05:23.000 +07:00 |
| 2691 |
track remote bookmark bookmark-2@origin |
| 2692 |
args: jj bookmark track bookmark-2 |
| 2693 |
|
| 2694 |
Changed remote bookmarks: |
| 2695 |
bookmark-2@origin: |
| 2696 |
+ tracked kulxwnxm e1a239a5 bookmark-2 | Commit 5 |
| 2697 |
- untracked kulxwnxm e1a239a5 bookmark-2 | Commit 5 |
| 2698 |
[EOF] |
| 2699 |
"); |
| 2700 |
|
| 2701 |
// Test creation of new commit. |
| 2702 |
let output = work_dir.run_jj(["bookmark", "track", "bookmark-2"]); |
| 2703 |
insta::assert_snapshot!(output, @" |
| 2704 |
------- stderr ------- |
| 2705 |
Warning: Remote bookmark already tracked: bookmark-2@origin |
| 2706 |
Nothing changed. |
| 2707 |
[EOF] |
| 2708 |
"); |
| 2709 |
let output = work_dir.run_jj(["op", "show"]); |
| 2710 |
insta::assert_snapshot!(output, @" |
| 2711 |
07b2b85e64f5 [email protected] default@ 2001-02-03 04:05:23.000 +07:00 - 2001-02-03 04:05:23.000 +07:00 |
| 2712 |
track remote bookmark bookmark-2@origin |
| 2713 |
args: jj bookmark track bookmark-2 |
| 2714 |
|
| 2715 |
Changed remote bookmarks: |
| 2716 |
bookmark-2@origin: |
| 2717 |
+ tracked kulxwnxm e1a239a5 bookmark-2 | Commit 5 |
| 2718 |
- untracked kulxwnxm e1a239a5 bookmark-2 | Commit 5 |
| 2719 |
[EOF] |
| 2720 |
"); |
| 2721 |
|
| 2722 |
// Test creation of new commit. |
| 2723 |
let output = work_dir.run_jj(["new", "bookmark-1@origin", "-m", "new commit"]); |
| 2724 |
insta::assert_snapshot!(output, @" |
| 2725 |
------- stderr ------- |
| 2726 |
Working copy (@) now at: tlkvzzqu 8f340dd7 (empty) new commit |
| 2727 |
Parent commit (@-) : zkmtkqvo 0dee6313 bookmark-1?? bookmark-1@origin | Commit 4 |
| 2728 |
Added 2 files, modified 0 files, removed 0 files |
| 2729 |
[EOF] |
| 2730 |
"); |
| 2731 |
let output = work_dir.run_jj(["op", "show"]); |
| 2732 |
insta::assert_snapshot!(output, @" |
| 2733 |
56bd9e4967d5 [email protected] default@ 2001-02-03 04:05:27.000 +07:00 - 2001-02-03 04:05:27.000 +07:00 |
| 2734 |
new empty commit |
| 2735 |
args: jj new bookmark-1@origin -m 'new commit' |
| 2736 |
|
| 2737 |
Changed commits: |
| 2738 |
○ + tlkvzzqu 8f340dd7 (empty) new commit |
| 2739 |
○ - qpvuntsm/0 e8849ae1 (hidden) (empty) (no description set) |
| 2740 |
|
| 2741 |
Changed working copy default@: |
| 2742 |
+ tlkvzzqu 8f340dd7 (empty) new commit |
| 2743 |
- qpvuntsm/0 e8849ae1 (hidden) (empty) (no description set) |
| 2744 |
[EOF] |
| 2745 |
"); |
| 2746 |
|
| 2747 |
// Test updating of local bookmark. |
| 2748 |
let output = work_dir.run_jj(["bookmark", "set", "bookmark-1", "-r", "@"]); |
| 2749 |
insta::assert_snapshot!(output, @" |
| 2750 |
------- stderr ------- |
| 2751 |
Moved 1 bookmarks to tlkvzzqu 8f340dd7 bookmark-1* | (empty) new commit |
| 2752 |
[EOF] |
| 2753 |
"); |
| 2754 |
let output = work_dir.run_jj(["op", "show"]); |
| 2755 |
insta::assert_snapshot!(output, @" |
| 2756 |
3ed3cc92cf58 [email protected] default@ 2001-02-03 04:05:29.000 +07:00 - 2001-02-03 04:05:29.000 +07:00 |
| 2757 |
point bookmark bookmark-1 to commit 8f340dd76dc637e4deac17f30056eef7d8eaf682 |
| 2758 |
args: jj bookmark set bookmark-1 -r @ |
| 2759 |
|
| 2760 |
Changed local bookmarks: |
| 2761 |
bookmark-1: |
| 2762 |
+ tlkvzzqu 8f340dd7 bookmark-1* | (empty) new commit |
| 2763 |
- (added) zkmtkqvo 0dee6313 bookmark-1@origin | Commit 4 |
| 2764 |
- (added) rnnslrkn 4ff62539 Commit 2 |
| 2765 |
[EOF] |
| 2766 |
"); |
| 2767 |
|
| 2768 |
// Test deletion of local bookmark. |
| 2769 |
let output = work_dir.run_jj(["bookmark", "delete", "bookmark-2"]); |
| 2770 |
insta::assert_snapshot!(output, @" |
| 2771 |
------- stderr ------- |
| 2772 |
Deleted 1 bookmarks. |
| 2773 |
[EOF] |
| 2774 |
"); |
| 2775 |
let output = work_dir.run_jj(["op", "show"]); |
| 2776 |
insta::assert_snapshot!(output, @" |
| 2777 |
82f0716300b2 [email protected] default@ 2001-02-03 04:05:31.000 +07:00 - 2001-02-03 04:05:31.000 +07:00 |
| 2778 |
delete bookmark bookmark-2 |
| 2779 |
args: jj bookmark delete bookmark-2 |
| 2780 |
|
| 2781 |
Changed local bookmarks: |
| 2782 |
bookmark-2: |
| 2783 |
+ (absent) |
| 2784 |
- kulxwnxm e1a239a5 bookmark-2@origin | Commit 5 |
| 2785 |
[EOF] |
| 2786 |
"); |
| 2787 |
|
| 2788 |
// Test pushing to Git remote. |
| 2789 |
let output = work_dir.run_jj(["git", "push", "--tracked", "--deleted"]); |
| 2790 |
insta::assert_snapshot!(output, @" |
| 2791 |
------- stderr ------- |
| 2792 |
Changes to push to origin: |
| 2793 |
bookmark: bookmark-1 [move forward from 0dee631320b1 to 8f340dd76dc6] |
| 2794 |
bookmark: bookmark-2 [delete from e1a239a57eb1] |
| 2795 |
[EOF] |
| 2796 |
"); |
| 2797 |
let output = work_dir.run_jj(["op", "show"]); |
| 2798 |
insta::assert_snapshot!(output, @" |
| 2799 |
ef37121543ef [email protected] default@ 2001-02-03 04:05:33.000 +07:00 - 2001-02-03 04:05:33.000 +07:00 |
| 2800 |
push all tracked bookmarks/tags to git remote origin |
| 2801 |
args: jj git push --tracked --deleted |
| 2802 |
|
| 2803 |
Changed remote bookmarks: |
| 2804 |
bookmark-1@origin: |
| 2805 |
+ tracked tlkvzzqu 8f340dd7 bookmark-1 | (empty) new commit |
| 2806 |
- tracked zkmtkqvo 0dee6313 Commit 4 |
| 2807 |
bookmark-2@origin: |
| 2808 |
+ untracked (absent) |
| 2809 |
- tracked kulxwnxm e1a239a5 Commit 5 |
| 2810 |
[EOF] |
| 2811 |
"); |
| 2812 |
|
| 2813 |
// Showing a given operation, without graph |
| 2814 |
let output = work_dir.run_jj(["op", "show", "--no-graph", "56bd9e4967d5"]); |
| 2815 |
insta::assert_snapshot!(output, @" |
| 2816 |
56bd9e4967d5 [email protected] default@ 2001-02-03 04:05:27.000 +07:00 - 2001-02-03 04:05:27.000 +07:00 |
| 2817 |
new empty commit |
| 2818 |
args: jj new bookmark-1@origin -m 'new commit' |
| 2819 |
|
| 2820 |
Changed commits: |
| 2821 |
+ tlkvzzqu 8f340dd7 (empty) new commit |
| 2822 |
- qpvuntsm/0 e8849ae1 (hidden) (empty) (no description set) |
| 2823 |
|
| 2824 |
Changed working copy default@: |
| 2825 |
+ tlkvzzqu 8f340dd7 (empty) new commit |
| 2826 |
- qpvuntsm/0 e8849ae1 (hidden) (empty) (no description set) |
| 2827 |
[EOF] |
| 2828 |
"); |
| 2829 |
} |
| 2830 |
|
| 2831 |
#[test] |
| 2832 |
fn test_op_show_patch() { |
| 2833 |
let test_env = TestEnvironment::default(); |
| 2834 |
test_env.run_jj_in(".", ["git", "init", "repo"]).success(); |
| 2835 |
let work_dir = test_env.work_dir("repo"); |
| 2836 |
|
| 2837 |
// Update working copy with a single file and create new commit. |
| 2838 |
work_dir.write_file("file", "a\n"); |
| 2839 |
let output = work_dir.run_jj(["new"]); |
| 2840 |
insta::assert_snapshot!(output, @" |
| 2841 |
------- stderr ------- |
| 2842 |
Working copy (@) now at: rlvkpnrz c1c924b8 (empty) (no description set) |
| 2843 |
Parent commit (@-) : qpvuntsm 6b57e33c (no description set) |
| 2844 |
[EOF] |
| 2845 |
"); |
| 2846 |
let output = work_dir.run_jj(["op", "show", "@-", "-p", "--git"]); |
| 2847 |
insta::assert_snapshot!(output, @" |
| 2848 |
494872ff8b1e [email protected] default@ 2001-02-03 04:05:08.000 +07:00 - 2001-02-03 04:05:08.000 +07:00 |
| 2849 |
snapshot working copy |
| 2850 |
args: jj new |
| 2851 |
|
| 2852 |
Changed commits: |
| 2853 |
○ + qpvuntsm 6b57e33c (no description set) |
| 2854 |
- qpvuntsm/1 e8849ae1 (hidden) (empty) (no description set) |
| 2855 |
diff --git a/file b/file |
| 2856 |
new file mode 100644 |
| 2857 |
index 0000000000..7898192261 |
| 2858 |
--- /dev/null |
| 2859 |
+++ b/file |
| 2860 |
@@ -0,0 +1,1 @@ |
| 2861 |
+a |
| 2862 |
|
| 2863 |
Changed working copy default@: |
| 2864 |
+ qpvuntsm 6b57e33c (no description set) |
| 2865 |
- qpvuntsm/1 e8849ae1 (hidden) (empty) (no description set) |
| 2866 |
[EOF] |
| 2867 |
"); |
| 2868 |
let output = work_dir.run_jj(["op", "show", "@", "-p", "--git"]); |
| 2869 |
insta::assert_snapshot!(output, @" |
| 2870 |
eb50f4ba33f8 [email protected] default@ 2001-02-03 04:05:08.000 +07:00 - 2001-02-03 04:05:08.000 +07:00 |
| 2871 |
new empty commit |
| 2872 |
args: jj new |
| 2873 |
|
| 2874 |
Changed commits: |
| 2875 |
○ + rlvkpnrz c1c924b8 (empty) (no description set) |
| 2876 |
|
| 2877 |
Changed working copy default@: |
| 2878 |
+ rlvkpnrz c1c924b8 (empty) (no description set) |
| 2879 |
- qpvuntsm 6b57e33c (no description set) |
| 2880 |
[EOF] |
| 2881 |
"); |
| 2882 |
|
| 2883 |
// Squash the working copy commit. |
| 2884 |
work_dir.write_file("file", "b\n"); |
| 2885 |
let output = work_dir.run_jj(["squash"]); |
| 2886 |
insta::assert_snapshot!(output, @" |
| 2887 |
------- stderr ------- |
| 2888 |
Working copy (@) now at: mzvwutvl 6cbd01ae (empty) (no description set) |
| 2889 |
Parent commit (@-) : qpvuntsm 7aa2ec5d (no description set) |
| 2890 |
[EOF] |
| 2891 |
"); |
| 2892 |
let output = work_dir.run_jj(["op", "show", "-p", "--git"]); |
| 2893 |
insta::assert_snapshot!(output, @" |
| 2894 |
f8b489c34565 [email protected] default@ 2001-02-03 04:05:11.000 +07:00 - 2001-02-03 04:05:11.000 +07:00 |
| 2895 |
squash commits into 6b57e33cc56babbeaa6bcd6e2a296236b52ad93c |
| 2896 |
args: jj squash |
| 2897 |
|
| 2898 |
Changed commits: |
| 2899 |
○ + mzvwutvl 6cbd01ae (empty) (no description set) |
| 2900 |
○ + qpvuntsm 7aa2ec5d (no description set) |
| 2901 |
- qpvuntsm/1 6b57e33c (hidden) (no description set) |
| 2902 |
- rlvkpnrz/0 05a2969e (hidden) (no description set) |
| 2903 |
diff --git a/file b/file |
| 2904 |
index 7898192261..6178079822 100644 |
| 2905 |
--- a/file |
| 2906 |
+++ b/file |
| 2907 |
@@ -1,1 +1,1 @@ |
| 2908 |
-a |
| 2909 |
+b |
| 2910 |
|
| 2911 |
Changed working copy default@: |
| 2912 |
+ mzvwutvl 6cbd01ae (empty) (no description set) |
| 2913 |
- rlvkpnrz/0 05a2969e (hidden) (no description set) |
| 2914 |
[EOF] |
| 2915 |
"); |
| 2916 |
|
| 2917 |
// Abandon the working copy commit. |
| 2918 |
let output = work_dir.run_jj(["abandon"]); |
| 2919 |
insta::assert_snapshot!(output, @" |
| 2920 |
------- stderr ------- |
| 2921 |
Abandoned 1 commits: |
| 2922 |
mzvwutvl 6cbd01ae (empty) (no description set) |
| 2923 |
Working copy (@) now at: yqosqzyt c97a8573 (empty) (no description set) |
| 2924 |
Parent commit (@-) : qpvuntsm 7aa2ec5d (no description set) |
| 2925 |
[EOF] |
| 2926 |
"); |
| 2927 |
let output = work_dir.run_jj(["op", "show", "-p", "--git"]); |
| 2928 |
insta::assert_snapshot!(output, @" |
| 2929 |
cad7943bb3ae [email protected] default@ 2001-02-03 04:05:13.000 +07:00 - 2001-02-03 04:05:13.000 +07:00 |
| 2930 |
abandon commit 6cbd01aefe5ae05a015328311dbd63b7305b8ebe |
| 2931 |
args: jj abandon |
| 2932 |
|
| 2933 |
Changed commits: |
| 2934 |
○ + yqosqzyt c97a8573 (empty) (no description set) |
| 2935 |
○ - mzvwutvl/0 6cbd01ae (hidden) (empty) (no description set) |
| 2936 |
|
| 2937 |
Changed working copy default@: |
| 2938 |
+ yqosqzyt c97a8573 (empty) (no description set) |
| 2939 |
- mzvwutvl/0 6cbd01ae (hidden) (empty) (no description set) |
| 2940 |
[EOF] |
| 2941 |
"); |
| 2942 |
|
| 2943 |
// Try again with "op log". |
| 2944 |
let output = work_dir.run_jj(["op", "log", "--git"]); |
| 2945 |
insta::assert_snapshot!(output, @" |
| 2946 |
@ cad7943bb3ae [email protected] default@ 2001-02-03 04:05:13.000 +07:00 - 2001-02-03 04:05:13.000 +07:00 |
| 2947 |
│ abandon commit 6cbd01aefe5ae05a015328311dbd63b7305b8ebe |
| 2948 |
│ args: jj abandon |
| 2949 |
│ |
| 2950 |
│ Changed commits: |
| 2951 |
│ ○ + yqosqzyt c97a8573 (empty) (no description set) |
| 2952 |
│ ○ - mzvwutvl/0 6cbd01ae (hidden) (empty) (no description set) |
| 2953 |
│ |
| 2954 |
│ Changed working copy default@: |
| 2955 |
│ + yqosqzyt c97a8573 (empty) (no description set) |
| 2956 |
│ - mzvwutvl/0 6cbd01ae (hidden) (empty) (no description set) |
| 2957 |
○ f8b489c34565 [email protected] default@ 2001-02-03 04:05:11.000 +07:00 - 2001-02-03 04:05:11.000 +07:00 |
| 2958 |
│ squash commits into 6b57e33cc56babbeaa6bcd6e2a296236b52ad93c |
| 2959 |
│ args: jj squash |
| 2960 |
│ |
| 2961 |
│ Changed commits: |
| 2962 |
│ ○ + mzvwutvl 6cbd01ae (empty) (no description set) |
| 2963 |
│ ○ + qpvuntsm 7aa2ec5d (no description set) |
| 2964 |
│ - qpvuntsm/1 6b57e33c (hidden) (no description set) |
| 2965 |
│ - rlvkpnrz/0 05a2969e (hidden) (no description set) |
| 2966 |
│ diff --git a/file b/file |
| 2967 |
│ index 7898192261..6178079822 100644 |
| 2968 |
│ --- a/file |
| 2969 |
│ +++ b/file |
| 2970 |
│ @@ -1,1 +1,1 @@ |
| 2971 |
│ -a |
| 2972 |
│ +b |
| 2973 |
│ |
| 2974 |
│ Changed working copy default@: |
| 2975 |
│ + mzvwutvl 6cbd01ae (empty) (no description set) |
| 2976 |
│ - rlvkpnrz/0 05a2969e (hidden) (no description set) |
| 2977 |
○ 5a7a78e63d4a [email protected] default@ 2001-02-03 04:05:11.000 +07:00 - 2001-02-03 04:05:11.000 +07:00 |
| 2978 |
│ snapshot working copy |
| 2979 |
│ args: jj squash |
| 2980 |
│ |
| 2981 |
│ Changed commits: |
| 2982 |
│ ○ + rlvkpnrz 05a2969e (no description set) |
| 2983 |
│ - rlvkpnrz/1 c1c924b8 (hidden) (empty) (no description set) |
| 2984 |
│ diff --git a/file b/file |
| 2985 |
│ index 7898192261..6178079822 100644 |
| 2986 |
│ --- a/file |
| 2987 |
│ +++ b/file |
| 2988 |
│ @@ -1,1 +1,1 @@ |
| 2989 |
│ -a |
| 2990 |
│ +b |
| 2991 |
│ |
| 2992 |
│ Changed working copy default@: |
| 2993 |
│ + rlvkpnrz 05a2969e (no description set) |
| 2994 |
│ - rlvkpnrz/1 c1c924b8 (hidden) (empty) (no description set) |
| 2995 |
○ eb50f4ba33f8 [email protected] default@ 2001-02-03 04:05:08.000 +07:00 - 2001-02-03 04:05:08.000 +07:00 |
| 2996 |
│ new empty commit |
| 2997 |
│ args: jj new |
| 2998 |
│ |
| 2999 |
│ Changed commits: |
| 3000 |
│ ○ + rlvkpnrz c1c924b8 (empty) (no description set) |
| 3001 |
│ |
| 3002 |
│ Changed working copy default@: |
| 3003 |
│ + rlvkpnrz c1c924b8 (empty) (no description set) |
| 3004 |
│ - qpvuntsm 6b57e33c (no description set) |
| 3005 |
○ 494872ff8b1e [email protected] default@ 2001-02-03 04:05:08.000 +07:00 - 2001-02-03 04:05:08.000 +07:00 |
| 3006 |
│ snapshot working copy |
| 3007 |
│ args: jj new |
| 3008 |
│ |
| 3009 |
│ Changed commits: |
| 3010 |
│ ○ + qpvuntsm 6b57e33c (no description set) |
| 3011 |
│ - qpvuntsm/1 e8849ae1 (hidden) (empty) (no description set) |
| 3012 |
│ diff --git a/file b/file |
| 3013 |
│ new file mode 100644 |
| 3014 |
│ index 0000000000..7898192261 |
| 3015 |
│ --- /dev/null |
| 3016 |
│ +++ b/file |
| 3017 |
│ @@ -0,0 +1,1 @@ |
| 3018 |
│ +a |
| 3019 |
│ |
| 3020 |
│ Changed working copy default@: |
| 3021 |
│ + qpvuntsm 6b57e33c (no description set) |
| 3022 |
│ - qpvuntsm/1 e8849ae1 (hidden) (empty) (no description set) |
| 3023 |
○ f63ee16f9553 [email protected] 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00 |
| 3024 |
│ add workspace 'default' |
| 3025 |
│ |
| 3026 |
│ Changed commits: |
| 3027 |
│ ○ + qpvuntsm e8849ae1 (empty) (no description set) |
| 3028 |
│ |
| 3029 |
│ Changed working copy default@: |
| 3030 |
│ + qpvuntsm e8849ae1 (empty) (no description set) |
| 3031 |
│ - (absent) |
| 3032 |
○ 000000000000 root() |
| 3033 |
[EOF] |
| 3034 |
"); |
| 3035 |
} |
| 3036 |
|
| 3037 |
#[test] |
| 3038 |
fn test_op_show_template() { |
| 3039 |
let test_env = TestEnvironment::default(); |
| 3040 |
test_env.run_jj_in(".", ["git", "init", "repo"]).success(); |
| 3041 |
let work_dir = test_env.work_dir("repo"); |
| 3042 |
|
| 3043 |
work_dir.write_file("file", "content\n"); |
| 3044 |
work_dir.run_jj(["commit", "-m", "first commit"]).success(); |
| 3045 |
|
| 3046 |
// Test with custom template |
| 3047 |
let output = work_dir.run_jj([ |
| 3048 |
"op", |
| 3049 |
"show", |
| 3050 |
"-T", |
| 3051 |
r#"separate(" ", id.short(), description)"#, |
| 3052 |
"--no-op-diff", |
| 3053 |
]); |
| 3054 |
insta::assert_snapshot!(output, @"22e6b90c70c1 commit 0883ea507656cce545dbba9f23760ff72dff5174[EOF]"); |
| 3055 |
|
| 3056 |
// Test --no-op-diff flag suppresses the diff |
| 3057 |
let output = work_dir.run_jj(["op", "show", "--no-op-diff"]); |
| 3058 |
insta::assert_snapshot!(output, @" |
| 3059 |
22e6b90c70c1 [email protected] default@ 2001-02-03 04:05:08.000 +07:00 - 2001-02-03 04:05:08.000 +07:00 |
| 3060 |
commit 0883ea507656cce545dbba9f23760ff72dff5174 |
| 3061 |
args: jj commit -m 'first commit' |
| 3062 |
[EOF] |
| 3063 |
"); |
| 3064 |
|
| 3065 |
// Test with custom template, without --no-op-diff |
| 3066 |
let output = work_dir.run_jj([ |
| 3067 |
"op", |
| 3068 |
"show", |
| 3069 |
"-T", |
| 3070 |
r#"separate(" ", id.short(), description)"#, |
| 3071 |
]); |
| 3072 |
insta::assert_snapshot!(output, @" |
| 3073 |
22e6b90c70c1 commit 0883ea507656cce545dbba9f23760ff72dff5174 |
| 3074 |
Changed commits: |
| 3075 |
○ + rlvkpnrz e4863b8c (empty) (no description set) |
| 3076 |
○ + qpvuntsm b52b7cb5 first commit |
| 3077 |
- qpvuntsm/1 0883ea50 (hidden) (no description set) |
| 3078 |
|
| 3079 |
Changed working copy default@: |
| 3080 |
+ rlvkpnrz e4863b8c (empty) (no description set) |
| 3081 |
- qpvuntsm/1 0883ea50 (hidden) (no description set) |
| 3082 |
[EOF] |
| 3083 |
"); |
| 3084 |
} |
| 3085 |
|
| 3086 |
#[test] |
| 3087 |
fn test_op_log_parents() { |
| 3088 |
let test_env = TestEnvironment::default(); |
| 3089 |
test_env.run_jj_in(".", ["git", "init", "repo"]).success(); |
| 3090 |
let work_dir = test_env.work_dir("repo"); |
| 3091 |
work_dir |
| 3092 |
.run_jj(["describe", "-m", "description 0"]) |
| 3093 |
.success(); |
| 3094 |
|
| 3095 |
work_dir |
| 3096 |
.run_jj(["describe", "-m", "description 1", "--at-op", "@-"]) |
| 3097 |
.success(); |
| 3098 |
let template = r#"id.short() ++ "\nP: " ++ parents.len() ++ " " ++ parents.map(|o| o.id().short()) ++ "\n""#; |
| 3099 |
let output = work_dir.run_jj(["op", "log", "-T", template]); |
| 3100 |
insta::assert_snapshot!(output, @" |
| 3101 |
@ 7f1c9ff8575c |
| 3102 |
├─╮ P: 2 7749eb4df93f 3cb69b18c151 |
| 3103 |
○ │ 7749eb4df93f |
| 3104 |
│ │ P: 1 f63ee16f9553 |
| 3105 |
│ ○ 3cb69b18c151 |
| 3106 |
├─╯ P: 1 f63ee16f9553 |
| 3107 |
○ f63ee16f9553 |
| 3108 |
│ P: 1 000000000000 |
| 3109 |
○ 000000000000 |
| 3110 |
P: 0 |
| 3111 |
[EOF] |
| 3112 |
------- stderr ------- |
| 3113 |
Concurrent modification detected, resolving automatically. |
| 3114 |
[EOF] |
| 3115 |
"); |
| 3116 |
} |
| 3117 |
|
| 3118 |
#[test] |
| 3119 |
fn test_op_log_anonymize() { |
| 3120 |
let test_env = TestEnvironment::default(); |
| 3121 |
test_env.run_jj_in(".", ["git", "init", "repo"]).success(); |
| 3122 |
let work_dir = test_env.work_dir("repo"); |
| 3123 |
work_dir |
| 3124 |
.run_jj(["describe", "-m", "description 0"]) |
| 3125 |
.success(); |
| 3126 |
|
| 3127 |
let output = work_dir.run_jj(["op", "log", "-Tbuiltin_op_log_redacted"]); |
| 3128 |
insta::assert_snapshot!(output, @" |
| 3129 |
@ 7749eb4df93f user-5910 workspace-ab88@ 2001-02-03 04:05:08.000 +07:00 - 2001-02-03 04:05:08.000 +07:00 |
| 3130 |
│ describe commit e8849ae12c709f2321908879bc724fdb2ab8a781 |
| 3131 |
│ (redacted) |
| 3132 |
○ f63ee16f9553 user-5910 workspace-482a@ 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00 |
| 3133 |
│ add workspace 'default' |
| 3134 |
○ 000000000000 root() |
| 3135 |
[EOF] |
| 3136 |
"); |
| 3137 |
} |
| 3138 |
|
| 3139 |
#[test] |
| 3140 |
fn test_op_immutable_revisions() { |
| 3141 |
let test_env = TestEnvironment::default(); |
| 3142 |
test_env.run_jj_in(".", ["git", "init", "repo"]).success(); |
| 3143 |
let work_dir = test_env.work_dir("repo"); |
| 3144 |
test_env.add_config(r#"revset-aliases."immutable_heads()" = "tags() | bookmarks()""#); |
| 3145 |
test_env.add_config(r#"revsets.op-diff-changes-in = "mutable() | immutable_heads()""#); |
| 3146 |
|
| 3147 |
// 1. Basic addition and removal elision |
| 3148 |
// Create a stack of 5 commits, all immutable. |
| 3149 |
for i in 1..=5 { |
| 3150 |
work_dir |
| 3151 |
.run_jj(["new", "@", "-m", &format!("commit {i}")]) |
| 3152 |
.success(); |
| 3153 |
} |
| 3154 |
work_dir.run_jj(["new"]).success(); |
| 3155 |
work_dir.run_jj(["tag", "set", "t1", "-r", "@-"]).success(); |
| 3156 |
|
| 3157 |
// Move working copy away |
| 3158 |
work_dir.run_jj(["new", "root()"]).success(); |
| 3159 |
|
| 3160 |
// Abandon the immutable stack |
| 3161 |
work_dir |
| 3162 |
.run_jj(["abandon", "--ignore-immutable", "::t1 & ~root()"]) |
| 3163 |
.success(); |
| 3164 |
insta::assert_snapshot!(work_dir.run_jj(["op", "show"]), @" |
| 3165 |
57739a739904 [email protected] default@ 2001-02-03 04:05:16.000 +07:00 - 2001-02-03 04:05:16.000 +07:00 |
| 3166 |
abandon commit 9c86781f3fe9097ffc530e65fd2ab4aff1e654bd and 5 more |
| 3167 |
args: jj abandon --ignore-immutable '::t1 & ~root()' |
| 3168 |
|
| 3169 |
Changed commits: |
| 3170 |
○ - royxmykx/0 9c86781f (hidden) (empty) commit 5 |
| 3171 |
(Elided 5 newly removed revisions) |
| 3172 |
[EOF] |
| 3173 |
"); |
| 3174 |
|
| 3175 |
// Undo |
| 3176 |
work_dir.run_jj(["op", "revert"]).success(); |
| 3177 |
insta::assert_snapshot!(work_dir.run_jj(["op", "show"]), @" |
| 3178 |
d5b2b3f52ef8 [email protected] default@ 2001-02-03 04:05:18.000 +07:00 - 2001-02-03 04:05:18.000 +07:00 |
| 3179 |
revert operation 57739a7399047ab60f9bf4aedcf1c604e868abd0f33795f7e18f99b86acb5fd8549c852fb49eb18f8c85fcfb4784e95161f2d9efc24b01c603f468a52689405f |
| 3180 |
args: jj op revert |
| 3181 |
|
| 3182 |
Changed commits: |
| 3183 |
○ + royxmykx 9c86781f (empty) commit 5 |
| 3184 |
(Elided 5 newly added revisions) |
| 3185 |
[EOF] |
| 3186 |
"); |
| 3187 |
|
| 3188 |
// 2. Multiple branches elision |
| 3189 |
work_dir.run_jj(["new", "t1", "-m", "f1 1"]).success(); |
| 3190 |
work_dir.run_jj(["new", "@", "-m", "f1 2"]).success(); |
| 3191 |
work_dir.run_jj(["new", "@", "-m", "f1 3"]).success(); |
| 3192 |
work_dir.run_jj(["new"]).success(); |
| 3193 |
work_dir.run_jj(["tag", "set", "f1", "-r", "@-"]).success(); |
| 3194 |
|
| 3195 |
work_dir.run_jj(["new", "t1", "-m", "f2 1"]).success(); |
| 3196 |
work_dir.run_jj(["new", "@", "-m", "f2 2"]).success(); |
| 3197 |
work_dir.run_jj(["new", "@", "-m", "f2 3"]).success(); |
| 3198 |
work_dir.run_jj(["new"]).success(); |
| 3199 |
work_dir.run_jj(["tag", "set", "f2", "-r", "@-"]).success(); |
| 3200 |
|
| 3201 |
// Move WC away |
| 3202 |
work_dir.run_jj(["new", "root()"]).success(); |
| 3203 |
|
| 3204 |
// Abandon both chains |
| 3205 |
work_dir |
| 3206 |
.run_jj(["abandon", "--ignore-immutable", "(::f1 | ::f2) & ~root()"]) |
| 3207 |
.success(); |
| 3208 |
let op_id_for_diff = work_dir.current_operation_id(); |
| 3209 |
insta::assert_snapshot!(work_dir.run_jj(["op", "show"]), @" |
| 3210 |
a3d69d664845 [email protected] default@ 2001-02-03 04:05:31.000 +07:00 - 2001-02-03 04:05:31.000 +07:00 |
| 3211 |
abandon commit 7c60d8fd187f77196d1def564b0d893d477b7e56 and 11 more |
| 3212 |
args: jj abandon --ignore-immutable '(::f1 | ::f2) & ~root()' |
| 3213 |
|
| 3214 |
Changed commits: |
| 3215 |
○ - tlkvzzqu/0 7c60d8fd (hidden) (empty) f2 3 |
| 3216 |
╷ ○ - nkmrtpmo/0 caf991b6 (hidden) (empty) f1 3 |
| 3217 |
╭─╯ |
| 3218 |
○ - royxmykx/0 9c86781f (hidden) (empty) commit 5 |
| 3219 |
(Elided 9 newly removed revisions) |
| 3220 |
[EOF] |
| 3221 |
"); |
| 3222 |
|
| 3223 |
// Use `--show-changes-in none()` to see only elisions |
| 3224 |
insta::assert_snapshot!(work_dir.run_jj(["op", "show", "--show-changes-in", "none()"]), @" |
| 3225 |
a3d69d664845 [email protected] default@ 2001-02-03 04:05:31.000 +07:00 - 2001-02-03 04:05:31.000 +07:00 |
| 3226 |
abandon commit 7c60d8fd187f77196d1def564b0d893d477b7e56 and 11 more |
| 3227 |
args: jj abandon --ignore-immutable '(::f1 | ::f2) & ~root()' |
| 3228 |
|
| 3229 |
Changed commits: |
| 3230 |
(Elided 10+ newly removed revisions) |
| 3231 |
[EOF] |
| 3232 |
"); |
| 3233 |
|
| 3234 |
// 3. Case where both added and removed immutable revisions are elided. |
| 3235 |
work_dir.run_jj(["new", "root()", "-m", "mix-a1"]).success(); |
| 3236 |
for i in 2..=5 { |
| 3237 |
work_dir |
| 3238 |
.run_jj(["new", "@", "-m", &format!("mix-a{i}")]) |
| 3239 |
.success(); |
| 3240 |
} |
| 3241 |
work_dir.run_jj(["new"]).success(); |
| 3242 |
work_dir |
| 3243 |
.run_jj(["bookmark", "set", "ba", "-r", "@-"]) |
| 3244 |
.success(); |
| 3245 |
|
| 3246 |
work_dir.run_jj(["new", "root()", "-m", "mix-b1"]).success(); |
| 3247 |
for i in 2..=5 { |
| 3248 |
work_dir |
| 3249 |
.run_jj(["new", "@", "-m", &format!("mix-b{i}")]) |
| 3250 |
.success(); |
| 3251 |
} |
| 3252 |
work_dir.run_jj(["new"]).success(); |
| 3253 |
work_dir |
| 3254 |
.run_jj(["bookmark", "set", "bb", "-r", "@-"]) |
| 3255 |
.success(); |
| 3256 |
|
| 3257 |
// Rebase bb chain onto ba head. |
| 3258 |
work_dir |
| 3259 |
.run_jj(["rebase", "--ignore-immutable", "-s", "bb----", "-d", "ba"]) |
| 3260 |
.success(); |
| 3261 |
insta::assert_snapshot!(work_dir.run_jj(["op", "show"]), @" |
| 3262 |
e92cd1c233e5 [email protected] default@ 2001-02-03 04:05:48.000 +07:00 - 2001-02-03 04:05:48.000 +07:00 |
| 3263 |
rebase commit 6c3a9c2476ba8a8e5bac722f9c0e2ca914b9577d and descendants |
| 3264 |
args: jj rebase --ignore-immutable -s bb---- -d ba |
| 3265 |
|
| 3266 |
Changed commits: |
| 3267 |
○ + wtlqussy bf3146c8 (empty) (no description set) |
| 3268 |
│ - wtlqussy/1 371fd4fe (hidden) (empty) (no description set) |
| 3269 |
○ + xpnwykqz 741a5187 bb | (empty) mix-b5 |
| 3270 |
- xpnwykqz/1 1c52a7a2 (hidden) (empty) mix-b5 |
| 3271 |
(Elided 4 newly added and 4 newly removed revisions) |
| 3272 |
|
| 3273 |
Changed working copy default@: |
| 3274 |
+ wtlqussy bf3146c8 (empty) (no description set) |
| 3275 |
- wtlqussy/1 371fd4fe (hidden) (empty) (no description set) |
| 3276 |
|
| 3277 |
Changed local bookmarks: |
| 3278 |
bb: |
| 3279 |
+ xpnwykqz 741a5187 bb | (empty) mix-b5 |
| 3280 |
- xpnwykqz/1 1c52a7a2 (hidden) (empty) mix-b5 |
| 3281 |
[EOF] |
| 3282 |
"); |
| 3283 |
|
| 3284 |
// Use `--show-changes-in none()` to see only elisions |
| 3285 |
insta::assert_snapshot!(work_dir.run_jj(["op", "show", "--show-changes-in", "none()"]), @" |
| 3286 |
e92cd1c233e5 [email protected] default@ 2001-02-03 04:05:48.000 +07:00 - 2001-02-03 04:05:48.000 +07:00 |
| 3287 |
rebase commit 6c3a9c2476ba8a8e5bac722f9c0e2ca914b9577d and descendants |
| 3288 |
args: jj rebase --ignore-immutable -s bb---- -d ba |
| 3289 |
|
| 3290 |
Changed commits: |
| 3291 |
(Elided 6 newly added and 6 newly removed revisions) |
| 3292 |
|
| 3293 |
Changed working copy default@: |
| 3294 |
+ wtlqussy bf3146c8 (empty) (no description set) |
| 3295 |
- wtlqussy/1 371fd4fe (hidden) (empty) (no description set) |
| 3296 |
|
| 3297 |
Changed local bookmarks: |
| 3298 |
bb: |
| 3299 |
+ xpnwykqz 741a5187 bb | (empty) mix-b5 |
| 3300 |
- xpnwykqz/1 1c52a7a2 (hidden) (empty) mix-b5 |
| 3301 |
[EOF] |
| 3302 |
"); |
| 3303 |
|
| 3304 |
// 4. Case where exactly one immutable revision is elided (singular "revision") |
| 3305 |
work_dir |
| 3306 |
.run_jj(["new", "root()", "-m", "single-1"]) |
| 3307 |
.success(); |
| 3308 |
work_dir.run_jj(["new", "@", "-m", "single-2"]).success(); |
| 3309 |
work_dir.run_jj(["new"]).success(); |
| 3310 |
work_dir |
| 3311 |
.run_jj(["tag", "set", "ts", "-r", "@-", "--allow-move"]) |
| 3312 |
.success(); |
| 3313 |
// Abandon to see single removal elision |
| 3314 |
work_dir |
| 3315 |
.run_jj(["abandon", "--ignore-immutable", "::ts & ~root()"]) |
| 3316 |
.success(); |
| 3317 |
insta::assert_snapshot!(work_dir.run_jj(["op", "show"]), @" |
| 3318 |
95b73748d059 [email protected] default@ 2001-02-03 04:05:55.000 +07:00 - 2001-02-03 04:05:55.000 +07:00 |
| 3319 |
abandon commit 4ebd4aa1d0bfee524ccd21882606990e3b75fc12 and 1 more |
| 3320 |
args: jj abandon --ignore-immutable '::ts & ~root()' |
| 3321 |
|
| 3322 |
Changed commits: |
| 3323 |
○ + ztnvrxlv 41578768 (empty) (no description set) |
| 3324 |
- ztnvrxlv/1 13887367 (hidden) (empty) (no description set) |
| 3325 |
○ - wqxolloz/0 4ebd4aa1 (hidden) (empty) single-2 |
| 3326 |
(Elided 1 newly removed revisions) |
| 3327 |
|
| 3328 |
Changed working copy default@: |
| 3329 |
+ ztnvrxlv 41578768 (empty) (no description set) |
| 3330 |
- ztnvrxlv/1 13887367 (hidden) (empty) (no description set) |
| 3331 |
[EOF] |
| 3332 |
"); |
| 3333 |
|
| 3334 |
// Undo to see single addition elision |
| 3335 |
work_dir.run_jj(["op", "revert"]).success(); |
| 3336 |
insta::assert_snapshot!(work_dir.run_jj(["op", "show"]), @" |
| 3337 |
6efe5476f4ba [email protected] default@ 2001-02-03 04:05:57.000 +07:00 - 2001-02-03 04:05:57.000 +07:00 |
| 3338 |
revert operation 95b73748d0599916938dca69ee15ca6a483ff989edc9623a4de65da4059d6b80613dbaa61c24145b621886f1e8562d2a951de817a3ea2ae46a59ec40bc67e4ec |
| 3339 |
args: jj op revert |
| 3340 |
|
| 3341 |
Changed commits: |
| 3342 |
○ + ztnvrxlv 13887367 (empty) (no description set) |
| 3343 |
│ - ztnvrxlv/0 41578768 (hidden) (empty) (no description set) |
| 3344 |
○ + wqxolloz 4ebd4aa1 (empty) single-2 |
| 3345 |
(Elided 1 newly added revisions) |
| 3346 |
|
| 3347 |
Changed working copy default@: |
| 3348 |
+ ztnvrxlv 13887367 (empty) (no description set) |
| 3349 |
- ztnvrxlv/0 41578768 (hidden) (empty) (no description set) |
| 3350 |
[EOF] |
| 3351 |
"); |
| 3352 |
|
| 3353 |
// 5. op diff and op log tests |
| 3354 |
insta::assert_snapshot!(work_dir.run_jj(["op", "diff", "--from", &op_id_for_diff]), @" |
| 3355 |
From operation: a3d69d664845 (2001-02-03 08:05:31) abandon commit 7c60d8fd187f77196d1def564b0d893d477b7e56 and 11 more |
| 3356 |
To operation: 6efe5476f4ba (2001-02-03 08:05:57) revert operation 95b73748d0599916938dca69ee15ca6a483ff989edc9623a4de65da4059d6b80613dbaa61c24145b621886f1e8562d2a951de817a3ea2ae46a59ec40bc67e4ec |
| 3357 |
|
| 3358 |
Changed commits: |
| 3359 |
○ + ztnvrxlv 13887367 (empty) (no description set) |
| 3360 |
○ + wqxolloz 4ebd4aa1 (empty) single-2 |
| 3361 |
○ + xpnwykqz 741a5187 bb | (empty) mix-b5 |
| 3362 |
○ + zowrlwsv 5653a1de ba | (empty) mix-a5 |
| 3363 |
○ - pzsxstzt/0 8192fa83 (hidden) (empty) (no description set) |
| 3364 |
(Elided 9 newly added revisions) |
| 3365 |
|
| 3366 |
Changed working copy default@: |
| 3367 |
+ ztnvrxlv 13887367 (empty) (no description set) |
| 3368 |
- pzsxstzt/0 8192fa83 (hidden) (empty) (no description set) |
| 3369 |
|
| 3370 |
Changed local bookmarks: |
| 3371 |
ba: |
| 3372 |
+ zowrlwsv 5653a1de ba | (empty) mix-a5 |
| 3373 |
- (absent) |
| 3374 |
bb: |
| 3375 |
+ xpnwykqz 741a5187 bb | (empty) mix-b5 |
| 3376 |
- (absent) |
| 3377 |
|
| 3378 |
Changed local tags: |
| 3379 |
ts: |
| 3380 |
+ wqxolloz 4ebd4aa1 (empty) single-2 |
| 3381 |
- (absent) |
| 3382 |
[EOF] |
| 3383 |
"); |
| 3384 |
|
| 3385 |
insta::assert_snapshot!(work_dir.run_jj(["op", "log", "-p", "--limit", "1"]), @" |
| 3386 |
@ 6efe5476f4ba [email protected] default@ 2001-02-03 04:05:57.000 +07:00 - 2001-02-03 04:05:57.000 +07:00 |
| 3387 |
│ revert operation 95b73748d0599916938dca69ee15ca6a483ff989edc9623a4de65da4059d6b80613dbaa61c24145b621886f1e8562d2a951de817a3ea2ae46a59ec40bc67e4ec |
| 3388 |
│ args: jj op revert |
| 3389 |
│ |
| 3390 |
│ Changed commits: |
| 3391 |
│ ○ + ztnvrxlv 13887367 (empty) (no description set) |
| 3392 |
│ │ - ztnvrxlv/0 41578768 (hidden) (empty) (no description set) |
| 3393 |
│ ○ + wqxolloz 4ebd4aa1 (empty) single-2 |
| 3394 |
│ Modified commit description: |
| 3395 |
│ 1: single-2 |
| 3396 |
│ (Elided 1 newly added revisions) |
| 3397 |
│ |
| 3398 |
│ Changed working copy default@: |
| 3399 |
│ + ztnvrxlv 13887367 (empty) (no description set) |
| 3400 |
│ - ztnvrxlv/0 41578768 (hidden) (empty) (no description set) |
| 3401 |
[EOF] |
| 3402 |
"); |
| 3403 |
|
| 3404 |
// 6. Accuracy: Show local heads of affected set even if they have immutable |
| 3405 |
// descendants elsewhere (e.g. already hidden). |
| 3406 |
// root -> c1 -> c2 -> c3 (all immutable) |
| 3407 |
work_dir.run_jj(["new", "root()", "-m", "acc-c1"]).success(); |
| 3408 |
let c1_id = work_dir |
| 3409 |
.run_jj(["log", "-T", "commit_id", "-r", "@", "--no-graph"]) |
| 3410 |
.stdout |
| 3411 |
.raw() |
| 3412 |
.trim() |
| 3413 |
.to_string(); |
| 3414 |
work_dir.run_jj(["new", "@", "-m", "acc-c2"]).success(); |
| 3415 |
let c2_id = work_dir |
| 3416 |
.run_jj(["log", "-T", "commit_id", "-r", "@", "--no-graph"]) |
| 3417 |
.stdout |
| 3418 |
.raw() |
| 3419 |
.trim() |
| 3420 |
.to_string(); |
| 3421 |
work_dir.run_jj(["new", "@", "-m", "acc-c3"]).success(); |
| 3422 |
let c3_id = work_dir |
| 3423 |
.run_jj(["log", "-T", "commit_id", "-r", "@", "--no-graph"]) |
| 3424 |
.stdout |
| 3425 |
.raw() |
| 3426 |
.trim() |
| 3427 |
.to_string(); |
| 3428 |
work_dir.run_jj(["new"]).success(); |
| 3429 |
|
| 3430 |
// Use c2_id to ensure the hidden c2 is shown. |
| 3431 |
test_env.add_config(format!( |
| 3432 |
r#"revsets.op-diff-changes-in = "mutable() | (all() & {c2_id})""#, |
| 3433 |
)); |
| 3434 |
|
| 3435 |
// Track all with bookmarks. |
| 3436 |
work_dir |
| 3437 |
.run_jj(["bookmark", "create", "ba1", "-r", &c1_id]) |
| 3438 |
.success(); |
| 3439 |
work_dir |
| 3440 |
.run_jj(["bookmark", "create", "ba2", "-r", &c2_id]) |
| 3441 |
.success(); |
| 3442 |
work_dir |
| 3443 |
.run_jj(["bookmark", "create", "ba3", "-r", &c3_id]) |
| 3444 |
.success(); |
| 3445 |
work_dir.run_jj(["new", "root()"]).success(); |
| 3446 |
|
| 3447 |
// Operation A: Hide acc-c3 by abandoning it. c1 and c2 remain visible via |
| 3448 |
// bookmarks. |
| 3449 |
work_dir |
| 3450 |
.run_jj(["abandon", "--ignore-immutable", "-r", &c3_id]) |
| 3451 |
.success(); |
| 3452 |
let op_a = work_dir.current_operation_id(); |
| 3453 |
|
| 3454 |
// Operation B: Abandon c1 and c2. Both become hidden. |
| 3455 |
// newly_hidden = {c1, c2}. |
| 3456 |
// Option 1 (Fix) shows the head (c2) and elides the parent (c1). |
| 3457 |
work_dir |
| 3458 |
.run_jj(["abandon", "--ignore-immutable", "-r", &c1_id, "-r", &c2_id]) |
| 3459 |
.success(); |
| 3460 |
let op_b = work_dir.current_operation_id(); |
| 3461 |
|
| 3462 |
// With --show-changes-in all(), the diff should show both c1 and c2 as |
| 3463 |
// newly hidden. |
| 3464 |
let output = work_dir.run_jj([ |
| 3465 |
"op", |
| 3466 |
"diff", |
| 3467 |
"--from", |
| 3468 |
&op_a, |
| 3469 |
"--to", |
| 3470 |
&op_b, |
| 3471 |
"--show-changes-in", |
| 3472 |
"all()", |
| 3473 |
]); |
| 3474 |
insta::assert_snapshot!(output, @" |
| 3475 |
From operation: 5e7f0dc78d52 (2001-02-03 08:06:12) abandon commit 65f87c2d667d5088987ce6bed60f31f783b9e2ba |
| 3476 |
To operation: 251152d9b321 (2001-02-03 08:06:13) abandon commit 7d9fcee9d7dedaa91bee64d976a4252c74750905 and 1 more |
| 3477 |
|
| 3478 |
Changed commits: |
| 3479 |
○ - quyylypw/0 7d9fcee9 (hidden) (empty) acc-c2 |
| 3480 |
○ - uzontzmm/0 593e25d0 (hidden) (empty) acc-c1 |
| 3481 |
|
| 3482 |
Changed local bookmarks: |
| 3483 |
ba1: |
| 3484 |
+ (absent) |
| 3485 |
- uzontzmm/0 593e25d0 (hidden) (empty) acc-c1 |
| 3486 |
ba2: |
| 3487 |
+ (absent) |
| 3488 |
- quyylypw/0 7d9fcee9 (hidden) (empty) acc-c2 |
| 3489 |
[EOF] |
| 3490 |
"); |
| 3491 |
|
| 3492 |
// Without --show-changes-in, the diff should show c2 as the head |
| 3493 |
// of the newly hidden set and elide c1. |
| 3494 |
let output = work_dir.run_jj(["op", "diff", "--from", &op_a, "--to", &op_b]); |
| 3495 |
insta::assert_snapshot!(output, @" |
| 3496 |
From operation: 5e7f0dc78d52 (2001-02-03 08:06:12) abandon commit 65f87c2d667d5088987ce6bed60f31f783b9e2ba |
| 3497 |
To operation: 251152d9b321 (2001-02-03 08:06:13) abandon commit 7d9fcee9d7dedaa91bee64d976a4252c74750905 and 1 more |
| 3498 |
|
| 3499 |
Changed commits: |
| 3500 |
○ - quyylypw/0 7d9fcee9 (hidden) (empty) acc-c2 |
| 3501 |
(Elided 1 newly removed revisions) |
| 3502 |
|
| 3503 |
Changed local bookmarks: |
| 3504 |
ba1: |
| 3505 |
+ (absent) |
| 3506 |
- uzontzmm/0 593e25d0 (hidden) (empty) acc-c1 |
| 3507 |
ba2: |
| 3508 |
+ (absent) |
| 3509 |
- quyylypw/0 7d9fcee9 (hidden) (empty) acc-c2 |
| 3510 |
[EOF] |
| 3511 |
"); |
| 3512 |
} |
| 3513 |
|
| 3514 |
#[test] |
| 3515 |
fn test_op_show_revset_expression_resolution() { |
| 3516 |
let test_env = TestEnvironment::default(); |
| 3517 |
test_env.run_jj_in(".", ["git", "init", "repo"]).success(); |
| 3518 |
let work_dir = test_env.work_dir("repo"); |
| 3519 |
test_env.add_config( |
| 3520 |
r#" |
| 3521 |
[templates] |
| 3522 |
commit_summary = 'commit_id.short() ++ " " ++ description.first_line()' |
| 3523 |
[template-aliases] |
| 3524 |
'format_short_id(id)' = 'id.substr(0, 12)' |
| 3525 |
'format_short_change_id_with_change_offset(commit)' = 'commit.change_id().short()' |
| 3526 |
"#, |
| 3527 |
); |
| 3528 |
|
| 3529 |
// 1. Initial commits. |
| 3530 |
work_dir.run_jj(["new", "root()", "-m", "base"]).success(); |
| 3531 |
|
| 3532 |
// 2. Create bookmark_x (op_create). |
| 3533 |
work_dir |
| 3534 |
.run_jj(["bookmark", "create", "-r@", "bookmark_x"]) |
| 3535 |
.success(); |
| 3536 |
let op_create = work_dir.current_operation_id(); |
| 3537 |
|
| 3538 |
// 3. Create a stack of 2 commits. |
| 3539 |
for i in 1..=2 { |
| 3540 |
work_dir |
| 3541 |
.run_jj(["new", "@", "-m", &format!("stack {i}")]) |
| 3542 |
.success(); |
| 3543 |
} |
| 3544 |
work_dir |
| 3545 |
.run_jj(["bookmark", "set", "bookmark_x", "-r@"]) |
| 3546 |
.success(); |
| 3547 |
|
| 3548 |
// 4. Rebase the stack (op_rebase). |
| 3549 |
work_dir |
| 3550 |
.run_jj(["new", "root()", "-m", "new_base"]) |
| 3551 |
.success(); |
| 3552 |
let new_base = "@"; |
| 3553 |
work_dir |
| 3554 |
.run_jj(["rebase", "-s", "bookmark_x-", "-d", new_base]) |
| 3555 |
.success(); |
| 3556 |
let op_rebase = work_dir.current_operation_id(); |
| 3557 |
|
| 3558 |
// Configure op-diff-changes-in to require 'bookmark_x'. |
| 3559 |
test_env.add_config(r#"revsets.op-diff-changes-in = "bookmark_x""#); |
| 3560 |
|
| 3561 |
// 5. Test op show for op_rebase: should show ELISION summary. |
| 3562 |
// bookmark_x exists in both states of the rebase. |
| 3563 |
insta::assert_snapshot!(work_dir.run_jj(["op", "show", &op_rebase]), @" |
| 3564 |
f03470add4fa [email protected] default@ 2001-02-03 04:05:14.000 +07:00 - 2001-02-03 04:05:14.000 +07:00 |
| 3565 |
rebase commit 0f12cf5c679b373cb1ee0fa3e441c2f5030c4dc9 and descendants |
| 3566 |
args: jj rebase -s bookmark_x- -d @ |
| 3567 |
|
| 3568 |
Changed commits: |
| 3569 |
○ + 3cafca23bb81 stack 2 |
| 3570 |
- 5456f1af47ed stack 2 |
| 3571 |
(Elided 1 newly added and 1 newly removed revisions) |
| 3572 |
|
| 3573 |
Changed local bookmarks: |
| 3574 |
bookmark_x: |
| 3575 |
+ 3cafca23bb81 stack 2 |
| 3576 |
- 5456f1af47ed stack 2 |
| 3577 |
[EOF] |
| 3578 |
"); |
| 3579 |
|
| 3580 |
// 6. Test op show for op_create: should show WARNING. |
| 3581 |
// bookmark_x did not exist in the 'from' state. |
| 3582 |
insta::assert_snapshot!(work_dir.run_jj(["op", "show", &op_create]), @" |
| 3583 |
e57fae0b2f31 [email protected] default@ 2001-02-03 04:05:09.000 +07:00 - 2001-02-03 04:05:09.000 +07:00 |
| 3584 |
create bookmark bookmark_x pointing to commit 2308e5a241f7a47f186b0686ffb17aa613a727d7 |
| 3585 |
args: jj bookmark create -r@ bookmark_x |
| 3586 |
|
| 3587 |
Warning: Could not resolve revset expression for elision: Revision `bookmark_x` doesn't exist |
| 3588 |
(Use --show-changes-in=all() to see all changes) |
| 3589 |
|
| 3590 |
Changed local bookmarks: |
| 3591 |
bookmark_x: |
| 3592 |
+ 2308e5a241f7 base |
| 3593 |
- (absent) |
| 3594 |
[EOF] |
| 3595 |
"); |
| 3596 |
|
| 3597 |
// 7. Test op show for op_create with the flag: should show all changes and NO |
| 3598 |
// WARNING. |
| 3599 |
insta::assert_snapshot!(work_dir.run_jj(["op", "show", &op_create, "--show-changes-in", "all()"]), @" |
| 3600 |
e57fae0b2f31 [email protected] default@ 2001-02-03 04:05:09.000 +07:00 - 2001-02-03 04:05:09.000 +07:00 |
| 3601 |
create bookmark bookmark_x pointing to commit 2308e5a241f7a47f186b0686ffb17aa613a727d7 |
| 3602 |
args: jj bookmark create -r@ bookmark_x |
| 3603 |
|
| 3604 |
Changed local bookmarks: |
| 3605 |
bookmark_x: |
| 3606 |
+ 2308e5a241f7 base |
| 3607 |
- (absent) |
| 3608 |
[EOF] |
| 3609 |
"); |
| 3610 |
|
| 3611 |
// 8. Test op diff from BEFORE creation to op_rebase: should show WARNING. |
| 3612 |
let op_before_create = format!("{op_create}-"); |
| 3613 |
insta::assert_snapshot!(work_dir.run_jj(["op", "diff", "--from", &op_before_create, "--to", &op_rebase]), @" |
| 3614 |
From operation: 3c9db0573e75 (2001-02-03 08:05:08) new empty commit |
| 3615 |
To operation: f03470add4fa (2001-02-03 08:05:14) rebase commit 0f12cf5c679b373cb1ee0fa3e441c2f5030c4dc9 and descendants |
| 3616 |
|
| 3617 |
Warning: Could not resolve revset expression for elision: Revision `bookmark_x` doesn't exist |
| 3618 |
(Use --show-changes-in=all() to see all changes) |
| 3619 |
|
| 3620 |
Changed working copy default@: |
| 3621 |
+ 6b753f7043b4 new_base |
| 3622 |
- 2308e5a241f7 base |
| 3623 |
|
| 3624 |
Changed local bookmarks: |
| 3625 |
bookmark_x: |
| 3626 |
+ 3cafca23bb81 stack 2 |
| 3627 |
- (absent) |
| 3628 |
[EOF] |
| 3629 |
"); |
| 3630 |
|
| 3631 |
// 9. Test op diff with the flag: should show all changes and NO WARNING. |
| 3632 |
insta::assert_snapshot!(work_dir.run_jj([ |
| 3633 |
"op", |
| 3634 |
"diff", |
| 3635 |
"--from", |
| 3636 |
&op_before_create, |
| 3637 |
"--to", |
| 3638 |
&op_rebase, |
| 3639 |
"--show-changes-in", |
| 3640 |
"all()", |
| 3641 |
]), @" |
| 3642 |
From operation: 3c9db0573e75 (2001-02-03 08:05:08) new empty commit |
| 3643 |
To operation: f03470add4fa (2001-02-03 08:05:14) rebase commit 0f12cf5c679b373cb1ee0fa3e441c2f5030c4dc9 and descendants |
| 3644 |
|
| 3645 |
Changed commits: |
| 3646 |
○ + 3cafca23bb81 stack 2 |
| 3647 |
○ + e7bd1678832f stack 1 |
| 3648 |
○ + 6b753f7043b4 new_base |
| 3649 |
|
| 3650 |
Changed working copy default@: |
| 3651 |
+ 6b753f7043b4 new_base |
| 3652 |
- 2308e5a241f7 base |
| 3653 |
|
| 3654 |
Changed local bookmarks: |
| 3655 |
bookmark_x: |
| 3656 |
+ 3cafca23bb81 stack 2 |
| 3657 |
- (absent) |
| 3658 |
[EOF] |
| 3659 |
"); |
| 3660 |
|
| 3661 |
// 10. Test op log -p: should show BOTH behaviors. |
| 3662 |
test_env.add_config(r#"revsets.op-diff-changes-in = "mutable() | bookmark_x""#); |
| 3663 |
insta::assert_snapshot!(work_dir.run_jj(["op", "log", "-p", "--limit", "6"]), @" |
| 3664 |
@ f03470add4fa [email protected] default@ 2001-02-03 04:05:14.000 +07:00 - 2001-02-03 04:05:14.000 +07:00 |
| 3665 |
│ rebase commit 0f12cf5c679b373cb1ee0fa3e441c2f5030c4dc9 and descendants |
| 3666 |
│ args: jj rebase -s bookmark_x- -d @ |
| 3667 |
│ |
| 3668 |
│ Changed commits: |
| 3669 |
│ ○ + 3cafca23bb81 stack 2 |
| 3670 |
│ │ - 5456f1af47ed stack 2 |
| 3671 |
│ ○ + e7bd1678832f stack 1 |
| 3672 |
│ - 0f12cf5c679b stack 1 |
| 3673 |
│ |
| 3674 |
│ Changed local bookmarks: |
| 3675 |
│ bookmark_x: |
| 3676 |
│ + 3cafca23bb81 stack 2 |
| 3677 |
│ - 5456f1af47ed stack 2 |
| 3678 |
○ ecab6f492442 [email protected] default@ 2001-02-03 04:05:13.000 +07:00 - 2001-02-03 04:05:13.000 +07:00 |
| 3679 |
│ new empty commit |
| 3680 |
│ args: jj new 'root()' -m new_base |
| 3681 |
│ |
| 3682 |
│ Changed commits: |
| 3683 |
│ ○ + 6b753f7043b4 new_base |
| 3684 |
│ Modified commit description: |
| 3685 |
│ 1: new_base |
| 3686 |
│ |
| 3687 |
│ Changed working copy default@: |
| 3688 |
│ + 6b753f7043b4 new_base |
| 3689 |
│ - 5456f1af47ed stack 2 |
| 3690 |
○ e3d322015195 [email protected] default@ 2001-02-03 04:05:12.000 +07:00 - 2001-02-03 04:05:12.000 +07:00 |
| 3691 |
│ point bookmark bookmark_x to commit 5456f1af47edb52cfd73d582364cc4dd6ddb08cf |
| 3692 |
│ args: jj bookmark set bookmark_x -r@ |
| 3693 |
│ |
| 3694 |
│ Changed local bookmarks: |
| 3695 |
│ bookmark_x: |
| 3696 |
│ + 5456f1af47ed stack 2 |
| 3697 |
│ - 2308e5a241f7 base |
| 3698 |
○ 5ae91ad4e666 [email protected] default@ 2001-02-03 04:05:11.000 +07:00 - 2001-02-03 04:05:11.000 +07:00 |
| 3699 |
│ new empty commit |
| 3700 |
│ args: jj new @ -m 'stack 2' |
| 3701 |
│ |
| 3702 |
│ Changed commits: |
| 3703 |
│ ○ + 5456f1af47ed stack 2 |
| 3704 |
│ Modified commit description: |
| 3705 |
│ 1: stack 2 |
| 3706 |
│ |
| 3707 |
│ Changed working copy default@: |
| 3708 |
│ + 5456f1af47ed stack 2 |
| 3709 |
│ - 0f12cf5c679b stack 1 |
| 3710 |
○ 40eb3a0af389 [email protected] default@ 2001-02-03 04:05:10.000 +07:00 - 2001-02-03 04:05:10.000 +07:00 |
| 3711 |
│ new empty commit |
| 3712 |
│ args: jj new @ -m 'stack 1' |
| 3713 |
│ |
| 3714 |
│ Changed commits: |
| 3715 |
│ ○ + 0f12cf5c679b stack 1 |
| 3716 |
│ Modified commit description: |
| 3717 |
│ 1: stack 1 |
| 3718 |
│ |
| 3719 |
│ Changed working copy default@: |
| 3720 |
│ + 0f12cf5c679b stack 1 |
| 3721 |
│ - 2308e5a241f7 base |
| 3722 |
○ e57fae0b2f31 [email protected] default@ 2001-02-03 04:05:09.000 +07:00 - 2001-02-03 04:05:09.000 +07:00 |
| 3723 |
│ create bookmark bookmark_x pointing to commit 2308e5a241f7a47f186b0686ffb17aa613a727d7 |
| 3724 |
│ args: jj bookmark create -r@ bookmark_x |
| 3725 |
│ |
| 3726 |
│ Warning: Could not resolve revset expression for elision: Revision `bookmark_x` doesn't exist |
| 3727 |
│ (Use --show-changes-in=all() to see all changes) |
| 3728 |
│ |
| 3729 |
│ Changed local bookmarks: |
| 3730 |
│ bookmark_x: |
| 3731 |
│ + 2308e5a241f7 base |
| 3732 |
│ - (absent) |
| 3733 |
[EOF] |
| 3734 |
"); |
| 3735 |
|
| 3736 |
// 11. Test op log -p with the flag: should show all changes and NO WARNING. |
| 3737 |
insta::assert_snapshot!(work_dir.run_jj([ |
| 3738 |
"op", |
| 3739 |
"log", |
| 3740 |
"-p", |
| 3741 |
"--limit", |
| 3742 |
"6", |
| 3743 |
"--show-changes-in", |
| 3744 |
"all()", |
| 3745 |
]), @" |
| 3746 |
@ f03470add4fa [email protected] default@ 2001-02-03 04:05:14.000 +07:00 - 2001-02-03 04:05:14.000 +07:00 |
| 3747 |
│ rebase commit 0f12cf5c679b373cb1ee0fa3e441c2f5030c4dc9 and descendants |
| 3748 |
│ args: jj rebase -s bookmark_x- -d @ |
| 3749 |
│ |
| 3750 |
│ Changed commits: |
| 3751 |
│ ○ + 3cafca23bb81 stack 2 |
| 3752 |
│ │ - 5456f1af47ed stack 2 |
| 3753 |
│ ○ + e7bd1678832f stack 1 |
| 3754 |
│ - 0f12cf5c679b stack 1 |
| 3755 |
│ |
| 3756 |
│ Changed local bookmarks: |
| 3757 |
│ bookmark_x: |
| 3758 |
│ + 3cafca23bb81 stack 2 |
| 3759 |
│ - 5456f1af47ed stack 2 |
| 3760 |
○ ecab6f492442 [email protected] default@ 2001-02-03 04:05:13.000 +07:00 - 2001-02-03 04:05:13.000 +07:00 |
| 3761 |
│ new empty commit |
| 3762 |
│ args: jj new 'root()' -m new_base |
| 3763 |
│ |
| 3764 |
│ Changed commits: |
| 3765 |
│ ○ + 6b753f7043b4 new_base |
| 3766 |
│ Modified commit description: |
| 3767 |
│ 1: new_base |
| 3768 |
│ |
| 3769 |
│ Changed working copy default@: |
| 3770 |
│ + 6b753f7043b4 new_base |
| 3771 |
│ - 5456f1af47ed stack 2 |
| 3772 |
○ e3d322015195 [email protected] default@ 2001-02-03 04:05:12.000 +07:00 - 2001-02-03 04:05:12.000 +07:00 |
| 3773 |
│ point bookmark bookmark_x to commit 5456f1af47edb52cfd73d582364cc4dd6ddb08cf |
| 3774 |
│ args: jj bookmark set bookmark_x -r@ |
| 3775 |
│ |
| 3776 |
│ Changed local bookmarks: |
| 3777 |
│ bookmark_x: |
| 3778 |
│ + 5456f1af47ed stack 2 |
| 3779 |
│ - 2308e5a241f7 base |
| 3780 |
○ 5ae91ad4e666 [email protected] default@ 2001-02-03 04:05:11.000 +07:00 - 2001-02-03 04:05:11.000 +07:00 |
| 3781 |
│ new empty commit |
| 3782 |
│ args: jj new @ -m 'stack 2' |
| 3783 |
│ |
| 3784 |
│ Changed commits: |
| 3785 |
│ ○ + 5456f1af47ed stack 2 |
| 3786 |
│ Modified commit description: |
| 3787 |
│ 1: stack 2 |
| 3788 |
│ |
| 3789 |
│ Changed working copy default@: |
| 3790 |
│ + 5456f1af47ed stack 2 |
| 3791 |
│ - 0f12cf5c679b stack 1 |
| 3792 |
○ 40eb3a0af389 [email protected] default@ 2001-02-03 04:05:10.000 +07:00 - 2001-02-03 04:05:10.000 +07:00 |
| 3793 |
│ new empty commit |
| 3794 |
│ args: jj new @ -m 'stack 1' |
| 3795 |
│ |
| 3796 |
│ Changed commits: |
| 3797 |
│ ○ + 0f12cf5c679b stack 1 |
| 3798 |
│ Modified commit description: |
| 3799 |
│ 1: stack 1 |
| 3800 |
│ |
| 3801 |
│ Changed working copy default@: |
| 3802 |
│ + 0f12cf5c679b stack 1 |
| 3803 |
│ - 2308e5a241f7 base |
| 3804 |
○ e57fae0b2f31 [email protected] default@ 2001-02-03 04:05:09.000 +07:00 - 2001-02-03 04:05:09.000 +07:00 |
| 3805 |
│ create bookmark bookmark_x pointing to commit 2308e5a241f7a47f186b0686ffb17aa613a727d7 |
| 3806 |
│ args: jj bookmark create -r@ bookmark_x |
| 3807 |
│ |
| 3808 |
│ Changed local bookmarks: |
| 3809 |
│ bookmark_x: |
| 3810 |
│ + 2308e5a241f7 base |
| 3811 |
│ - (absent) |
| 3812 |
[EOF] |
| 3813 |
"); |
| 3814 |
} |
| 3815 |
|
| 3816 |
#[test] |
| 3817 |
fn test_op_diff_invalid_revset() { |
| 3818 |
let test_env = TestEnvironment::default(); |
| 3819 |
test_env.run_jj_in(".", ["git", "init", "repo"]).success(); |
| 3820 |
let work_dir = test_env.work_dir("repo"); |
| 3821 |
|
| 3822 |
// Invalid flag value |
| 3823 |
insta::assert_snapshot!(work_dir.run_jj(["op", "diff", "--show-changes-in", "invalid("]), @" |
| 3824 |
------- stderr ------- |
| 3825 |
Error: Invalid `--show-changes-in` expression: invalid( |
| 3826 |
Caused by: --> 1:9 |
| 3827 |
| |
| 3828 |
1 | invalid( |
| 3829 |
| ^--- |
| 3830 |
| |
| 3831 |
= expected <strict_identifier> or <expression> |
| 3832 |
[EOF] |
| 3833 |
[exit status: 1] |
| 3834 |
"); |
| 3835 |
|
| 3836 |
// Invalid config value |
| 3837 |
test_env.add_config(r#"revsets.op-diff-changes-in = "invalid(""#); |
| 3838 |
insta::assert_snapshot!(work_dir.run_jj(["op", "diff"]), @" |
| 3839 |
------- stderr ------- |
| 3840 |
Config error: Invalid `revsets.op-diff-changes-in` |
| 3841 |
Caused by: --> 1:9 |
| 3842 |
| |
| 3843 |
1 | invalid( |
| 3844 |
| ^--- |
| 3845 |
| |
| 3846 |
= expected <strict_identifier> or <expression> |
| 3847 |
For help, see https://docs.jj-vcs.dev/latest/config/ or use `jj help -k config`. |
| 3848 |
[EOF] |
| 3849 |
[exit status: 1] |
| 3850 |
"); |
| 3851 |
} |
| 3852 |
|
| 3853 |
fn init_bare_git_repo(git_repo_path: &Path) -> gix::Repository { |
| 3854 |
let git_repo = git::init_bare(git_repo_path); |
| 3855 |
let commit_result = git::add_commit( |
| 3856 |
&git_repo, |
| 3857 |
"refs/heads/bookmark-1", |
| 3858 |
"some-file", |
| 3859 |
b"some content", |
| 3860 |
"Commit 1", |
| 3861 |
&[], |
| 3862 |
); |
| 3863 |
git::write_commit( |
| 3864 |
&git_repo, |
| 3865 |
"refs/heads/bookmark-2", |
| 3866 |
commit_result.tree_id, |
| 3867 |
"Commit 2", |
| 3868 |
&[], |
| 3869 |
); |
| 3870 |
git::write_commit( |
| 3871 |
&git_repo, |
| 3872 |
"refs/heads/bookmark-3", |
| 3873 |
commit_result.tree_id, |
| 3874 |
"Commit 3", |
| 3875 |
&[], |
| 3876 |
); |
| 3877 |
|
| 3878 |
git::add_commit( |
| 3879 |
&git_repo, |
| 3880 |
"refs/tags/tag-1", |
| 3881 |
"some-file", |
| 3882 |
b"some tagged content", |
| 3883 |
"Commit 4", |
| 3884 |
&[], |
| 3885 |
); |
| 3886 |
|
| 3887 |
git::set_head_to_id(&git_repo, commit_result.commit_id); |
| 3888 |
git_repo |
| 3889 |
} |
| 3890 |
|
| 3891 |
fn modify_git_repo(git_repo: gix::Repository) -> gix::Repository { |
| 3892 |
let bookmark1_commit = git_repo |
| 3893 |
.find_reference("refs/heads/bookmark-1") |
| 3894 |
.unwrap() |
| 3895 |
.peel_to_commit() |
| 3896 |
.unwrap() |
| 3897 |
.id(); |
| 3898 |
let bookmark2_commit = git_repo |
| 3899 |
.find_reference("refs/heads/bookmark-2") |
| 3900 |
.unwrap() |
| 3901 |
.peel_to_commit() |
| 3902 |
.unwrap() |
| 3903 |
.id(); |
| 3904 |
|
| 3905 |
let commit_result = git::add_commit( |
| 3906 |
&git_repo, |
| 3907 |
"refs/heads/bookmark-1", |
| 3908 |
"next-file", |
| 3909 |
b"more content", |
| 3910 |
"Commit 4", |
| 3911 |
&[bookmark1_commit.detach()], |
| 3912 |
); |
| 3913 |
git::write_commit( |
| 3914 |
&git_repo, |
| 3915 |
"refs/heads/bookmark-2", |
| 3916 |
commit_result.tree_id, |
| 3917 |
"Commit 5", |
| 3918 |
&[bookmark2_commit.detach()], |
| 3919 |
); |
| 3920 |
|
| 3921 |
git_repo |
| 3922 |
.find_reference("refs/heads/bookmark-3") |
| 3923 |
.unwrap() |
| 3924 |
.delete() |
| 3925 |
.unwrap(); |
| 3926 |
git_repo |
| 3927 |
} |
| 3928 |
|
| 3929 |
#[must_use] |
| 3930 |
fn get_log_output(work_dir: &TestWorkDir, op_id: &str) -> CommandOutput { |
| 3931 |
work_dir.run_jj(["log", "-T", "commit_id", "--at-op", op_id, "-r", "all()"]) |
| 3932 |
} |