| 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 |
use crate::common::CommandOutput; |
| 16 |
use crate::common::TestEnvironment; |
| 17 |
use crate::common::TestWorkDir; |
| 18 |
use crate::common::create_commit; |
| 19 |
|
| 20 |
#[test] |
| 21 |
fn test_basics() { |
| 22 |
let test_env = TestEnvironment::default(); |
| 23 |
test_env.run_jj_in(".", ["git", "init", "repo"]).success(); |
| 24 |
let work_dir = test_env.work_dir("repo"); |
| 25 |
|
| 26 |
create_commit(&work_dir, "a", &[]); |
| 27 |
create_commit(&work_dir, "b", &["a"]); |
| 28 |
create_commit(&work_dir, "c", &[]); |
| 29 |
create_commit(&work_dir, "d", &["c"]); |
| 30 |
create_commit(&work_dir, "e", &["a", "d"]); |
| 31 |
// Test the setup |
| 32 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 33 |
@ [znk] e |
| 34 |
├─╮ |
| 35 |
│ ○ [vru] d |
| 36 |
│ ○ [roy] c |
| 37 |
│ │ ○ [zsu] b |
| 38 |
├───╯ |
| 39 |
○ │ [rlv] a |
| 40 |
├─╯ |
| 41 |
◆ [zzz] |
| 42 |
[EOF] |
| 43 |
"); |
| 44 |
let setup_opid = work_dir.current_operation_id(); |
| 45 |
|
| 46 |
let output = work_dir.run_jj(["abandon", "--retain-bookmarks", "d"]); |
| 47 |
insta::assert_snapshot!(output, @r" |
| 48 |
------- stderr ------- |
| 49 |
Abandoned 1 commits: |
| 50 |
vruxwmqv 636920e4 d | d |
| 51 |
Rebased 1 descendant commits onto parents of abandoned commits. |
| 52 |
Working copy (@) now at: znkkpsqq 38e96a1f e | e |
| 53 |
Parent commit (@-) : rlvkpnrz 7d980be7 a | a |
| 54 |
Parent commit (@-) : royxmykx c12952d9 c d | c |
| 55 |
Added 0 files, modified 0 files, removed 1 files |
| 56 |
[EOF] |
| 57 |
"); |
| 58 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 59 |
@ [znk] e |
| 60 |
├─╮ |
| 61 |
│ ○ [roy] c d |
| 62 |
│ │ ○ [zsu] b |
| 63 |
├───╯ |
| 64 |
○ │ [rlv] a |
| 65 |
├─╯ |
| 66 |
◆ [zzz] |
| 67 |
[EOF] |
| 68 |
"); |
| 69 |
|
| 70 |
work_dir.run_jj(["op", "restore", &setup_opid]).success(); |
| 71 |
let output = work_dir.run_jj(["abandon", "--retain-bookmarks"]); // abandons `e` |
| 72 |
insta::assert_snapshot!(output, @" |
| 73 |
------- stderr ------- |
| 74 |
Abandoned 1 commits: |
| 75 |
znkkpsqq 03e0d4bf e | e |
| 76 |
Working copy (@) now at: nkmrtpmo 179731fc (empty) (no description set) |
| 77 |
Parent commit (@-) : rlvkpnrz 7d980be7 a e?? | a |
| 78 |
Parent commit (@-) : vruxwmqv 636920e4 d e?? | d |
| 79 |
Added 0 files, modified 0 files, removed 1 files |
| 80 |
[EOF] |
| 81 |
"); |
| 82 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 83 |
@ [nkm] |
| 84 |
├─╮ |
| 85 |
│ ○ [vru] d e?? |
| 86 |
│ ○ [roy] c |
| 87 |
│ │ ○ [zsu] b |
| 88 |
├───╯ |
| 89 |
○ │ [rlv] a e?? |
| 90 |
├─╯ |
| 91 |
◆ [zzz] |
| 92 |
[EOF] |
| 93 |
"); |
| 94 |
|
| 95 |
work_dir.run_jj(["op", "restore", &setup_opid]).success(); |
| 96 |
let output = work_dir.run_jj(["abandon", "descendants(d)"]); |
| 97 |
insta::assert_snapshot!(output, @" |
| 98 |
------- stderr ------- |
| 99 |
Abandoned 2 commits: |
| 100 |
znkkpsqq 03e0d4bf e | e |
| 101 |
vruxwmqv 636920e4 d | d |
| 102 |
Deleted bookmarks: d, e |
| 103 |
Working copy (@) now at: xtnwkqum 1c70f4d2 (empty) (no description set) |
| 104 |
Parent commit (@-) : rlvkpnrz 7d980be7 a | a |
| 105 |
Parent commit (@-) : royxmykx c12952d9 c | c |
| 106 |
Added 0 files, modified 0 files, removed 2 files |
| 107 |
[EOF] |
| 108 |
"); |
| 109 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 110 |
@ [xtn] |
| 111 |
├─╮ |
| 112 |
│ ○ [roy] c |
| 113 |
│ │ ○ [zsu] b |
| 114 |
├───╯ |
| 115 |
○ │ [rlv] a |
| 116 |
├─╯ |
| 117 |
◆ [zzz] |
| 118 |
[EOF] |
| 119 |
"); |
| 120 |
|
| 121 |
// Test abandoning the same commit twice directly |
| 122 |
work_dir.run_jj(["op", "restore", &setup_opid]).success(); |
| 123 |
let output = work_dir.run_jj(["abandon", "-rb", "b"]); |
| 124 |
insta::assert_snapshot!(output, @" |
| 125 |
------- stderr ------- |
| 126 |
Abandoned 1 commits: |
| 127 |
zsuskuln 123b4d91 b | b |
| 128 |
Deleted bookmarks: b |
| 129 |
[EOF] |
| 130 |
"); |
| 131 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 132 |
@ [znk] e |
| 133 |
├─╮ |
| 134 |
│ ○ [vru] d |
| 135 |
│ ○ [roy] c |
| 136 |
○ │ [rlv] a |
| 137 |
├─╯ |
| 138 |
◆ [zzz] |
| 139 |
[EOF] |
| 140 |
"); |
| 141 |
|
| 142 |
// Test abandoning the same commit twice indirectly |
| 143 |
work_dir.run_jj(["op", "restore", &setup_opid]).success(); |
| 144 |
let output = work_dir.run_jj(["abandon", "d::", "e"]); |
| 145 |
insta::assert_snapshot!(output, @" |
| 146 |
------- stderr ------- |
| 147 |
Abandoned 2 commits: |
| 148 |
znkkpsqq 03e0d4bf e | e |
| 149 |
vruxwmqv 636920e4 d | d |
| 150 |
Deleted bookmarks: d, e |
| 151 |
Working copy (@) now at: xlzxqlsl 55d5c4c2 (empty) (no description set) |
| 152 |
Parent commit (@-) : rlvkpnrz 7d980be7 a | a |
| 153 |
Parent commit (@-) : royxmykx c12952d9 c | c |
| 154 |
Added 0 files, modified 0 files, removed 2 files |
| 155 |
[EOF] |
| 156 |
"); |
| 157 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 158 |
@ [xlz] |
| 159 |
├─╮ |
| 160 |
│ ○ [roy] c |
| 161 |
│ │ ○ [zsu] b |
| 162 |
├───╯ |
| 163 |
○ │ [rlv] a |
| 164 |
├─╯ |
| 165 |
◆ [zzz] |
| 166 |
[EOF] |
| 167 |
"); |
| 168 |
|
| 169 |
let output = work_dir.run_jj(["abandon", "none()"]); |
| 170 |
insta::assert_snapshot!(output, @" |
| 171 |
------- stderr ------- |
| 172 |
No revisions to abandon. |
| 173 |
[EOF] |
| 174 |
"); |
| 175 |
} |
| 176 |
|
| 177 |
#[test] |
| 178 |
fn test_abandon_many() { |
| 179 |
let test_env = TestEnvironment::default(); |
| 180 |
test_env.run_jj_in(".", ["git", "init", "repo"]).success(); |
| 181 |
let work_dir = test_env.work_dir("repo"); |
| 182 |
|
| 183 |
for i in 0..10 { |
| 184 |
work_dir.run_jj(["new", &format!("-mcommit{i}")]).success(); |
| 185 |
} |
| 186 |
|
| 187 |
// The list of commits should be elided. |
| 188 |
let output = work_dir.run_jj(["abandon", ".."]); |
| 189 |
insta::assert_snapshot!(output, @" |
| 190 |
------- stderr ------- |
| 191 |
Abandoned 11 commits: |
| 192 |
kpqxywon 6faec5d1 (empty) commit9 |
| 193 |
znkkpsqq 80f67a53 (empty) commit8 |
| 194 |
yostqsxw 8bd72fcc (empty) commit7 |
| 195 |
vruxwmqv 06c46771 (empty) commit6 |
| 196 |
yqosqzyt 168813e3 (empty) commit5 |
| 197 |
royxmykx bd8c3571 (empty) commit4 |
| 198 |
mzvwutvl 57958fa0 (empty) commit3 |
| 199 |
zsuskuln 59515644 (empty) commit2 |
| 200 |
kkmpptxz a969596d (empty) commit1 |
| 201 |
rlvkpnrz 02fe38c9 (empty) commit0 |
| 202 |
... |
| 203 |
Working copy (@) now at: kmkuslsw a36a913b (empty) (no description set) |
| 204 |
Parent commit (@-) : zzzzzzzz 00000000 (empty) (no description set) |
| 205 |
[EOF] |
| 206 |
"); |
| 207 |
} |
| 208 |
|
| 209 |
// This behavior illustrates https://github.com/jj-vcs/jj/issues/2600. |
| 210 |
// See also the corresponding test in `test_rebase_command` |
| 211 |
#[test] |
| 212 |
fn test_bug_2600() { |
| 213 |
let test_env = TestEnvironment::default(); |
| 214 |
test_env.run_jj_in(".", ["git", "init", "repo"]).success(); |
| 215 |
let work_dir = test_env.work_dir("repo"); |
| 216 |
|
| 217 |
// We will not touch "nottherootcommit". See the |
| 218 |
// `test_bug_2600_rootcommit_special_case` for the one case where base being the |
| 219 |
// child of the root commit changes the expected behavior. |
| 220 |
create_commit(&work_dir, "nottherootcommit", &[]); |
| 221 |
create_commit(&work_dir, "base", &["nottherootcommit"]); |
| 222 |
create_commit(&work_dir, "a", &["base"]); |
| 223 |
create_commit(&work_dir, "b", &["base", "a"]); |
| 224 |
create_commit(&work_dir, "c", &["b"]); |
| 225 |
|
| 226 |
// Test the setup |
| 227 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 228 |
@ [znk] c |
| 229 |
○ [vru] b |
| 230 |
├─╮ |
| 231 |
│ ○ [roy] a |
| 232 |
├─╯ |
| 233 |
○ [zsu] base |
| 234 |
○ [rlv] nottherootcommit |
| 235 |
◆ [zzz] |
| 236 |
[EOF] |
| 237 |
"); |
| 238 |
let setup_opid = work_dir.current_operation_id(); |
| 239 |
|
| 240 |
work_dir.run_jj(["op", "restore", &setup_opid]).success(); |
| 241 |
let output = work_dir.run_jj(["abandon", "base"]); |
| 242 |
insta::assert_snapshot!(output, @r" |
| 243 |
------- stderr ------- |
| 244 |
Abandoned 1 commits: |
| 245 |
zsuskuln 67c2f714 base | base |
| 246 |
Deleted bookmarks: base |
| 247 |
Rebased 3 descendant commits onto parents of abandoned commits. |
| 248 |
Working copy (@) now at: znkkpsqq c1223866 c | c |
| 249 |
Parent commit (@-) : vruxwmqv 1dfaa834 b | b |
| 250 |
Added 0 files, modified 0 files, removed 1 files |
| 251 |
[EOF] |
| 252 |
"); |
| 253 |
// Commits "a" and "b" should both have "nottherootcommit" as parent, and "b" |
| 254 |
// should keep "a" as second parent. |
| 255 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 256 |
@ [znk] c |
| 257 |
○ [vru] b |
| 258 |
├─╮ |
| 259 |
│ ○ [roy] a |
| 260 |
├─╯ |
| 261 |
○ [rlv] nottherootcommit |
| 262 |
◆ [zzz] |
| 263 |
[EOF] |
| 264 |
"); |
| 265 |
|
| 266 |
work_dir.run_jj(["op", "restore", &setup_opid]).success(); |
| 267 |
let output = work_dir.run_jj(["abandon", "a"]); |
| 268 |
insta::assert_snapshot!(output, @r" |
| 269 |
------- stderr ------- |
| 270 |
Abandoned 1 commits: |
| 271 |
royxmykx 183dbbca a | a |
| 272 |
Deleted bookmarks: a |
| 273 |
Rebased 2 descendant commits onto parents of abandoned commits. |
| 274 |
Working copy (@) now at: znkkpsqq f863da3f c | c |
| 275 |
Parent commit (@-) : vruxwmqv d7aed853 b | b |
| 276 |
Added 0 files, modified 0 files, removed 1 files |
| 277 |
[EOF] |
| 278 |
"); |
| 279 |
// Commit "b" should have "base" as parent. It should not have two parent |
| 280 |
// pointers to that commit even though it was a merge commit before we abandoned |
| 281 |
// "a". |
| 282 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 283 |
@ [znk] c |
| 284 |
○ [vru] b |
| 285 |
○ [zsu] base |
| 286 |
○ [rlv] nottherootcommit |
| 287 |
◆ [zzz] |
| 288 |
[EOF] |
| 289 |
"); |
| 290 |
|
| 291 |
work_dir.run_jj(["op", "restore", &setup_opid]).success(); |
| 292 |
let output = work_dir.run_jj(["abandon", "b"]); |
| 293 |
insta::assert_snapshot!(output, @r" |
| 294 |
------- stderr ------- |
| 295 |
Abandoned 1 commits: |
| 296 |
vruxwmqv cedee197 b | b |
| 297 |
Deleted bookmarks: b |
| 298 |
Rebased 1 descendant commits onto parents of abandoned commits. |
| 299 |
Working copy (@) now at: znkkpsqq 4dc308fb c | c |
| 300 |
Parent commit (@-) : zsuskuln 67c2f714 base | base |
| 301 |
Parent commit (@-) : royxmykx 183dbbca a | a |
| 302 |
Added 0 files, modified 0 files, removed 1 files |
| 303 |
[EOF] |
| 304 |
"); |
| 305 |
// Commit "c" should inherit the parents from the abndoned commit "b". |
| 306 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 307 |
@ [znk] c |
| 308 |
├─╮ |
| 309 |
│ ○ [roy] a |
| 310 |
├─╯ |
| 311 |
○ [zsu] base |
| 312 |
○ [rlv] nottherootcommit |
| 313 |
◆ [zzz] |
| 314 |
[EOF] |
| 315 |
"); |
| 316 |
|
| 317 |
work_dir.run_jj(["op", "restore", &setup_opid]).success(); |
| 318 |
// ========= Reminder of the setup =========== |
| 319 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 320 |
@ [znk] c |
| 321 |
○ [vru] b |
| 322 |
├─╮ |
| 323 |
│ ○ [roy] a |
| 324 |
├─╯ |
| 325 |
○ [zsu] base |
| 326 |
○ [rlv] nottherootcommit |
| 327 |
◆ [zzz] |
| 328 |
[EOF] |
| 329 |
"); |
| 330 |
let output = work_dir.run_jj(["abandon", "--retain-bookmarks", "a", "b"]); |
| 331 |
insta::assert_snapshot!(output, @r" |
| 332 |
------- stderr ------- |
| 333 |
Abandoned 2 commits: |
| 334 |
vruxwmqv cedee197 b | b |
| 335 |
royxmykx 183dbbca a | a |
| 336 |
Rebased 1 descendant commits onto parents of abandoned commits. |
| 337 |
Working copy (@) now at: znkkpsqq b350f44b c | c |
| 338 |
Parent commit (@-) : zsuskuln 67c2f714 a b base | base |
| 339 |
Added 0 files, modified 0 files, removed 2 files |
| 340 |
[EOF] |
| 341 |
"); |
| 342 |
// Commit "c" should have "base" as parent. As when we abandoned "a", it should |
| 343 |
// not have two parent pointers to the same commit. |
| 344 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 345 |
@ [znk] c |
| 346 |
○ [zsu] a b base |
| 347 |
○ [rlv] nottherootcommit |
| 348 |
◆ [zzz] |
| 349 |
[EOF] |
| 350 |
"); |
| 351 |
let output = work_dir.run_jj(["bookmark", "list", "b"]); |
| 352 |
insta::assert_snapshot!(output, @" |
| 353 |
b: zsuskuln 67c2f714 base |
| 354 |
[EOF] |
| 355 |
"); |
| 356 |
} |
| 357 |
|
| 358 |
#[test] |
| 359 |
fn test_bug_2600_rootcommit_special_case() { |
| 360 |
let test_env = TestEnvironment::default(); |
| 361 |
test_env.run_jj_in(".", ["git", "init", "repo"]).success(); |
| 362 |
let work_dir = test_env.work_dir("repo"); |
| 363 |
|
| 364 |
// Set up like `test_bug_2600`, but without the `nottherootcommit` commit. |
| 365 |
create_commit(&work_dir, "base", &[]); |
| 366 |
create_commit(&work_dir, "a", &["base"]); |
| 367 |
create_commit(&work_dir, "b", &["base", "a"]); |
| 368 |
create_commit(&work_dir, "c", &["b"]); |
| 369 |
|
| 370 |
// Setup |
| 371 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 372 |
@ [vru] c |
| 373 |
○ [roy] b |
| 374 |
├─╮ |
| 375 |
│ ○ [zsu] a |
| 376 |
├─╯ |
| 377 |
○ [rlv] base |
| 378 |
◆ [zzz] |
| 379 |
[EOF] |
| 380 |
"); |
| 381 |
|
| 382 |
// Now, the test |
| 383 |
let output = work_dir.run_jj(["abandon", "base"]); |
| 384 |
insta::assert_snapshot!(output, @" |
| 385 |
------- stderr ------- |
| 386 |
Error: The Git backend does not support creating merge commits with the root commit as one of the parents. |
| 387 |
[EOF] |
| 388 |
[exit status: 1] |
| 389 |
"); |
| 390 |
} |
| 391 |
|
| 392 |
#[test] |
| 393 |
fn test_double_abandon() { |
| 394 |
let test_env = TestEnvironment::default(); |
| 395 |
test_env.run_jj_in(".", ["git", "init", "repo"]).success(); |
| 396 |
let work_dir = test_env.work_dir("repo"); |
| 397 |
|
| 398 |
create_commit(&work_dir, "a", &[]); |
| 399 |
// Test the setup |
| 400 |
insta::assert_snapshot!(work_dir.run_jj(["log", "--no-graph", "-r", "a"]), @" |
| 401 |
rlvkpnrz [email protected] 2001-02-03 08:05:09 a 7d980be7 |
| 402 |
a |
| 403 |
[EOF] |
| 404 |
"); |
| 405 |
|
| 406 |
let commit_id = work_dir |
| 407 |
.run_jj(["log", "--no-graph", "--color=never", "-T=commit_id", "-r=a"]) |
| 408 |
.success() |
| 409 |
.stdout |
| 410 |
.into_raw(); |
| 411 |
|
| 412 |
let output = work_dir.run_jj(["abandon", &commit_id]); |
| 413 |
insta::assert_snapshot!(output, @" |
| 414 |
------- stderr ------- |
| 415 |
Abandoned 1 commits: |
| 416 |
rlvkpnrz 7d980be7 a | a |
| 417 |
Deleted bookmarks: a |
| 418 |
Working copy (@) now at: royxmykx 0cff017c (empty) (no description set) |
| 419 |
Parent commit (@-) : zzzzzzzz 00000000 (empty) (no description set) |
| 420 |
Added 0 files, modified 0 files, removed 1 files |
| 421 |
[EOF] |
| 422 |
"); |
| 423 |
let output = work_dir.run_jj(["abandon", &commit_id]); |
| 424 |
insta::assert_snapshot!(output, @" |
| 425 |
------- stderr ------- |
| 426 |
Skipping 1 revisions that are already hidden. |
| 427 |
No revisions to abandon. |
| 428 |
[EOF] |
| 429 |
"); |
| 430 |
} |
| 431 |
|
| 432 |
#[test] |
| 433 |
fn test_abandon_restore_descendants() { |
| 434 |
let test_env = TestEnvironment::default(); |
| 435 |
test_env.run_jj_in(".", ["git", "init", "repo"]).success(); |
| 436 |
let work_dir = test_env.work_dir("repo"); |
| 437 |
|
| 438 |
work_dir.write_file("file", "foo\n"); |
| 439 |
work_dir.run_jj(["new"]).success(); |
| 440 |
work_dir.write_file("file", "bar\n"); |
| 441 |
work_dir.run_jj(["new"]).success(); |
| 442 |
work_dir.write_file("file", "baz\n"); |
| 443 |
|
| 444 |
// Remove the commit containing "bar" |
| 445 |
let output = work_dir.run_jj(["abandon", "-r@-", "--restore-descendants"]); |
| 446 |
insta::assert_snapshot!(output, @r" |
| 447 |
------- stderr ------- |
| 448 |
Abandoned 1 commits: |
| 449 |
rlvkpnrz b23f92c3 (no description set) |
| 450 |
Rebased 1 descendant commits (while preserving their content) onto parents of abandoned commits. |
| 451 |
Working copy (@) now at: kkmpptxz 2b575035 (no description set) |
| 452 |
Parent commit (@-) : qpvuntsm d0c049cd (no description set) |
| 453 |
[EOF] |
| 454 |
"); |
| 455 |
let output = work_dir.run_jj(["diff", "--git"]); |
| 456 |
insta::assert_snapshot!(output, @" |
| 457 |
diff --git a/file b/file |
| 458 |
index 257cc5642c..76018072e0 100644 |
| 459 |
--- a/file |
| 460 |
+++ b/file |
| 461 |
@@ -1,1 +1,1 @@ |
| 462 |
-foo |
| 463 |
+baz |
| 464 |
[EOF] |
| 465 |
"); |
| 466 |
} |
| 467 |
|
| 468 |
#[test] |
| 469 |
fn test_abandon_tracking_bookmarks() { |
| 470 |
let test_env = TestEnvironment::default(); |
| 471 |
|
| 472 |
test_env.run_jj_in(".", ["git", "init", "remote"]).success(); |
| 473 |
let remote_dir = test_env.work_dir("remote"); |
| 474 |
remote_dir |
| 475 |
.run_jj(["bookmark", "set", "-r@", "foo"]) |
| 476 |
.success(); |
| 477 |
remote_dir.run_jj(["git", "export"]).success(); |
| 478 |
|
| 479 |
// Create colocated Git repo which may have @git tracking bookmarks |
| 480 |
test_env |
| 481 |
.run_jj_in( |
| 482 |
".", |
| 483 |
[ |
| 484 |
"git", |
| 485 |
"clone", |
| 486 |
"--colocate", |
| 487 |
"--config=remotes.origin.auto-track-bookmarks='*'", |
| 488 |
"remote/.jj/repo/store/git", |
| 489 |
"local", |
| 490 |
], |
| 491 |
) |
| 492 |
.success(); |
| 493 |
let local_dir = test_env.work_dir("local"); |
| 494 |
local_dir |
| 495 |
.run_jj(["bookmark", "set", "-r@", "bar"]) |
| 496 |
.success(); |
| 497 |
insta::assert_snapshot!(get_log_output(&local_dir), @" |
| 498 |
@ [zsu] bar |
| 499 |
│ ○ [qpv] foo |
| 500 |
├─╯ |
| 501 |
◆ [zzz] |
| 502 |
[EOF] |
| 503 |
"); |
| 504 |
|
| 505 |
let output = local_dir.run_jj(["abandon", "foo"]); |
| 506 |
insta::assert_snapshot!(output, @" |
| 507 |
------- stderr ------- |
| 508 |
Abandoned 1 commits: |
| 509 |
qpvuntsm e8849ae1 foo | (empty) (no description set) |
| 510 |
Deleted bookmarks: foo |
| 511 |
Hint: Deleted bookmarks can be pushed by name or all at once with `jj git push --deleted`. |
| 512 |
[EOF] |
| 513 |
"); |
| 514 |
let output = local_dir.run_jj(["abandon", "bar"]); |
| 515 |
insta::assert_snapshot!(output, @" |
| 516 |
------- stderr ------- |
| 517 |
Abandoned 1 commits: |
| 518 |
zsuskuln c2934cfb bar | (empty) (no description set) |
| 519 |
Deleted bookmarks: bar |
| 520 |
Working copy (@) now at: vruxwmqv b64f323d (empty) (no description set) |
| 521 |
Parent commit (@-) : zzzzzzzz 00000000 (empty) (no description set) |
| 522 |
[EOF] |
| 523 |
"); |
| 524 |
} |
| 525 |
|
| 526 |
#[must_use] |
| 527 |
fn get_log_output(work_dir: &TestWorkDir) -> CommandOutput { |
| 528 |
let template = r#"separate(" ", "[" ++ change_id.short(3) ++ "]", bookmarks)"#; |
| 529 |
work_dir.run_jj(["log", "-T", template]) |
| 530 |
} |