| 1 |
// Copyright 2023 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 |
|
| 16 |
use crate::common::CommandOutput; |
| 17 |
use crate::common::TestEnvironment; |
| 18 |
use crate::common::TestWorkDir; |
| 19 |
use crate::common::force_interactive; |
| 20 |
|
| 21 |
#[test] |
| 22 |
fn test_next_simple() { |
| 23 |
// Move from first => second. |
| 24 |
// first |
| 25 |
// | |
| 26 |
// second |
| 27 |
// | |
| 28 |
// third |
| 29 |
// |
| 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 |
// Create a simple linear history, which we'll traverse. |
| 34 |
work_dir.run_jj(["commit", "-m", "first"]).success(); |
| 35 |
work_dir.run_jj(["commit", "-m", "second"]).success(); |
| 36 |
work_dir.run_jj(["commit", "-m", "third"]).success(); |
| 37 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 38 |
@ zsuskulnrvyr |
| 39 |
○ kkmpptxzrspx third |
| 40 |
○ rlvkpnrzqnoo second |
| 41 |
○ qpvuntsmwlqt first |
| 42 |
◆ zzzzzzzzzzzz |
| 43 |
[EOF] |
| 44 |
"); |
| 45 |
|
| 46 |
// Move to `first` |
| 47 |
work_dir.run_jj(["new", "@--"]).success(); |
| 48 |
|
| 49 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 50 |
@ royxmykxtrkr |
| 51 |
│ ○ kkmpptxzrspx third |
| 52 |
├─╯ |
| 53 |
○ rlvkpnrzqnoo second |
| 54 |
○ qpvuntsmwlqt first |
| 55 |
◆ zzzzzzzzzzzz |
| 56 |
[EOF] |
| 57 |
"); |
| 58 |
|
| 59 |
let output = work_dir.run_jj(["next"]); |
| 60 |
insta::assert_snapshot!(output, @" |
| 61 |
------- stderr ------- |
| 62 |
Working copy (@) now at: vruxwmqv 01f06d39 (empty) (no description set) |
| 63 |
Parent commit (@-) : kkmpptxz 7576de42 (empty) third |
| 64 |
[EOF] |
| 65 |
"); |
| 66 |
|
| 67 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 68 |
@ vruxwmqvtpmx |
| 69 |
○ kkmpptxzrspx third |
| 70 |
○ rlvkpnrzqnoo second |
| 71 |
○ qpvuntsmwlqt first |
| 72 |
◆ zzzzzzzzzzzz |
| 73 |
[EOF] |
| 74 |
"); |
| 75 |
} |
| 76 |
|
| 77 |
#[test] |
| 78 |
fn test_next_multiple() { |
| 79 |
// Move from first => fourth. |
| 80 |
let test_env = TestEnvironment::default(); |
| 81 |
test_env.run_jj_in(".", ["git", "init", "repo"]).success(); |
| 82 |
let work_dir = test_env.work_dir("repo"); |
| 83 |
work_dir.run_jj(["commit", "-m", "first"]).success(); |
| 84 |
work_dir.run_jj(["commit", "-m", "second"]).success(); |
| 85 |
work_dir.run_jj(["commit", "-m", "third"]).success(); |
| 86 |
work_dir.run_jj(["commit", "-m", "fourth"]).success(); |
| 87 |
work_dir.run_jj(["new", "@---"]).success(); |
| 88 |
|
| 89 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 90 |
@ royxmykxtrkr |
| 91 |
│ ○ zsuskulnrvyr fourth |
| 92 |
│ ○ kkmpptxzrspx third |
| 93 |
├─╯ |
| 94 |
○ rlvkpnrzqnoo second |
| 95 |
○ qpvuntsmwlqt first |
| 96 |
◆ zzzzzzzzzzzz |
| 97 |
[EOF] |
| 98 |
"); |
| 99 |
|
| 100 |
// We should now be the child of the fourth commit. |
| 101 |
let output = work_dir.run_jj(["next", "2"]); |
| 102 |
insta::assert_snapshot!(output, @" |
| 103 |
------- stderr ------- |
| 104 |
Working copy (@) now at: vruxwmqv a53dd783 (empty) (no description set) |
| 105 |
Parent commit (@-) : zsuskuln c5025ce1 (empty) fourth |
| 106 |
[EOF] |
| 107 |
"); |
| 108 |
|
| 109 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 110 |
@ vruxwmqvtpmx |
| 111 |
○ zsuskulnrvyr fourth |
| 112 |
○ kkmpptxzrspx third |
| 113 |
○ rlvkpnrzqnoo second |
| 114 |
○ qpvuntsmwlqt first |
| 115 |
◆ zzzzzzzzzzzz |
| 116 |
[EOF] |
| 117 |
"); |
| 118 |
} |
| 119 |
|
| 120 |
#[test] |
| 121 |
fn test_prev_simple() { |
| 122 |
// Move @- from third to second. |
| 123 |
let test_env = TestEnvironment::default(); |
| 124 |
test_env.run_jj_in(".", ["git", "init", "repo"]).success(); |
| 125 |
let work_dir = test_env.work_dir("repo"); |
| 126 |
work_dir.run_jj(["commit", "-m", "first"]).success(); |
| 127 |
work_dir.run_jj(["commit", "-m", "second"]).success(); |
| 128 |
work_dir.run_jj(["commit", "-m", "third"]).success(); |
| 129 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 130 |
@ zsuskulnrvyr |
| 131 |
○ kkmpptxzrspx third |
| 132 |
○ rlvkpnrzqnoo second |
| 133 |
○ qpvuntsmwlqt first |
| 134 |
◆ zzzzzzzzzzzz |
| 135 |
[EOF] |
| 136 |
"); |
| 137 |
|
| 138 |
let output = work_dir.run_jj(["prev"]); |
| 139 |
insta::assert_snapshot!(output, @" |
| 140 |
------- stderr ------- |
| 141 |
Working copy (@) now at: royxmykx 539f176b (empty) (no description set) |
| 142 |
Parent commit (@-) : rlvkpnrz 9439bf06 (empty) second |
| 143 |
[EOF] |
| 144 |
"); |
| 145 |
|
| 146 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 147 |
@ royxmykxtrkr |
| 148 |
│ ○ kkmpptxzrspx third |
| 149 |
├─╯ |
| 150 |
○ rlvkpnrzqnoo second |
| 151 |
○ qpvuntsmwlqt first |
| 152 |
◆ zzzzzzzzzzzz |
| 153 |
[EOF] |
| 154 |
"); |
| 155 |
} |
| 156 |
|
| 157 |
#[test] |
| 158 |
fn test_prev_multiple_without_root() { |
| 159 |
// Move @- from fourth to second. |
| 160 |
let test_env = TestEnvironment::default(); |
| 161 |
test_env.run_jj_in(".", ["git", "init", "repo"]).success(); |
| 162 |
let work_dir = test_env.work_dir("repo"); |
| 163 |
work_dir.run_jj(["commit", "-m", "first"]).success(); |
| 164 |
work_dir.run_jj(["commit", "-m", "second"]).success(); |
| 165 |
work_dir.run_jj(["commit", "-m", "third"]).success(); |
| 166 |
work_dir.run_jj(["commit", "-m", "fourth"]).success(); |
| 167 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 168 |
@ mzvwutvlkqwt |
| 169 |
○ zsuskulnrvyr fourth |
| 170 |
○ kkmpptxzrspx third |
| 171 |
○ rlvkpnrzqnoo second |
| 172 |
○ qpvuntsmwlqt first |
| 173 |
◆ zzzzzzzzzzzz |
| 174 |
[EOF] |
| 175 |
"); |
| 176 |
|
| 177 |
let output = work_dir.run_jj(["prev", "2"]); |
| 178 |
insta::assert_snapshot!(output, @" |
| 179 |
------- stderr ------- |
| 180 |
Working copy (@) now at: yqosqzyt a4d3accb (empty) (no description set) |
| 181 |
Parent commit (@-) : rlvkpnrz 9439bf06 (empty) second |
| 182 |
[EOF] |
| 183 |
"); |
| 184 |
|
| 185 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 186 |
@ yqosqzytrlsw |
| 187 |
│ ○ zsuskulnrvyr fourth |
| 188 |
│ ○ kkmpptxzrspx third |
| 189 |
├─╯ |
| 190 |
○ rlvkpnrzqnoo second |
| 191 |
○ qpvuntsmwlqt first |
| 192 |
◆ zzzzzzzzzzzz |
| 193 |
[EOF] |
| 194 |
"); |
| 195 |
} |
| 196 |
|
| 197 |
#[test] |
| 198 |
fn test_next_exceeding_history() { |
| 199 |
// Try to step beyond the current repos history. |
| 200 |
let test_env = TestEnvironment::default(); |
| 201 |
test_env.run_jj_in(".", ["git", "init", "repo"]).success(); |
| 202 |
let work_dir = test_env.work_dir("repo"); |
| 203 |
work_dir.run_jj(["commit", "-m", "first"]).success(); |
| 204 |
work_dir.run_jj(["commit", "-m", "second"]).success(); |
| 205 |
work_dir.run_jj(["commit", "-m", "third"]).success(); |
| 206 |
work_dir.run_jj(["new", "-r", "@--"]).success(); |
| 207 |
|
| 208 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 209 |
@ mzvwutvlkqwt |
| 210 |
│ ○ kkmpptxzrspx third |
| 211 |
├─╯ |
| 212 |
○ rlvkpnrzqnoo second |
| 213 |
○ qpvuntsmwlqt first |
| 214 |
◆ zzzzzzzzzzzz |
| 215 |
[EOF] |
| 216 |
"); |
| 217 |
|
| 218 |
// `jj next` beyond existing history fails. |
| 219 |
let output = work_dir.run_jj(["next", "3"]); |
| 220 |
insta::assert_snapshot!(output, @" |
| 221 |
------- stderr ------- |
| 222 |
Error: No other descendant found 3 commit(s) forward from the working copy parent(s) |
| 223 |
Hint: Working copy parent: rlvkpnrz 9439bf06 (empty) second |
| 224 |
[EOF] |
| 225 |
[exit status: 1] |
| 226 |
"); |
| 227 |
} |
| 228 |
|
| 229 |
// The working copy commit is a child of a "fork" with two children on each |
| 230 |
// bookmark. |
| 231 |
#[test] |
| 232 |
fn test_next_parent_has_multiple_descendants() { |
| 233 |
let test_env = TestEnvironment::default(); |
| 234 |
test_env.run_jj_in(".", ["git", "init", "repo"]).success(); |
| 235 |
let work_dir = test_env.work_dir("repo"); |
| 236 |
// Setup. |
| 237 |
work_dir.run_jj(["desc", "-m", "1"]).success(); |
| 238 |
work_dir.run_jj(["new", "-m", "2"]).success(); |
| 239 |
work_dir.run_jj(["new", "root()", "-m", "3"]).success(); |
| 240 |
work_dir.run_jj(["new", "-m", "4"]).success(); |
| 241 |
work_dir.run_jj(["edit", "subject(3)"]).success(); |
| 242 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 243 |
○ mzvwutvlkqwt 4 |
| 244 |
@ zsuskulnrvyr 3 |
| 245 |
│ ○ kkmpptxzrspx 2 |
| 246 |
│ ○ qpvuntsmwlqt 1 |
| 247 |
├─╯ |
| 248 |
◆ zzzzzzzzzzzz |
| 249 |
[EOF] |
| 250 |
"); |
| 251 |
|
| 252 |
let output = work_dir.run_jj(["next", "--edit"]); |
| 253 |
insta::assert_snapshot!(output, @" |
| 254 |
------- stderr ------- |
| 255 |
Working copy (@) now at: mzvwutvl e5543950 (empty) 4 |
| 256 |
Parent commit (@-) : zsuskuln 83df6e43 (empty) 3 |
| 257 |
[EOF] |
| 258 |
"); |
| 259 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 260 |
@ mzvwutvlkqwt 4 |
| 261 |
○ zsuskulnrvyr 3 |
| 262 |
│ ○ kkmpptxzrspx 2 |
| 263 |
│ ○ qpvuntsmwlqt 1 |
| 264 |
├─╯ |
| 265 |
◆ zzzzzzzzzzzz |
| 266 |
[EOF] |
| 267 |
"); |
| 268 |
} |
| 269 |
|
| 270 |
#[test] |
| 271 |
fn test_next_with_merge_commit_parent() { |
| 272 |
let test_env = TestEnvironment::default(); |
| 273 |
test_env.run_jj_in(".", ["git", "init", "repo"]).success(); |
| 274 |
let work_dir = test_env.work_dir("repo"); |
| 275 |
// Setup. |
| 276 |
work_dir.run_jj(["desc", "-m", "1"]).success(); |
| 277 |
work_dir.run_jj(["new", "root()", "-m", "2"]).success(); |
| 278 |
work_dir |
| 279 |
.run_jj(["new", "subject(1)", "subject(2)", "-m", "3"]) |
| 280 |
.success(); |
| 281 |
work_dir.run_jj(["new", "-m", "4"]).success(); |
| 282 |
work_dir.run_jj(["prev", "0"]).success(); |
| 283 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 284 |
@ royxmykxtrkr |
| 285 |
│ ○ mzvwutvlkqwt 4 |
| 286 |
├─╯ |
| 287 |
○ zsuskulnrvyr 3 |
| 288 |
├─╮ |
| 289 |
│ ○ kkmpptxzrspx 2 |
| 290 |
○ │ qpvuntsmwlqt 1 |
| 291 |
├─╯ |
| 292 |
◆ zzzzzzzzzzzz |
| 293 |
[EOF] |
| 294 |
"); |
| 295 |
|
| 296 |
let output = work_dir.run_jj(["next"]); |
| 297 |
insta::assert_snapshot!(output, @" |
| 298 |
------- stderr ------- |
| 299 |
Working copy (@) now at: vruxwmqv 7a09c355 (empty) (no description set) |
| 300 |
Parent commit (@-) : mzvwutvl f02c921e (empty) 4 |
| 301 |
[EOF] |
| 302 |
"); |
| 303 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 304 |
@ vruxwmqvtpmx |
| 305 |
○ mzvwutvlkqwt 4 |
| 306 |
○ zsuskulnrvyr 3 |
| 307 |
├─╮ |
| 308 |
│ ○ kkmpptxzrspx 2 |
| 309 |
○ │ qpvuntsmwlqt 1 |
| 310 |
├─╯ |
| 311 |
◆ zzzzzzzzzzzz |
| 312 |
[EOF] |
| 313 |
"); |
| 314 |
} |
| 315 |
|
| 316 |
#[test] |
| 317 |
fn test_next_on_merge_commit() { |
| 318 |
let test_env = TestEnvironment::default(); |
| 319 |
test_env.run_jj_in(".", ["git", "init", "repo"]).success(); |
| 320 |
let work_dir = test_env.work_dir("repo"); |
| 321 |
// Setup. |
| 322 |
work_dir.run_jj(["desc", "-m", "1"]).success(); |
| 323 |
work_dir.run_jj(["new", "root()", "-m", "2"]).success(); |
| 324 |
work_dir |
| 325 |
.run_jj(["new", "subject(1)", "subject(2)", "-m", "3"]) |
| 326 |
.success(); |
| 327 |
work_dir.run_jj(["new", "-m", "4"]).success(); |
| 328 |
work_dir.run_jj(["edit", "subject(3)"]).success(); |
| 329 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 330 |
○ mzvwutvlkqwt 4 |
| 331 |
@ zsuskulnrvyr 3 |
| 332 |
├─╮ |
| 333 |
│ ○ kkmpptxzrspx 2 |
| 334 |
○ │ qpvuntsmwlqt 1 |
| 335 |
├─╯ |
| 336 |
◆ zzzzzzzzzzzz |
| 337 |
[EOF] |
| 338 |
"); |
| 339 |
|
| 340 |
let output = work_dir.run_jj(["next", "--edit"]); |
| 341 |
insta::assert_snapshot!(output, @" |
| 342 |
------- stderr ------- |
| 343 |
Working copy (@) now at: mzvwutvl f02c921e (empty) 4 |
| 344 |
Parent commit (@-) : zsuskuln d2500577 (empty) 3 |
| 345 |
[EOF] |
| 346 |
"); |
| 347 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 348 |
@ mzvwutvlkqwt 4 |
| 349 |
○ zsuskulnrvyr 3 |
| 350 |
├─╮ |
| 351 |
│ ○ kkmpptxzrspx 2 |
| 352 |
○ │ qpvuntsmwlqt 1 |
| 353 |
├─╯ |
| 354 |
◆ zzzzzzzzzzzz |
| 355 |
[EOF] |
| 356 |
"); |
| 357 |
} |
| 358 |
|
| 359 |
#[test] |
| 360 |
fn test_next_fails_on_bookmarking_children_no_stdin() { |
| 361 |
let test_env = TestEnvironment::default(); |
| 362 |
test_env.run_jj_in(".", ["git", "init", "repo"]).success(); |
| 363 |
let work_dir = test_env.work_dir("repo"); |
| 364 |
work_dir.run_jj(["commit", "-m", "first"]).success(); |
| 365 |
work_dir.run_jj(["commit", "-m", "second"]).success(); |
| 366 |
work_dir.run_jj(["new", "@--"]).success(); |
| 367 |
work_dir.run_jj(["commit", "-m", "third"]).success(); |
| 368 |
work_dir.run_jj(["new", "@--"]).success(); |
| 369 |
|
| 370 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 371 |
@ royxmykxtrkr |
| 372 |
│ ○ zsuskulnrvyr third |
| 373 |
├─╯ |
| 374 |
│ ○ rlvkpnrzqnoo second |
| 375 |
├─╯ |
| 376 |
○ qpvuntsmwlqt first |
| 377 |
◆ zzzzzzzzzzzz |
| 378 |
[EOF] |
| 379 |
"); |
| 380 |
|
| 381 |
// Try to advance the working copy commit. |
| 382 |
let output = work_dir.run_jj(["next"]); |
| 383 |
insta::assert_snapshot!(output, @" |
| 384 |
------- stderr ------- |
| 385 |
ambiguous next commit, choose one to target: |
| 386 |
1: zsuskuln 6fc6af46 (empty) third |
| 387 |
2: rlvkpnrz 9439bf06 (empty) second |
| 388 |
q: quit the prompt |
| 389 |
Error: Cannot prompt for input since the output is not connected to a terminal |
| 390 |
[EOF] |
| 391 |
[exit status: 1] |
| 392 |
"); |
| 393 |
} |
| 394 |
|
| 395 |
#[test] |
| 396 |
fn test_next_fails_on_bookmarking_children_quit_prompt() { |
| 397 |
let test_env = TestEnvironment::default(); |
| 398 |
test_env.run_jj_in(".", ["git", "init", "repo"]).success(); |
| 399 |
let work_dir = test_env.work_dir("repo"); |
| 400 |
work_dir.run_jj(["commit", "-m", "first"]).success(); |
| 401 |
work_dir.run_jj(["commit", "-m", "second"]).success(); |
| 402 |
work_dir.run_jj(["new", "@--"]).success(); |
| 403 |
work_dir.run_jj(["commit", "-m", "third"]).success(); |
| 404 |
work_dir.run_jj(["new", "@--"]).success(); |
| 405 |
|
| 406 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 407 |
@ royxmykxtrkr |
| 408 |
│ ○ zsuskulnrvyr third |
| 409 |
├─╯ |
| 410 |
│ ○ rlvkpnrzqnoo second |
| 411 |
├─╯ |
| 412 |
○ qpvuntsmwlqt first |
| 413 |
◆ zzzzzzzzzzzz |
| 414 |
[EOF] |
| 415 |
"); |
| 416 |
|
| 417 |
// Try to advance the working copy commit. |
| 418 |
let output = work_dir.run_jj_with(|cmd| force_interactive(cmd).arg("next").write_stdin("q\n")); |
| 419 |
insta::assert_snapshot!(output, @" |
| 420 |
------- stderr ------- |
| 421 |
ambiguous next commit, choose one to target: |
| 422 |
1: zsuskuln 6fc6af46 (empty) third |
| 423 |
2: rlvkpnrz 9439bf06 (empty) second |
| 424 |
q: quit the prompt |
| 425 |
enter the index of the commit you want to target: Error: ambiguous target commit |
| 426 |
[EOF] |
| 427 |
[exit status: 1] |
| 428 |
"); |
| 429 |
} |
| 430 |
|
| 431 |
#[test] |
| 432 |
fn test_next_choose_bookmarking_child() { |
| 433 |
let test_env = TestEnvironment::default(); |
| 434 |
test_env.run_jj_in(".", ["git", "init", "repo"]).success(); |
| 435 |
let work_dir = test_env.work_dir("repo"); |
| 436 |
work_dir.run_jj(["commit", "-m", "first"]).success(); |
| 437 |
work_dir.run_jj(["commit", "-m", "second"]).success(); |
| 438 |
work_dir.run_jj(["new", "@--"]).success(); |
| 439 |
work_dir.run_jj(["commit", "-m", "third"]).success(); |
| 440 |
work_dir.run_jj(["new", "@--"]).success(); |
| 441 |
work_dir.run_jj(["commit", "-m", "fourth"]).success(); |
| 442 |
work_dir.run_jj(["new", "@--"]).success(); |
| 443 |
// Advance the working copy commit. |
| 444 |
let output = work_dir.run_jj_with(|cmd| force_interactive(cmd).arg("next").write_stdin("2\n")); |
| 445 |
insta::assert_snapshot!(output, @" |
| 446 |
------- stderr ------- |
| 447 |
ambiguous next commit, choose one to target: |
| 448 |
1: royxmykx 3522c887 (empty) fourth |
| 449 |
2: zsuskuln 6fc6af46 (empty) third |
| 450 |
3: rlvkpnrz 9439bf06 (empty) second |
| 451 |
q: quit the prompt |
| 452 |
enter the index of the commit you want to target: Working copy (@) now at: yostqsxw 683938a4 (empty) (no description set) |
| 453 |
Parent commit (@-) : zsuskuln 6fc6af46 (empty) third |
| 454 |
[EOF] |
| 455 |
"); |
| 456 |
} |
| 457 |
|
| 458 |
#[test] |
| 459 |
fn test_prev_on_merge_commit() { |
| 460 |
let test_env = TestEnvironment::default(); |
| 461 |
test_env.run_jj_in(".", ["git", "init", "repo"]).success(); |
| 462 |
let work_dir = test_env.work_dir("repo"); |
| 463 |
work_dir.run_jj(["desc", "-m", "first"]).success(); |
| 464 |
work_dir.run_jj(["bookmark", "c", "-r@", "left"]).success(); |
| 465 |
work_dir.run_jj(["new", "root()", "-m", "second"]).success(); |
| 466 |
work_dir.run_jj(["bookmark", "c", "-r@", "right"]).success(); |
| 467 |
work_dir.run_jj(["new", "left", "right"]).success(); |
| 468 |
|
| 469 |
// Check that the graph looks the way we expect. |
| 470 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 471 |
@ royxmykxtrkr |
| 472 |
├─╮ |
| 473 |
│ ○ zsuskulnrvyr right second |
| 474 |
○ │ qpvuntsmwlqt left first |
| 475 |
├─╯ |
| 476 |
◆ zzzzzzzzzzzz |
| 477 |
[EOF] |
| 478 |
"); |
| 479 |
let setup_opid = work_dir.current_operation_id(); |
| 480 |
|
| 481 |
let output = work_dir.run_jj(["prev"]); |
| 482 |
insta::assert_snapshot!(output, @" |
| 483 |
------- stderr ------- |
| 484 |
Working copy (@) now at: vruxwmqv b64f323d (empty) (no description set) |
| 485 |
Parent commit (@-) : zzzzzzzz 00000000 (empty) (no description set) |
| 486 |
[EOF] |
| 487 |
"); |
| 488 |
|
| 489 |
work_dir.run_jj(["op", "restore", &setup_opid]).success(); |
| 490 |
let output = work_dir.run_jj_with(|cmd| { |
| 491 |
force_interactive(cmd) |
| 492 |
.args(["prev", "--edit"]) |
| 493 |
.write_stdin("2\n") |
| 494 |
}); |
| 495 |
insta::assert_snapshot!(output, @" |
| 496 |
------- stderr ------- |
| 497 |
ambiguous prev commit, choose one to target: |
| 498 |
1: zsuskuln 22a08bc0 right | (empty) second |
| 499 |
2: qpvuntsm 68a50538 left | (empty) first |
| 500 |
q: quit the prompt |
| 501 |
enter the index of the commit you want to target: Working copy (@) now at: qpvuntsm 68a50538 left | (empty) first |
| 502 |
Parent commit (@-) : zzzzzzzz 00000000 (empty) (no description set) |
| 503 |
[EOF] |
| 504 |
"); |
| 505 |
} |
| 506 |
|
| 507 |
#[test] |
| 508 |
fn test_prev_on_merge_commit_with_parent_merge() { |
| 509 |
let test_env = TestEnvironment::default(); |
| 510 |
test_env.run_jj_in(".", ["git", "init", "repo"]).success(); |
| 511 |
let work_dir = test_env.work_dir("repo"); |
| 512 |
work_dir.run_jj(["desc", "-m", "x"]).success(); |
| 513 |
work_dir.run_jj(["new", "root()", "-m", "y"]).success(); |
| 514 |
work_dir |
| 515 |
.run_jj(["new", "subject(x)", "subject(y)", "-m", "z"]) |
| 516 |
.success(); |
| 517 |
work_dir.run_jj(["new", "root()", "-m", "1"]).success(); |
| 518 |
work_dir |
| 519 |
.run_jj(["new", "subject(z)", "subject(1)", "-m", "M"]) |
| 520 |
.success(); |
| 521 |
|
| 522 |
// Check that the graph looks the way we expect. |
| 523 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 524 |
@ royxmykxtrkr M |
| 525 |
├─╮ |
| 526 |
│ ○ mzvwutvlkqwt 1 |
| 527 |
○ │ zsuskulnrvyr z |
| 528 |
├───╮ |
| 529 |
│ │ ○ kkmpptxzrspx y |
| 530 |
│ ├─╯ |
| 531 |
○ │ qpvuntsmwlqt x |
| 532 |
├─╯ |
| 533 |
◆ zzzzzzzzzzzz |
| 534 |
[EOF] |
| 535 |
"); |
| 536 |
let setup_opid = work_dir.current_operation_id(); |
| 537 |
|
| 538 |
let output = work_dir.run_jj_with(|cmd| force_interactive(cmd).arg("prev").write_stdin("2\n")); |
| 539 |
insta::assert_snapshot!(output, @" |
| 540 |
------- stderr ------- |
| 541 |
ambiguous prev commit, choose one to target: |
| 542 |
1: kkmpptxz ab947132 (empty) y |
| 543 |
2: qpvuntsm 007e88d2 (empty) x |
| 544 |
3: zzzzzzzz 00000000 (empty) (no description set) |
| 545 |
q: quit the prompt |
| 546 |
enter the index of the commit you want to target: Working copy (@) now at: vruxwmqv ff8922ba (empty) (no description set) |
| 547 |
Parent commit (@-) : qpvuntsm 007e88d2 (empty) x |
| 548 |
[EOF] |
| 549 |
"); |
| 550 |
|
| 551 |
work_dir.run_jj(["op", "restore", &setup_opid]).success(); |
| 552 |
let output = work_dir.run_jj_with(|cmd| { |
| 553 |
force_interactive(cmd) |
| 554 |
.args(["prev", "--edit"]) |
| 555 |
.write_stdin("2\n") |
| 556 |
}); |
| 557 |
insta::assert_snapshot!(output, @" |
| 558 |
------- stderr ------- |
| 559 |
ambiguous prev commit, choose one to target: |
| 560 |
1: mzvwutvl 0e8fc48c (empty) 1 |
| 561 |
2: zsuskuln e7382ca4 (empty) z |
| 562 |
q: quit the prompt |
| 563 |
enter the index of the commit you want to target: Working copy (@) now at: zsuskuln e7382ca4 (empty) z |
| 564 |
Parent commit (@-) : qpvuntsm 007e88d2 (empty) x |
| 565 |
Parent commit (@-) : kkmpptxz ab947132 (empty) y |
| 566 |
[EOF] |
| 567 |
"); |
| 568 |
} |
| 569 |
|
| 570 |
#[test] |
| 571 |
fn test_prev_prompts_on_multiple_parents() { |
| 572 |
let test_env = TestEnvironment::default(); |
| 573 |
test_env.run_jj_in(".", ["git", "init", "repo"]).success(); |
| 574 |
let work_dir = test_env.work_dir("repo"); |
| 575 |
work_dir.run_jj(["commit", "-m", "first"]).success(); |
| 576 |
work_dir.run_jj(["new", "@--"]).success(); |
| 577 |
work_dir.run_jj(["commit", "-m", "second"]).success(); |
| 578 |
work_dir.run_jj(["new", "@--"]).success(); |
| 579 |
work_dir.run_jj(["commit", "-m", "third"]).success(); |
| 580 |
// Create a merge commit, which has two parents. |
| 581 |
work_dir.run_jj(["new", "@--+"]).success(); |
| 582 |
work_dir.run_jj(["commit", "-m", "merge"]).success(); |
| 583 |
work_dir.run_jj(["commit", "-m", "merge+1"]).success(); |
| 584 |
|
| 585 |
// Check that the graph looks the way we expect. |
| 586 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 587 |
@ yostqsxwqrlt |
| 588 |
○ vruxwmqvtpmx merge+1 |
| 589 |
○ yqosqzytrlsw merge |
| 590 |
├─┬─╮ |
| 591 |
│ │ ○ qpvuntsmwlqt first |
| 592 |
│ ○ │ kkmpptxzrspx second |
| 593 |
│ ├─╯ |
| 594 |
○ │ mzvwutvlkqwt third |
| 595 |
├─╯ |
| 596 |
◆ zzzzzzzzzzzz |
| 597 |
[EOF] |
| 598 |
"); |
| 599 |
|
| 600 |
// Move @ backwards. |
| 601 |
let output = work_dir.run_jj_with(|cmd| { |
| 602 |
force_interactive(cmd) |
| 603 |
.args(["prev", "2"]) |
| 604 |
.write_stdin("3\n") |
| 605 |
}); |
| 606 |
insta::assert_snapshot!(output, @" |
| 607 |
------- stderr ------- |
| 608 |
ambiguous prev commit, choose one to target: |
| 609 |
1: mzvwutvl 5ec63817 (empty) third |
| 610 |
2: kkmpptxz e8959fbd (empty) second |
| 611 |
3: qpvuntsm 68a50538 (empty) first |
| 612 |
q: quit the prompt |
| 613 |
enter the index of the commit you want to target: Working copy (@) now at: kpqxywon 5448803a (empty) (no description set) |
| 614 |
Parent commit (@-) : qpvuntsm 68a50538 (empty) first |
| 615 |
[EOF] |
| 616 |
"); |
| 617 |
|
| 618 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 619 |
@ kpqxywonksrl |
| 620 |
│ ○ vruxwmqvtpmx merge+1 |
| 621 |
│ ○ yqosqzytrlsw merge |
| 622 |
╭─┼─╮ |
| 623 |
○ │ │ qpvuntsmwlqt first |
| 624 |
│ │ ○ kkmpptxzrspx second |
| 625 |
├───╯ |
| 626 |
│ ○ mzvwutvlkqwt third |
| 627 |
├─╯ |
| 628 |
◆ zzzzzzzzzzzz |
| 629 |
[EOF] |
| 630 |
"); |
| 631 |
|
| 632 |
work_dir.run_jj(["next"]).success(); |
| 633 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 634 |
@ wqnwkozpkust |
| 635 |
│ ○ vruxwmqvtpmx merge+1 |
| 636 |
├─╯ |
| 637 |
○ yqosqzytrlsw merge |
| 638 |
├─┬─╮ |
| 639 |
│ │ ○ qpvuntsmwlqt first |
| 640 |
│ ○ │ kkmpptxzrspx second |
| 641 |
│ ├─╯ |
| 642 |
○ │ mzvwutvlkqwt third |
| 643 |
├─╯ |
| 644 |
◆ zzzzzzzzzzzz |
| 645 |
[EOF] |
| 646 |
"); |
| 647 |
} |
| 648 |
|
| 649 |
#[test] |
| 650 |
fn test_prev_beyond_root_fails() { |
| 651 |
let test_env = TestEnvironment::default(); |
| 652 |
test_env.run_jj_in(".", ["git", "init", "repo"]).success(); |
| 653 |
let work_dir = test_env.work_dir("repo"); |
| 654 |
work_dir.run_jj(["commit", "-m", "first"]).success(); |
| 655 |
work_dir.run_jj(["commit", "-m", "second"]).success(); |
| 656 |
work_dir.run_jj(["commit", "-m", "third"]).success(); |
| 657 |
work_dir.run_jj(["commit", "-m", "fourth"]).success(); |
| 658 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 659 |
@ mzvwutvlkqwt |
| 660 |
○ zsuskulnrvyr fourth |
| 661 |
○ kkmpptxzrspx third |
| 662 |
○ rlvkpnrzqnoo second |
| 663 |
○ qpvuntsmwlqt first |
| 664 |
◆ zzzzzzzzzzzz |
| 665 |
[EOF] |
| 666 |
"); |
| 667 |
// @- is at "fourth", and there is no parent 5 commits behind it. |
| 668 |
let output = work_dir.run_jj(["prev", "5"]); |
| 669 |
insta::assert_snapshot!(output,@" |
| 670 |
------- stderr ------- |
| 671 |
Error: No ancestor found 5 commit(s) back from the working copy parents(s) |
| 672 |
Hint: Working copy parent: zsuskuln c5025ce1 (empty) fourth |
| 673 |
[EOF] |
| 674 |
[exit status: 1] |
| 675 |
"); |
| 676 |
} |
| 677 |
|
| 678 |
#[test] |
| 679 |
fn test_prev_editing() { |
| 680 |
// Edit the third commit. |
| 681 |
let test_env = TestEnvironment::default(); |
| 682 |
test_env.run_jj_in(".", ["git", "init", "repo"]).success(); |
| 683 |
let work_dir = test_env.work_dir("repo"); |
| 684 |
work_dir.run_jj(["commit", "-m", "first"]).success(); |
| 685 |
work_dir.run_jj(["commit", "-m", "second"]).success(); |
| 686 |
work_dir.run_jj(["commit", "-m", "third"]).success(); |
| 687 |
work_dir.run_jj(["commit", "-m", "fourth"]).success(); |
| 688 |
// Edit the "fourth" commit, which becomes the leaf. |
| 689 |
work_dir.run_jj(["edit", "@-"]).success(); |
| 690 |
// Check that the graph looks the way we expect. |
| 691 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 692 |
@ zsuskulnrvyr fourth |
| 693 |
○ kkmpptxzrspx third |
| 694 |
○ rlvkpnrzqnoo second |
| 695 |
○ qpvuntsmwlqt first |
| 696 |
◆ zzzzzzzzzzzz |
| 697 |
[EOF] |
| 698 |
"); |
| 699 |
|
| 700 |
let output = work_dir.run_jj(["prev", "--edit"]); |
| 701 |
insta::assert_snapshot!(output, @" |
| 702 |
------- stderr ------- |
| 703 |
Working copy (@) now at: kkmpptxz 7576de42 (empty) third |
| 704 |
Parent commit (@-) : rlvkpnrz 9439bf06 (empty) second |
| 705 |
[EOF] |
| 706 |
"); |
| 707 |
|
| 708 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 709 |
○ zsuskulnrvyr fourth |
| 710 |
@ kkmpptxzrspx third |
| 711 |
○ rlvkpnrzqnoo second |
| 712 |
○ qpvuntsmwlqt first |
| 713 |
◆ zzzzzzzzzzzz |
| 714 |
[EOF] |
| 715 |
"); |
| 716 |
} |
| 717 |
|
| 718 |
#[test] |
| 719 |
fn test_next_editing() { |
| 720 |
// Edit the second commit. |
| 721 |
let test_env = TestEnvironment::default(); |
| 722 |
test_env.run_jj_in(".", ["git", "init", "repo"]).success(); |
| 723 |
let work_dir = test_env.work_dir("repo"); |
| 724 |
work_dir.run_jj(["commit", "-m", "first"]).success(); |
| 725 |
work_dir.run_jj(["commit", "-m", "second"]).success(); |
| 726 |
work_dir.run_jj(["commit", "-m", "third"]).success(); |
| 727 |
work_dir.run_jj(["commit", "-m", "fourth"]).success(); |
| 728 |
work_dir.run_jj(["edit", "@---"]).success(); |
| 729 |
|
| 730 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 731 |
○ zsuskulnrvyr fourth |
| 732 |
○ kkmpptxzrspx third |
| 733 |
@ rlvkpnrzqnoo second |
| 734 |
○ qpvuntsmwlqt first |
| 735 |
◆ zzzzzzzzzzzz |
| 736 |
[EOF] |
| 737 |
"); |
| 738 |
|
| 739 |
let output = work_dir.run_jj(["next", "--edit"]); |
| 740 |
insta::assert_snapshot!(output, @" |
| 741 |
------- stderr ------- |
| 742 |
Working copy (@) now at: kkmpptxz 7576de42 (empty) third |
| 743 |
Parent commit (@-) : rlvkpnrz 9439bf06 (empty) second |
| 744 |
[EOF] |
| 745 |
"); |
| 746 |
|
| 747 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 748 |
○ zsuskulnrvyr fourth |
| 749 |
@ kkmpptxzrspx third |
| 750 |
○ rlvkpnrzqnoo second |
| 751 |
○ qpvuntsmwlqt first |
| 752 |
◆ zzzzzzzzzzzz |
| 753 |
[EOF] |
| 754 |
"); |
| 755 |
} |
| 756 |
|
| 757 |
#[test] |
| 758 |
fn test_prev_conflict() { |
| 759 |
// Make the first commit our new parent. |
| 760 |
let test_env = TestEnvironment::default(); |
| 761 |
test_env.run_jj_in(".", ["git", "init", "repo"]).success(); |
| 762 |
let work_dir = test_env.work_dir("repo"); |
| 763 |
work_dir.write_file("content.txt", "first"); |
| 764 |
work_dir.run_jj(["commit", "-m", "first"]).success(); |
| 765 |
work_dir.write_file("content.txt", "second"); |
| 766 |
work_dir.run_jj(["commit", "-m", "second"]).success(); |
| 767 |
work_dir.run_jj(["commit", "-m", "third"]).success(); |
| 768 |
// Create a conflict in the first commit, where we'll jump to. |
| 769 |
work_dir.run_jj(["edit", "subject(first)"]).success(); |
| 770 |
work_dir.write_file("content.txt", "first+1"); |
| 771 |
work_dir.run_jj(["new", "subject(third)"]).success(); |
| 772 |
work_dir.run_jj(["commit", "-m", "fourth"]).success(); |
| 773 |
// Test the setup |
| 774 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 775 |
@ yqosqzytrlsw conflict |
| 776 |
× royxmykxtrkr conflict fourth |
| 777 |
× kkmpptxzrspx conflict third |
| 778 |
× rlvkpnrzqnoo conflict second |
| 779 |
○ qpvuntsmwlqt first |
| 780 |
◆ zzzzzzzzzzzz |
| 781 |
[EOF] |
| 782 |
"); |
| 783 |
work_dir.run_jj(["prev", "--conflict"]).success(); |
| 784 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 785 |
@ yostqsxwqrlt conflict |
| 786 |
│ × royxmykxtrkr conflict fourth |
| 787 |
├─╯ |
| 788 |
× kkmpptxzrspx conflict third |
| 789 |
× rlvkpnrzqnoo conflict second |
| 790 |
○ qpvuntsmwlqt first |
| 791 |
◆ zzzzzzzzzzzz |
| 792 |
[EOF] |
| 793 |
"); |
| 794 |
} |
| 795 |
|
| 796 |
#[test] |
| 797 |
fn test_prev_conflict_editing() { |
| 798 |
// Edit the third commit. |
| 799 |
let test_env = TestEnvironment::default(); |
| 800 |
test_env.run_jj_in(".", ["git", "init", "repo"]).success(); |
| 801 |
let work_dir = test_env.work_dir("repo"); |
| 802 |
work_dir.run_jj(["commit", "-m", "first"]).success(); |
| 803 |
work_dir.run_jj(["commit", "-m", "second"]).success(); |
| 804 |
work_dir.write_file("content.txt", "second"); |
| 805 |
work_dir.run_jj(["commit", "-m", "third"]).success(); |
| 806 |
// Create a conflict in the third commit, where we'll jump to. |
| 807 |
work_dir.run_jj(["edit", "subject(first)"]).success(); |
| 808 |
work_dir.write_file("content.txt", "first text"); |
| 809 |
work_dir.run_jj(["new", "subject(third)"]).success(); |
| 810 |
// Test the setup |
| 811 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 812 |
@ royxmykxtrkr conflict |
| 813 |
× kkmpptxzrspx conflict third |
| 814 |
○ rlvkpnrzqnoo second |
| 815 |
○ qpvuntsmwlqt first |
| 816 |
◆ zzzzzzzzzzzz |
| 817 |
[EOF] |
| 818 |
"); |
| 819 |
work_dir.run_jj(["prev", "--conflict", "--edit"]).success(); |
| 820 |
// We now should be editing the third commit. |
| 821 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 822 |
@ kkmpptxzrspx conflict third |
| 823 |
○ rlvkpnrzqnoo second |
| 824 |
○ qpvuntsmwlqt first |
| 825 |
◆ zzzzzzzzzzzz |
| 826 |
[EOF] |
| 827 |
"); |
| 828 |
} |
| 829 |
|
| 830 |
#[test] |
| 831 |
fn test_next_conflict() { |
| 832 |
// There is a conflict in the third commit, so after next it should be the new |
| 833 |
// parent. |
| 834 |
let test_env = TestEnvironment::default(); |
| 835 |
test_env.run_jj_in(".", ["git", "init", "repo"]).success(); |
| 836 |
let work_dir = test_env.work_dir("repo"); |
| 837 |
work_dir.write_file("content.txt", "first"); |
| 838 |
work_dir.run_jj(["commit", "-m", "first"]).success(); |
| 839 |
work_dir.run_jj(["commit", "-m", "second"]).success(); |
| 840 |
// Create a conflict in the third commit. |
| 841 |
work_dir.write_file("content.txt", "third"); |
| 842 |
work_dir.run_jj(["commit", "-m", "third"]).success(); |
| 843 |
work_dir.run_jj(["new", "subject(first)"]).success(); |
| 844 |
work_dir.write_file("content.txt", "first v2"); |
| 845 |
work_dir |
| 846 |
.run_jj(["squash", "--into", "subject(third)"]) |
| 847 |
.success(); |
| 848 |
// Test the setup |
| 849 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 850 |
@ royxmykxtrkr |
| 851 |
│ × kkmpptxzrspx conflict third |
| 852 |
│ ○ rlvkpnrzqnoo second |
| 853 |
├─╯ |
| 854 |
○ qpvuntsmwlqt first |
| 855 |
◆ zzzzzzzzzzzz |
| 856 |
[EOF] |
| 857 |
"); |
| 858 |
work_dir.run_jj(["next", "--conflict"]).success(); |
| 859 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 860 |
@ vruxwmqvtpmx conflict |
| 861 |
× kkmpptxzrspx conflict third |
| 862 |
○ rlvkpnrzqnoo second |
| 863 |
○ qpvuntsmwlqt first |
| 864 |
◆ zzzzzzzzzzzz |
| 865 |
[EOF] |
| 866 |
"); |
| 867 |
} |
| 868 |
|
| 869 |
#[test] |
| 870 |
fn test_next_conflict_editing() { |
| 871 |
// There is a conflict in the third commit, so after next it should be our |
| 872 |
// working copy. |
| 873 |
let test_env = TestEnvironment::default(); |
| 874 |
test_env.run_jj_in(".", ["git", "init", "repo"]).success(); |
| 875 |
let work_dir = test_env.work_dir("repo"); |
| 876 |
work_dir.run_jj(["commit", "-m", "first"]).success(); |
| 877 |
work_dir.write_file("content.txt", "second"); |
| 878 |
work_dir.run_jj(["commit", "-m", "second"]).success(); |
| 879 |
// Create a conflict in the third commit. |
| 880 |
work_dir.write_file("content.txt", "third"); |
| 881 |
work_dir.run_jj(["edit", "subject(second)"]).success(); |
| 882 |
work_dir.write_file("content.txt", "modified second"); |
| 883 |
work_dir.run_jj(["edit", "@-"]).success(); |
| 884 |
// Test the setup |
| 885 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 886 |
× kkmpptxzrspx conflict |
| 887 |
○ rlvkpnrzqnoo second |
| 888 |
@ qpvuntsmwlqt first |
| 889 |
◆ zzzzzzzzzzzz |
| 890 |
[EOF] |
| 891 |
"); |
| 892 |
work_dir.run_jj(["next", "--conflict", "--edit"]).success(); |
| 893 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 894 |
@ kkmpptxzrspx conflict |
| 895 |
○ rlvkpnrzqnoo second |
| 896 |
○ qpvuntsmwlqt first |
| 897 |
◆ zzzzzzzzzzzz |
| 898 |
[EOF] |
| 899 |
"); |
| 900 |
} |
| 901 |
|
| 902 |
#[test] |
| 903 |
fn test_next_conflict_head() { |
| 904 |
// When editing a head with conflicts, `jj next --conflict [--edit]` errors out. |
| 905 |
let test_env = TestEnvironment::default(); |
| 906 |
test_env.run_jj_in(".", ["git", "init", "repo"]).success(); |
| 907 |
let work_dir = test_env.work_dir("repo"); |
| 908 |
work_dir.write_file("file", "first"); |
| 909 |
work_dir.run_jj(["new"]).success(); |
| 910 |
work_dir.write_file("file", "second"); |
| 911 |
work_dir.run_jj(["abandon", "@-"]).success(); |
| 912 |
// Test the setup |
| 913 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 914 |
@ rlvkpnrzqnoo conflict |
| 915 |
◆ zzzzzzzzzzzz |
| 916 |
[EOF] |
| 917 |
"); |
| 918 |
|
| 919 |
let output = work_dir.run_jj(["next", "--conflict"]); |
| 920 |
insta::assert_snapshot!(output, @" |
| 921 |
------- stderr ------- |
| 922 |
Error: The working copy parent(s) have no other descendants with conflicts |
| 923 |
Hint: Working copy parent: zzzzzzzz 00000000 (empty) (no description set) |
| 924 |
[EOF] |
| 925 |
[exit status: 1] |
| 926 |
"); |
| 927 |
|
| 928 |
let output = work_dir.run_jj(["next", "--conflict", "--edit"]); |
| 929 |
insta::assert_snapshot!(output, @" |
| 930 |
------- stderr ------- |
| 931 |
Error: The working copy has no descendants with conflicts |
| 932 |
Hint: Working copy: rlvkpnrz 27780096 (conflict) (no description set) |
| 933 |
[EOF] |
| 934 |
[exit status: 1] |
| 935 |
"); |
| 936 |
} |
| 937 |
|
| 938 |
#[test] |
| 939 |
fn test_movement_edit_mode_true() { |
| 940 |
let test_env = TestEnvironment::default(); |
| 941 |
test_env.add_config(r#"ui.movement.edit = true"#); |
| 942 |
|
| 943 |
test_env.run_jj_in(".", ["git", "init", "repo"]).success(); |
| 944 |
let work_dir = test_env.work_dir("repo"); |
| 945 |
|
| 946 |
work_dir.run_jj(["commit", "-m", "first"]).success(); |
| 947 |
work_dir.run_jj(["commit", "-m", "second"]).success(); |
| 948 |
work_dir.run_jj(["commit", "-m", "third"]).success(); |
| 949 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 950 |
@ zsuskulnrvyr |
| 951 |
○ kkmpptxzrspx third |
| 952 |
○ rlvkpnrzqnoo second |
| 953 |
○ qpvuntsmwlqt first |
| 954 |
◆ zzzzzzzzzzzz |
| 955 |
[EOF] |
| 956 |
"); |
| 957 |
|
| 958 |
work_dir.run_jj(["prev"]).success(); |
| 959 |
|
| 960 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 961 |
@ kkmpptxzrspx third |
| 962 |
○ rlvkpnrzqnoo second |
| 963 |
○ qpvuntsmwlqt first |
| 964 |
◆ zzzzzzzzzzzz |
| 965 |
[EOF] |
| 966 |
"); |
| 967 |
|
| 968 |
let output = work_dir.run_jj(["prev"]); |
| 969 |
insta::assert_snapshot!(output, @" |
| 970 |
------- stderr ------- |
| 971 |
Working copy (@) now at: rlvkpnrz 9439bf06 (empty) second |
| 972 |
Parent commit (@-) : qpvuntsm 68a50538 (empty) first |
| 973 |
[EOF] |
| 974 |
"); |
| 975 |
|
| 976 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 977 |
○ kkmpptxzrspx third |
| 978 |
@ rlvkpnrzqnoo second |
| 979 |
○ qpvuntsmwlqt first |
| 980 |
◆ zzzzzzzzzzzz |
| 981 |
[EOF] |
| 982 |
"); |
| 983 |
|
| 984 |
let output = work_dir.run_jj(["prev"]); |
| 985 |
insta::assert_snapshot!(output, @" |
| 986 |
------- stderr ------- |
| 987 |
Working copy (@) now at: qpvuntsm 68a50538 (empty) first |
| 988 |
Parent commit (@-) : zzzzzzzz 00000000 (empty) (no description set) |
| 989 |
[EOF] |
| 990 |
"); |
| 991 |
|
| 992 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 993 |
○ kkmpptxzrspx third |
| 994 |
○ rlvkpnrzqnoo second |
| 995 |
@ qpvuntsmwlqt first |
| 996 |
◆ zzzzzzzzzzzz |
| 997 |
[EOF] |
| 998 |
"); |
| 999 |
|
| 1000 |
let output = work_dir.run_jj(["prev"]); |
| 1001 |
insta::assert_snapshot!(output, @" |
| 1002 |
------- stderr ------- |
| 1003 |
Error: The root commit 000000000000 is immutable |
| 1004 |
[EOF] |
| 1005 |
[exit status: 1] |
| 1006 |
"); |
| 1007 |
|
| 1008 |
let output = work_dir.run_jj(["next"]); |
| 1009 |
insta::assert_snapshot!(output, @" |
| 1010 |
------- stderr ------- |
| 1011 |
Working copy (@) now at: rlvkpnrz 9439bf06 (empty) second |
| 1012 |
Parent commit (@-) : qpvuntsm 68a50538 (empty) first |
| 1013 |
[EOF] |
| 1014 |
"); |
| 1015 |
|
| 1016 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 1017 |
○ kkmpptxzrspx third |
| 1018 |
@ rlvkpnrzqnoo second |
| 1019 |
○ qpvuntsmwlqt first |
| 1020 |
◆ zzzzzzzzzzzz |
| 1021 |
[EOF] |
| 1022 |
"); |
| 1023 |
|
| 1024 |
let output = work_dir.run_jj(["next"]); |
| 1025 |
insta::assert_snapshot!(output, @" |
| 1026 |
------- stderr ------- |
| 1027 |
Working copy (@) now at: kkmpptxz 7576de42 (empty) third |
| 1028 |
Parent commit (@-) : rlvkpnrz 9439bf06 (empty) second |
| 1029 |
[EOF] |
| 1030 |
"); |
| 1031 |
|
| 1032 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 1033 |
@ kkmpptxzrspx third |
| 1034 |
○ rlvkpnrzqnoo second |
| 1035 |
○ qpvuntsmwlqt first |
| 1036 |
◆ zzzzzzzzzzzz |
| 1037 |
[EOF] |
| 1038 |
"); |
| 1039 |
|
| 1040 |
let output = work_dir.run_jj(["prev", "--no-edit"]); |
| 1041 |
insta::assert_snapshot!(output, @" |
| 1042 |
------- stderr ------- |
| 1043 |
Working copy (@) now at: uyznsvlq 1062d305 (empty) (no description set) |
| 1044 |
Parent commit (@-) : qpvuntsm 68a50538 (empty) first |
| 1045 |
[EOF] |
| 1046 |
"); |
| 1047 |
|
| 1048 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 1049 |
@ uyznsvlquzzm |
| 1050 |
│ ○ kkmpptxzrspx third |
| 1051 |
│ ○ rlvkpnrzqnoo second |
| 1052 |
├─╯ |
| 1053 |
○ qpvuntsmwlqt first |
| 1054 |
◆ zzzzzzzzzzzz |
| 1055 |
[EOF] |
| 1056 |
"); |
| 1057 |
|
| 1058 |
let output = work_dir.run_jj(["next", "--no-edit"]); |
| 1059 |
insta::assert_snapshot!(output, @" |
| 1060 |
------- stderr ------- |
| 1061 |
Working copy (@) now at: xtnwkqum ccbc5bff (empty) (no description set) |
| 1062 |
Parent commit (@-) : rlvkpnrz 9439bf06 (empty) second |
| 1063 |
[EOF] |
| 1064 |
"); |
| 1065 |
|
| 1066 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 1067 |
@ xtnwkqumpolk |
| 1068 |
│ ○ kkmpptxzrspx third |
| 1069 |
├─╯ |
| 1070 |
○ rlvkpnrzqnoo second |
| 1071 |
○ qpvuntsmwlqt first |
| 1072 |
◆ zzzzzzzzzzzz |
| 1073 |
[EOF] |
| 1074 |
"); |
| 1075 |
|
| 1076 |
let output = work_dir.run_jj(["next"]); |
| 1077 |
insta::assert_snapshot!(output, @" |
| 1078 |
------- stderr ------- |
| 1079 |
Error: No descendant found 1 commit(s) forward from the working copy |
| 1080 |
Hint: Working copy: xtnwkqum ccbc5bff (empty) (no description set) |
| 1081 |
[EOF] |
| 1082 |
[exit status: 1] |
| 1083 |
"); |
| 1084 |
} |
| 1085 |
|
| 1086 |
#[test] |
| 1087 |
fn test_movement_edit_mode_false() { |
| 1088 |
let test_env = TestEnvironment::default(); |
| 1089 |
test_env.add_config(r#"ui.movement.edit = false"#); |
| 1090 |
|
| 1091 |
test_env.run_jj_in(".", ["git", "init", "repo"]).success(); |
| 1092 |
let work_dir = test_env.work_dir("repo"); |
| 1093 |
|
| 1094 |
work_dir.run_jj(["commit", "-m", "first"]).success(); |
| 1095 |
work_dir.run_jj(["commit", "-m", "second"]).success(); |
| 1096 |
work_dir.run_jj(["commit", "-m", "third"]).success(); |
| 1097 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 1098 |
@ zsuskulnrvyr |
| 1099 |
○ kkmpptxzrspx third |
| 1100 |
○ rlvkpnrzqnoo second |
| 1101 |
○ qpvuntsmwlqt first |
| 1102 |
◆ zzzzzzzzzzzz |
| 1103 |
[EOF] |
| 1104 |
"); |
| 1105 |
|
| 1106 |
work_dir.run_jj(["prev"]).success(); |
| 1107 |
|
| 1108 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 1109 |
@ royxmykxtrkr |
| 1110 |
│ ○ kkmpptxzrspx third |
| 1111 |
├─╯ |
| 1112 |
○ rlvkpnrzqnoo second |
| 1113 |
○ qpvuntsmwlqt first |
| 1114 |
◆ zzzzzzzzzzzz |
| 1115 |
[EOF] |
| 1116 |
"); |
| 1117 |
|
| 1118 |
let output = work_dir.run_jj(["prev", "--no-edit"]); |
| 1119 |
insta::assert_snapshot!(output, @" |
| 1120 |
------- stderr ------- |
| 1121 |
Working copy (@) now at: vruxwmqv 1a9aa547 (empty) (no description set) |
| 1122 |
Parent commit (@-) : qpvuntsm 68a50538 (empty) first |
| 1123 |
[EOF] |
| 1124 |
"); |
| 1125 |
|
| 1126 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 1127 |
@ vruxwmqvtpmx |
| 1128 |
│ ○ kkmpptxzrspx third |
| 1129 |
│ ○ rlvkpnrzqnoo second |
| 1130 |
├─╯ |
| 1131 |
○ qpvuntsmwlqt first |
| 1132 |
◆ zzzzzzzzzzzz |
| 1133 |
[EOF] |
| 1134 |
"); |
| 1135 |
|
| 1136 |
let output = work_dir.run_jj(["prev", "3"]); |
| 1137 |
insta::assert_snapshot!(output, @" |
| 1138 |
------- stderr ------- |
| 1139 |
Error: No ancestor found 3 commit(s) back from the working copy parents(s) |
| 1140 |
Hint: Working copy parent: qpvuntsm 68a50538 (empty) first |
| 1141 |
[EOF] |
| 1142 |
[exit status: 1] |
| 1143 |
"); |
| 1144 |
|
| 1145 |
let output = work_dir.run_jj(["next"]); |
| 1146 |
insta::assert_snapshot!(output, @" |
| 1147 |
------- stderr ------- |
| 1148 |
Working copy (@) now at: kpqxywon 97dd6a5a (empty) (no description set) |
| 1149 |
Parent commit (@-) : rlvkpnrz 9439bf06 (empty) second |
| 1150 |
[EOF] |
| 1151 |
"); |
| 1152 |
|
| 1153 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 1154 |
@ kpqxywonksrl |
| 1155 |
│ ○ kkmpptxzrspx third |
| 1156 |
├─╯ |
| 1157 |
○ rlvkpnrzqnoo second |
| 1158 |
○ qpvuntsmwlqt first |
| 1159 |
◆ zzzzzzzzzzzz |
| 1160 |
[EOF] |
| 1161 |
"); |
| 1162 |
|
| 1163 |
let output = work_dir.run_jj(["next", "--no-edit"]); |
| 1164 |
insta::assert_snapshot!(output, @" |
| 1165 |
------- stderr ------- |
| 1166 |
Working copy (@) now at: wqnwkozp 525e0f84 (empty) (no description set) |
| 1167 |
Parent commit (@-) : kkmpptxz 7576de42 (empty) third |
| 1168 |
[EOF] |
| 1169 |
"); |
| 1170 |
|
| 1171 |
let output = work_dir.run_jj(["prev", "--edit", "2"]); |
| 1172 |
insta::assert_snapshot!(output, @" |
| 1173 |
------- stderr ------- |
| 1174 |
Working copy (@) now at: rlvkpnrz 9439bf06 (empty) second |
| 1175 |
Parent commit (@-) : qpvuntsm 68a50538 (empty) first |
| 1176 |
[EOF] |
| 1177 |
"); |
| 1178 |
|
| 1179 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 1180 |
○ kkmpptxzrspx third |
| 1181 |
@ rlvkpnrzqnoo second |
| 1182 |
○ qpvuntsmwlqt first |
| 1183 |
◆ zzzzzzzzzzzz |
| 1184 |
[EOF] |
| 1185 |
"); |
| 1186 |
|
| 1187 |
let output = work_dir.run_jj(["next", "--edit"]); |
| 1188 |
insta::assert_snapshot!(output, @" |
| 1189 |
------- stderr ------- |
| 1190 |
Working copy (@) now at: kkmpptxz 7576de42 (empty) third |
| 1191 |
Parent commit (@-) : rlvkpnrz 9439bf06 (empty) second |
| 1192 |
[EOF] |
| 1193 |
"); |
| 1194 |
|
| 1195 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 1196 |
@ kkmpptxzrspx third |
| 1197 |
○ rlvkpnrzqnoo second |
| 1198 |
○ qpvuntsmwlqt first |
| 1199 |
◆ zzzzzzzzzzzz |
| 1200 |
[EOF] |
| 1201 |
"); |
| 1202 |
} |
| 1203 |
|
| 1204 |
#[test] |
| 1205 |
fn test_next_when_wc_has_descendants() { |
| 1206 |
let test_env = TestEnvironment::default(); |
| 1207 |
test_env.add_config(r#"ui.movement.edit = false"#); |
| 1208 |
|
| 1209 |
test_env.run_jj_in(".", ["git", "init", "repo"]).success(); |
| 1210 |
let work_dir = test_env.work_dir("repo"); |
| 1211 |
|
| 1212 |
work_dir.run_jj(["commit", "-m", "base"]).success(); |
| 1213 |
work_dir.run_jj(["commit", "-m", "right-wc"]).success(); |
| 1214 |
work_dir.run_jj(["commit", "-m", "right-1"]).success(); |
| 1215 |
work_dir.run_jj(["commit", "-m", "right-2"]).success(); |
| 1216 |
work_dir.run_jj(["edit", "subject(right-wc)"]).success(); |
| 1217 |
|
| 1218 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 1219 |
○ zsuskulnrvyr right-2 |
| 1220 |
○ kkmpptxzrspx right-1 |
| 1221 |
@ rlvkpnrzqnoo right-wc |
| 1222 |
○ qpvuntsmwlqt base |
| 1223 |
◆ zzzzzzzzzzzz |
| 1224 |
[EOF] |
| 1225 |
"); |
| 1226 |
|
| 1227 |
let output = work_dir.run_jj(["next", "2"]); |
| 1228 |
insta::assert_snapshot!(output, @" |
| 1229 |
------- stderr ------- |
| 1230 |
Error: The working copy must not have any children |
| 1231 |
Hint: Create a new commit on top of this one or use `--edit` |
| 1232 |
[EOF] |
| 1233 |
[exit status: 1] |
| 1234 |
"); |
| 1235 |
} |
| 1236 |
|
| 1237 |
#[must_use] |
| 1238 |
fn get_log_output(work_dir: &TestWorkDir) -> CommandOutput { |
| 1239 |
let template = r#"separate(" ", change_id.short(), local_bookmarks, if(conflict, "conflict"), description)"#; |
| 1240 |
work_dir.run_jj(["log", "-T", template]) |
| 1241 |
} |