| 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_duplicate() { |
| 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", &[]); |
| 28 |
create_commit(&work_dir, "c", &["a", "b"]); |
| 29 |
// Test the setup |
| 30 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 31 |
@ 387b928721d9 c |
| 32 |
├─╮ |
| 33 |
│ ○ d18ca3e87135 b |
| 34 |
○ │ 7d980be7a1d4 a |
| 35 |
├─╯ |
| 36 |
◆ 000000000000 |
| 37 |
[EOF] |
| 38 |
"); |
| 39 |
|
| 40 |
let output = work_dir.run_jj(["duplicate", "all()"]); |
| 41 |
insta::assert_snapshot!(output, @" |
| 42 |
------- stderr ------- |
| 43 |
Error: Cannot duplicate the root commit |
| 44 |
[EOF] |
| 45 |
[exit status: 1] |
| 46 |
"); |
| 47 |
|
| 48 |
let output = work_dir.run_jj(["duplicate", "none()"]); |
| 49 |
insta::assert_snapshot!(output, @" |
| 50 |
------- stderr ------- |
| 51 |
No revisions to duplicate. |
| 52 |
[EOF] |
| 53 |
"); |
| 54 |
|
| 55 |
let output = work_dir.run_jj(["duplicate", "a"]); |
| 56 |
insta::assert_snapshot!(output, @" |
| 57 |
------- stderr ------- |
| 58 |
Duplicated 7d980be7a1d4 as kpqxywon 13eb8bd0 a |
| 59 |
[EOF] |
| 60 |
"); |
| 61 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 62 |
@ 387b928721d9 c |
| 63 |
├─╮ |
| 64 |
│ ○ d18ca3e87135 b |
| 65 |
○ │ 7d980be7a1d4 a |
| 66 |
├─╯ |
| 67 |
│ ○ 13eb8bd0a547 a |
| 68 |
├─╯ |
| 69 |
◆ 000000000000 |
| 70 |
[EOF] |
| 71 |
"); |
| 72 |
|
| 73 |
let output = work_dir.run_jj(["undo"]); |
| 74 |
insta::assert_snapshot!(output, @" |
| 75 |
------- stderr ------- |
| 76 |
Undid operation: 894889750512 (2001-02-03 08:05:17) duplicate 1 commit(s) |
| 77 |
Restored to operation: 29e5b8953f22 (2001-02-03 08:05:13) create bookmark c pointing to commit 387b928721d9f2efff819ccce81868f32537d71f |
| 78 |
[EOF] |
| 79 |
"); |
| 80 |
let output = work_dir.run_jj(["duplicate" /* duplicates `c` */]); |
| 81 |
insta::assert_snapshot!(output, @" |
| 82 |
------- stderr ------- |
| 83 |
Duplicated 387b928721d9 as lylxulpl 71c64df5 c |
| 84 |
[EOF] |
| 85 |
"); |
| 86 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 87 |
@ 387b928721d9 c |
| 88 |
├─╮ |
| 89 |
│ │ ○ 71c64df584dc c |
| 90 |
╭─┬─╯ |
| 91 |
│ ○ d18ca3e87135 b |
| 92 |
○ │ 7d980be7a1d4 a |
| 93 |
├─╯ |
| 94 |
◆ 000000000000 |
| 95 |
[EOF] |
| 96 |
"); |
| 97 |
} |
| 98 |
|
| 99 |
#[test] |
| 100 |
fn test_duplicate_many() { |
| 101 |
let test_env = TestEnvironment::default(); |
| 102 |
test_env.run_jj_in(".", ["git", "init", "repo"]).success(); |
| 103 |
let work_dir = test_env.work_dir("repo"); |
| 104 |
|
| 105 |
create_commit(&work_dir, "a", &[]); |
| 106 |
create_commit(&work_dir, "b", &["a"]); |
| 107 |
create_commit(&work_dir, "c", &["a"]); |
| 108 |
create_commit(&work_dir, "d", &["c"]); |
| 109 |
create_commit(&work_dir, "e", &["b", "d"]); |
| 110 |
// Test the setup |
| 111 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 112 |
@ 0559be9bd4d0 e |
| 113 |
├─╮ |
| 114 |
│ ○ a2dbb1aad514 d |
| 115 |
│ ○ 991a7501d660 c |
| 116 |
○ │ 123b4d91f6e5 b |
| 117 |
├─╯ |
| 118 |
○ 7d980be7a1d4 a |
| 119 |
◆ 000000000000 |
| 120 |
[EOF] |
| 121 |
"); |
| 122 |
let setup_opid = work_dir.current_operation_id(); |
| 123 |
|
| 124 |
let output = work_dir.run_jj(["duplicate", "b::"]); |
| 125 |
insta::assert_snapshot!(output, @" |
| 126 |
------- stderr ------- |
| 127 |
Duplicated 123b4d91f6e5 as wqnwkozp 10059c86 b |
| 128 |
Duplicated 0559be9bd4d0 as mouksmqu 0afe2f34 e |
| 129 |
[EOF] |
| 130 |
"); |
| 131 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 132 |
@ 0559be9bd4d0 e |
| 133 |
├─╮ |
| 134 |
○ │ 123b4d91f6e5 b |
| 135 |
│ │ ○ 0afe2f348a93 e |
| 136 |
│ ╭─┤ |
| 137 |
│ ○ │ a2dbb1aad514 d |
| 138 |
│ ○ │ 991a7501d660 c |
| 139 |
├─╯ │ |
| 140 |
│ ○ 10059c8651d7 b |
| 141 |
├───╯ |
| 142 |
○ 7d980be7a1d4 a |
| 143 |
◆ 000000000000 |
| 144 |
[EOF] |
| 145 |
"); |
| 146 |
|
| 147 |
// Try specifying the same commit twice directly |
| 148 |
work_dir.run_jj(["op", "restore", &setup_opid]).success(); |
| 149 |
let output = work_dir.run_jj(["duplicate", "b", "b"]); |
| 150 |
insta::assert_snapshot!(output, @" |
| 151 |
------- stderr ------- |
| 152 |
Duplicated 123b4d91f6e5 as nkmrtpmo 1ccf2589 b |
| 153 |
[EOF] |
| 154 |
"); |
| 155 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 156 |
@ 0559be9bd4d0 e |
| 157 |
├─╮ |
| 158 |
│ ○ a2dbb1aad514 d |
| 159 |
│ ○ 991a7501d660 c |
| 160 |
○ │ 123b4d91f6e5 b |
| 161 |
├─╯ |
| 162 |
│ ○ 1ccf2589bfd1 b |
| 163 |
├─╯ |
| 164 |
○ 7d980be7a1d4 a |
| 165 |
◆ 000000000000 |
| 166 |
[EOF] |
| 167 |
"); |
| 168 |
|
| 169 |
// Try specifying the same commit twice indirectly |
| 170 |
work_dir.run_jj(["op", "restore", &setup_opid]).success(); |
| 171 |
let output = work_dir.run_jj(["duplicate", "b::", "d::"]); |
| 172 |
insta::assert_snapshot!(output, @" |
| 173 |
------- stderr ------- |
| 174 |
Duplicated 123b4d91f6e5 as xtnwkqum 1a94ffc6 b |
| 175 |
Duplicated a2dbb1aad514 as pqrnrkux 6a17a96d d |
| 176 |
Duplicated 0559be9bd4d0 as ztxkyksq b113bd5c e |
| 177 |
[EOF] |
| 178 |
"); |
| 179 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 180 |
@ 0559be9bd4d0 e |
| 181 |
├─╮ |
| 182 |
│ ○ a2dbb1aad514 d |
| 183 |
○ │ 123b4d91f6e5 b |
| 184 |
│ │ ○ b113bd5c550a e |
| 185 |
│ │ ├─╮ |
| 186 |
│ │ │ ○ 6a17a96d77d2 d |
| 187 |
│ ├───╯ |
| 188 |
│ ○ │ 991a7501d660 c |
| 189 |
├─╯ │ |
| 190 |
│ ○ 1a94ffc6e6aa b |
| 191 |
├───╯ |
| 192 |
○ 7d980be7a1d4 a |
| 193 |
◆ 000000000000 |
| 194 |
[EOF] |
| 195 |
"); |
| 196 |
|
| 197 |
work_dir.run_jj(["op", "restore", &setup_opid]).success(); |
| 198 |
// Reminder of the setup |
| 199 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 200 |
@ 0559be9bd4d0 e |
| 201 |
├─╮ |
| 202 |
│ ○ a2dbb1aad514 d |
| 203 |
│ ○ 991a7501d660 c |
| 204 |
○ │ 123b4d91f6e5 b |
| 205 |
├─╯ |
| 206 |
○ 7d980be7a1d4 a |
| 207 |
◆ 000000000000 |
| 208 |
[EOF] |
| 209 |
"); |
| 210 |
let output = work_dir.run_jj(["duplicate", "d::", "a"]); |
| 211 |
insta::assert_snapshot!(output, @" |
| 212 |
------- stderr ------- |
| 213 |
Duplicated 7d980be7a1d4 as nlrtlrxv 117dd806 a |
| 214 |
Duplicated a2dbb1aad514 as plymsszl f2ec1b7f d |
| 215 |
Duplicated 0559be9bd4d0 as urrlptpw 9e54f34c e |
| 216 |
[EOF] |
| 217 |
"); |
| 218 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 219 |
@ 0559be9bd4d0 e |
| 220 |
├─╮ |
| 221 |
│ ○ a2dbb1aad514 d |
| 222 |
│ │ ○ 9e54f34ca238 e |
| 223 |
╭───┤ |
| 224 |
│ │ ○ f2ec1b7f4e82 d |
| 225 |
│ ├─╯ |
| 226 |
│ ○ 991a7501d660 c |
| 227 |
○ │ 123b4d91f6e5 b |
| 228 |
├─╯ |
| 229 |
○ 7d980be7a1d4 a |
| 230 |
│ ○ 117dd80623e6 a |
| 231 |
├─╯ |
| 232 |
◆ 000000000000 |
| 233 |
[EOF] |
| 234 |
"); |
| 235 |
|
| 236 |
// Check for BUG -- makes too many 'a'-s, etc. |
| 237 |
work_dir.run_jj(["op", "restore", &setup_opid]).success(); |
| 238 |
let output = work_dir.run_jj(["duplicate", "a::"]); |
| 239 |
insta::assert_snapshot!(output, @" |
| 240 |
------- stderr ------- |
| 241 |
Duplicated 7d980be7a1d4 as uuuvxpvw cb730319 a |
| 242 |
Duplicated 123b4d91f6e5 as nmpuuozl b00a23f6 b |
| 243 |
Duplicated 991a7501d660 as kzpokyyw 7c1b86d5 c |
| 244 |
Duplicated a2dbb1aad514 as yxrlprzz 2f5494bb d |
| 245 |
Duplicated 0559be9bd4d0 as mvkzkxrl 8a4c81fe e |
| 246 |
[EOF] |
| 247 |
"); |
| 248 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 249 |
@ 0559be9bd4d0 e |
| 250 |
├─╮ |
| 251 |
│ ○ a2dbb1aad514 d |
| 252 |
│ ○ 991a7501d660 c |
| 253 |
○ │ 123b4d91f6e5 b |
| 254 |
├─╯ |
| 255 |
○ 7d980be7a1d4 a |
| 256 |
│ ○ 8a4c81fee5f1 e |
| 257 |
│ ├─╮ |
| 258 |
│ │ ○ 2f5494bb9bce d |
| 259 |
│ │ ○ 7c1b86d551da c |
| 260 |
│ ○ │ b00a23f660bf b |
| 261 |
│ ├─╯ |
| 262 |
│ ○ cb7303191ed7 a |
| 263 |
├─╯ |
| 264 |
◆ 000000000000 |
| 265 |
[EOF] |
| 266 |
"); |
| 267 |
} |
| 268 |
|
| 269 |
#[test] |
| 270 |
fn test_duplicate_destination() { |
| 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 |
|
| 275 |
create_commit(&work_dir, "a1", &[]); |
| 276 |
create_commit(&work_dir, "a2", &["a1"]); |
| 277 |
create_commit(&work_dir, "a3", &["a2"]); |
| 278 |
create_commit(&work_dir, "b", &[]); |
| 279 |
create_commit(&work_dir, "c", &[]); |
| 280 |
create_commit(&work_dir, "d", &[]); |
| 281 |
let setup_opid = work_dir.current_operation_id(); |
| 282 |
|
| 283 |
// Test the setup |
| 284 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 285 |
@ 5248650c3314 d |
| 286 |
│ ○ 22370aa928dc c |
| 287 |
├─╯ |
| 288 |
│ ○ c406dbab05ac b |
| 289 |
├─╯ |
| 290 |
│ ○ 5fb83d2b58d6 a3 |
| 291 |
│ ○ 7bfd9fbe959c a2 |
| 292 |
│ ○ 5d93a4b8f4bd a1 |
| 293 |
├─╯ |
| 294 |
◆ 000000000000 |
| 295 |
[EOF] |
| 296 |
"); |
| 297 |
|
| 298 |
// Duplicate a single commit onto a single destination. |
| 299 |
let output = work_dir.run_jj(["duplicate", "a1", "-o", "c"]); |
| 300 |
insta::assert_snapshot!(output, @" |
| 301 |
------- stderr ------- |
| 302 |
Duplicated 5d93a4b8f4bd as kxryzmor 08f0f980 a1 |
| 303 |
[EOF] |
| 304 |
"); |
| 305 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 306 |
@ 5248650c3314 d |
| 307 |
│ ○ 08f0f980b8ad a1 |
| 308 |
│ ○ 22370aa928dc c |
| 309 |
├─╯ |
| 310 |
│ ○ c406dbab05ac b |
| 311 |
├─╯ |
| 312 |
│ ○ 5fb83d2b58d6 a3 |
| 313 |
│ ○ 7bfd9fbe959c a2 |
| 314 |
│ ○ 5d93a4b8f4bd a1 |
| 315 |
├─╯ |
| 316 |
◆ 000000000000 |
| 317 |
[EOF] |
| 318 |
"); |
| 319 |
work_dir.run_jj(["op", "restore", &setup_opid]).success(); |
| 320 |
|
| 321 |
// Duplicate a single commit onto multiple destinations. |
| 322 |
let output = work_dir.run_jj(["duplicate", "a1", "-o", "c", "-o", "d"]); |
| 323 |
insta::assert_snapshot!(output, @" |
| 324 |
------- stderr ------- |
| 325 |
Duplicated 5d93a4b8f4bd as xznxytkn 0bad88fb a1 |
| 326 |
[EOF] |
| 327 |
"); |
| 328 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 329 |
○ 0bad88fbab2e a1 |
| 330 |
├─╮ |
| 331 |
│ @ 5248650c3314 d |
| 332 |
○ │ 22370aa928dc c |
| 333 |
├─╯ |
| 334 |
│ ○ c406dbab05ac b |
| 335 |
├─╯ |
| 336 |
│ ○ 5fb83d2b58d6 a3 |
| 337 |
│ ○ 7bfd9fbe959c a2 |
| 338 |
│ ○ 5d93a4b8f4bd a1 |
| 339 |
├─╯ |
| 340 |
◆ 000000000000 |
| 341 |
[EOF] |
| 342 |
"); |
| 343 |
work_dir.run_jj(["op", "restore", &setup_opid]).success(); |
| 344 |
|
| 345 |
// Duplicate a single commit onto its descendant. |
| 346 |
let output = work_dir.run_jj(["duplicate", "a1", "-o", "a3"]); |
| 347 |
insta::assert_snapshot!(output, @r" |
| 348 |
------- stderr ------- |
| 349 |
Warning: Duplicating commit 5d93a4b8f4bd as a descendant of itself. |
| 350 |
Duplicated 5d93a4b8f4bd as tlkvzzqu 8351ae70 (empty) a1 |
| 351 |
[EOF] |
| 352 |
"); |
| 353 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 354 |
@ 5248650c3314 d |
| 355 |
│ ○ 22370aa928dc c |
| 356 |
├─╯ |
| 357 |
│ ○ c406dbab05ac b |
| 358 |
├─╯ |
| 359 |
│ ○ 8351ae7027e4 a1 |
| 360 |
│ ○ 5fb83d2b58d6 a3 |
| 361 |
│ ○ 7bfd9fbe959c a2 |
| 362 |
│ ○ 5d93a4b8f4bd a1 |
| 363 |
├─╯ |
| 364 |
◆ 000000000000 |
| 365 |
[EOF] |
| 366 |
"); |
| 367 |
|
| 368 |
work_dir.run_jj(["op", "restore", &setup_opid]).success(); |
| 369 |
// Duplicate multiple commits without a direct ancestry relationship onto a |
| 370 |
// single destination. |
| 371 |
let output = work_dir.run_jj(["duplicate", "-r=a1", "-r=b", "-o", "c"]); |
| 372 |
insta::assert_snapshot!(output, @" |
| 373 |
------- stderr ------- |
| 374 |
Duplicated 5d93a4b8f4bd as pzsxstzt 663f101c a1 |
| 375 |
Duplicated c406dbab05ac as nxkxtmvy b8a86167 b |
| 376 |
[EOF] |
| 377 |
"); |
| 378 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 379 |
@ 5248650c3314 d |
| 380 |
│ ○ b8a8616787a4 b |
| 381 |
│ │ ○ 663f101c476a a1 |
| 382 |
│ ├─╯ |
| 383 |
│ ○ 22370aa928dc c |
| 384 |
├─╯ |
| 385 |
│ ○ c406dbab05ac b |
| 386 |
├─╯ |
| 387 |
│ ○ 5fb83d2b58d6 a3 |
| 388 |
│ ○ 7bfd9fbe959c a2 |
| 389 |
│ ○ 5d93a4b8f4bd a1 |
| 390 |
├─╯ |
| 391 |
◆ 000000000000 |
| 392 |
[EOF] |
| 393 |
"); |
| 394 |
work_dir.run_jj(["op", "restore", &setup_opid]).success(); |
| 395 |
|
| 396 |
// Duplicate multiple commits without a direct ancestry relationship onto |
| 397 |
// multiple destinations. |
| 398 |
let output = work_dir.run_jj(["duplicate", "-r=a1", "b", "-o", "c", "-o", "d"]); |
| 399 |
insta::assert_snapshot!(output, @" |
| 400 |
------- stderr ------- |
| 401 |
Duplicated 5d93a4b8f4bd as qmkrwlvp b0f531b0 a1 |
| 402 |
Duplicated c406dbab05ac as pkqrwoqq 0df6b6b2 b |
| 403 |
[EOF] |
| 404 |
"); |
| 405 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 406 |
○ 0df6b6b21bfe b |
| 407 |
├─╮ |
| 408 |
│ │ ○ b0f531b01b33 a1 |
| 409 |
╭─┬─╯ |
| 410 |
│ @ 5248650c3314 d |
| 411 |
○ │ 22370aa928dc c |
| 412 |
├─╯ |
| 413 |
│ ○ c406dbab05ac b |
| 414 |
├─╯ |
| 415 |
│ ○ 5fb83d2b58d6 a3 |
| 416 |
│ ○ 7bfd9fbe959c a2 |
| 417 |
│ ○ 5d93a4b8f4bd a1 |
| 418 |
├─╯ |
| 419 |
◆ 000000000000 |
| 420 |
[EOF] |
| 421 |
"); |
| 422 |
work_dir.run_jj(["op", "restore", &setup_opid]).success(); |
| 423 |
|
| 424 |
// Duplicate multiple commits with an ancestry relationship onto a |
| 425 |
// single destination. |
| 426 |
let output = work_dir.run_jj(["duplicate", "a1", "a3", "-o", "c"]); |
| 427 |
insta::assert_snapshot!(output, @" |
| 428 |
------- stderr ------- |
| 429 |
Duplicated 5d93a4b8f4bd as qwyusntz 5f1c245f a1 |
| 430 |
Duplicated 5fb83d2b58d6 as pwpvvyov 2a209b65 a3 |
| 431 |
[EOF] |
| 432 |
"); |
| 433 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 434 |
@ 5248650c3314 d |
| 435 |
│ ○ 2a209b658cd6 a3 |
| 436 |
│ ○ 5f1c245fb9ae a1 |
| 437 |
│ ○ 22370aa928dc c |
| 438 |
├─╯ |
| 439 |
│ ○ c406dbab05ac b |
| 440 |
├─╯ |
| 441 |
│ ○ 5fb83d2b58d6 a3 |
| 442 |
│ ○ 7bfd9fbe959c a2 |
| 443 |
│ ○ 5d93a4b8f4bd a1 |
| 444 |
├─╯ |
| 445 |
◆ 000000000000 |
| 446 |
[EOF] |
| 447 |
"); |
| 448 |
work_dir.run_jj(["op", "restore", &setup_opid]).success(); |
| 449 |
|
| 450 |
// Duplicate multiple commits with an ancestry relationship onto |
| 451 |
// multiple destinations. |
| 452 |
let output = work_dir.run_jj(["duplicate", "a1", "a3", "-o", "c", "-o", "d"]); |
| 453 |
insta::assert_snapshot!(output, @" |
| 454 |
------- stderr ------- |
| 455 |
Duplicated 5d93a4b8f4bd as soqnvnyz bc6678fd a1 |
| 456 |
Duplicated 5fb83d2b58d6 as nmmmqslz a35b7e76 a3 |
| 457 |
[EOF] |
| 458 |
"); |
| 459 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 460 |
○ a35b7e76b4dd a3 |
| 461 |
○ bc6678fdf2a5 a1 |
| 462 |
├─╮ |
| 463 |
│ @ 5248650c3314 d |
| 464 |
○ │ 22370aa928dc c |
| 465 |
├─╯ |
| 466 |
│ ○ c406dbab05ac b |
| 467 |
├─╯ |
| 468 |
│ ○ 5fb83d2b58d6 a3 |
| 469 |
│ ○ 7bfd9fbe959c a2 |
| 470 |
│ ○ 5d93a4b8f4bd a1 |
| 471 |
├─╯ |
| 472 |
◆ 000000000000 |
| 473 |
[EOF] |
| 474 |
"); |
| 475 |
} |
| 476 |
|
| 477 |
#[test] |
| 478 |
fn test_duplicate_insert_after() { |
| 479 |
let test_env = TestEnvironment::default(); |
| 480 |
test_env.run_jj_in(".", ["git", "init", "repo"]).success(); |
| 481 |
let work_dir = test_env.work_dir("repo"); |
| 482 |
|
| 483 |
create_commit(&work_dir, "a1", &[]); |
| 484 |
create_commit(&work_dir, "a2", &["a1"]); |
| 485 |
create_commit(&work_dir, "a3", &["a2"]); |
| 486 |
create_commit(&work_dir, "a4", &["a3"]); |
| 487 |
create_commit(&work_dir, "b1", &[]); |
| 488 |
create_commit(&work_dir, "b2", &["b1"]); |
| 489 |
create_commit(&work_dir, "c1", &[]); |
| 490 |
create_commit(&work_dir, "c2", &["c1"]); |
| 491 |
create_commit(&work_dir, "d1", &[]); |
| 492 |
create_commit(&work_dir, "d2", &["d1"]); |
| 493 |
let setup_opid = work_dir.current_operation_id(); |
| 494 |
|
| 495 |
// Test the setup |
| 496 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 497 |
@ 3e122d6a4b70 d2 |
| 498 |
○ ae61a031221a d1 |
| 499 |
│ ○ 47a79ab4bbc6 c2 |
| 500 |
│ ○ 9b24b49f717e c1 |
| 501 |
├─╯ |
| 502 |
│ ○ 65b6f1fe6b41 b2 |
| 503 |
│ ○ 6a9343b8797a b1 |
| 504 |
├─╯ |
| 505 |
│ ○ e9b68b6313be a4 |
| 506 |
│ ○ 5fb83d2b58d6 a3 |
| 507 |
│ ○ 7bfd9fbe959c a2 |
| 508 |
│ ○ 5d93a4b8f4bd a1 |
| 509 |
├─╯ |
| 510 |
◆ 000000000000 |
| 511 |
[EOF] |
| 512 |
"); |
| 513 |
|
| 514 |
// Duplicate a single commit after a single commit with no direct relationship. |
| 515 |
let output = work_dir.run_jj(["duplicate", "a1", "--after", "b1"]); |
| 516 |
insta::assert_snapshot!(output, @r" |
| 517 |
------- stderr ------- |
| 518 |
Duplicated 5d93a4b8f4bd as nlrtlrxv 52959024 a1 |
| 519 |
Rebased 1 commits onto duplicated commits. |
| 520 |
[EOF] |
| 521 |
"); |
| 522 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 523 |
@ 3e122d6a4b70 d2 |
| 524 |
○ ae61a031221a d1 |
| 525 |
│ ○ 47a79ab4bbc6 c2 |
| 526 |
│ ○ 9b24b49f717e c1 |
| 527 |
├─╯ |
| 528 |
│ ○ 8124402d0ebe b2 |
| 529 |
│ ○ 52959024d93a a1 |
| 530 |
│ ○ 6a9343b8797a b1 |
| 531 |
├─╯ |
| 532 |
│ ○ e9b68b6313be a4 |
| 533 |
│ ○ 5fb83d2b58d6 a3 |
| 534 |
│ ○ 7bfd9fbe959c a2 |
| 535 |
│ ○ 5d93a4b8f4bd a1 |
| 536 |
├─╯ |
| 537 |
◆ 000000000000 |
| 538 |
[EOF] |
| 539 |
"); |
| 540 |
work_dir.run_jj(["op", "restore", &setup_opid]).success(); |
| 541 |
|
| 542 |
// Duplicate a single commit after a single ancestor commit. |
| 543 |
let output = work_dir.run_jj(["duplicate", "a3", "--after", "a1"]); |
| 544 |
insta::assert_snapshot!(output, @r" |
| 545 |
------- stderr ------- |
| 546 |
Warning: Duplicating commit 5fb83d2b58d6 as an ancestor of itself. |
| 547 |
Duplicated 5fb83d2b58d6 as uuuvxpvw f626655e a3 |
| 548 |
Rebased 3 commits onto duplicated commits. |
| 549 |
[EOF] |
| 550 |
"); |
| 551 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 552 |
@ 3e122d6a4b70 d2 |
| 553 |
○ ae61a031221a d1 |
| 554 |
│ ○ 47a79ab4bbc6 c2 |
| 555 |
│ ○ 9b24b49f717e c1 |
| 556 |
├─╯ |
| 557 |
│ ○ 65b6f1fe6b41 b2 |
| 558 |
│ ○ 6a9343b8797a b1 |
| 559 |
├─╯ |
| 560 |
│ ○ cfea8bb13adf a4 |
| 561 |
│ ○ 3a595c648b6d a3 |
| 562 |
│ ○ 307ab42af890 a2 |
| 563 |
│ ○ f626655ef3dd a3 |
| 564 |
│ ○ 5d93a4b8f4bd a1 |
| 565 |
├─╯ |
| 566 |
◆ 000000000000 |
| 567 |
[EOF] |
| 568 |
"); |
| 569 |
work_dir.run_jj(["op", "restore", &setup_opid]).success(); |
| 570 |
|
| 571 |
// Duplicate a single commit after a single descendant commit. |
| 572 |
let output = work_dir.run_jj(["duplicate", "a1", "--after", "a3"]); |
| 573 |
insta::assert_snapshot!(output, @r" |
| 574 |
------- stderr ------- |
| 575 |
Warning: Duplicating commit 5d93a4b8f4bd as a descendant of itself. |
| 576 |
Duplicated 5d93a4b8f4bd as pkstwlsy 610e8ba1 (empty) a1 |
| 577 |
Rebased 1 commits onto duplicated commits. |
| 578 |
[EOF] |
| 579 |
"); |
| 580 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 581 |
@ 3e122d6a4b70 d2 |
| 582 |
○ ae61a031221a d1 |
| 583 |
│ ○ 47a79ab4bbc6 c2 |
| 584 |
│ ○ 9b24b49f717e c1 |
| 585 |
├─╯ |
| 586 |
│ ○ 65b6f1fe6b41 b2 |
| 587 |
│ ○ 6a9343b8797a b1 |
| 588 |
├─╯ |
| 589 |
│ ○ f8077bd38256 a4 |
| 590 |
│ ○ 610e8ba113f6 a1 |
| 591 |
│ ○ 5fb83d2b58d6 a3 |
| 592 |
│ ○ 7bfd9fbe959c a2 |
| 593 |
│ ○ 5d93a4b8f4bd a1 |
| 594 |
├─╯ |
| 595 |
◆ 000000000000 |
| 596 |
[EOF] |
| 597 |
"); |
| 598 |
work_dir.run_jj(["op", "restore", &setup_opid]).success(); |
| 599 |
|
| 600 |
// Duplicate a single commit after multiple commits with no direct |
| 601 |
// relationship. |
| 602 |
let output = work_dir.run_jj(["duplicate", "a1", "--after", "b1", "--after", "c1"]); |
| 603 |
insta::assert_snapshot!(output, @r" |
| 604 |
------- stderr ------- |
| 605 |
Duplicated 5d93a4b8f4bd as zowrlwsv a78c25cc a1 |
| 606 |
Rebased 2 commits onto duplicated commits. |
| 607 |
[EOF] |
| 608 |
"); |
| 609 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 610 |
@ 3e122d6a4b70 d2 |
| 611 |
○ ae61a031221a d1 |
| 612 |
│ ○ 4150b5a5466e c2 |
| 613 |
│ │ ○ 4a1f33498a39 b2 |
| 614 |
│ ├─╯ |
| 615 |
│ ○ a78c25cc7d58 a1 |
| 616 |
│ ├─╮ |
| 617 |
│ │ ○ 9b24b49f717e c1 |
| 618 |
├───╯ |
| 619 |
│ ○ 6a9343b8797a b1 |
| 620 |
├─╯ |
| 621 |
│ ○ e9b68b6313be a4 |
| 622 |
│ ○ 5fb83d2b58d6 a3 |
| 623 |
│ ○ 7bfd9fbe959c a2 |
| 624 |
│ ○ 5d93a4b8f4bd a1 |
| 625 |
├─╯ |
| 626 |
◆ 000000000000 |
| 627 |
[EOF] |
| 628 |
"); |
| 629 |
work_dir.run_jj(["op", "restore", &setup_opid]).success(); |
| 630 |
|
| 631 |
// Duplicate a single commit after multiple commits including an ancestor. |
| 632 |
let output = work_dir.run_jj(["duplicate", "a3", "--after", "a2", "--after", "b2"]); |
| 633 |
insta::assert_snapshot!(output, @r" |
| 634 |
------- stderr ------- |
| 635 |
Warning: Duplicating commit 5fb83d2b58d6 as an ancestor of itself. |
| 636 |
Duplicated 5fb83d2b58d6 as wvmqtotl 0824a995 a3 |
| 637 |
Rebased 2 commits onto duplicated commits. |
| 638 |
[EOF] |
| 639 |
"); |
| 640 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 641 |
@ 3e122d6a4b70 d2 |
| 642 |
○ ae61a031221a d1 |
| 643 |
│ ○ 47a79ab4bbc6 c2 |
| 644 |
│ ○ 9b24b49f717e c1 |
| 645 |
├─╯ |
| 646 |
│ ○ a916f82ba67e a4 |
| 647 |
│ ○ 3568f02a532c a3 |
| 648 |
│ ○ 0824a99549cc a3 |
| 649 |
│ ├─╮ |
| 650 |
│ │ ○ 65b6f1fe6b41 b2 |
| 651 |
│ │ ○ 6a9343b8797a b1 |
| 652 |
├───╯ |
| 653 |
│ ○ 7bfd9fbe959c a2 |
| 654 |
│ ○ 5d93a4b8f4bd a1 |
| 655 |
├─╯ |
| 656 |
◆ 000000000000 |
| 657 |
[EOF] |
| 658 |
"); |
| 659 |
work_dir.run_jj(["op", "restore", &setup_opid]).success(); |
| 660 |
|
| 661 |
// Duplicate a single commit after multiple commits including a descendant. |
| 662 |
let output = work_dir.run_jj(["duplicate", "a1", "--after", "a3", "--after", "b2"]); |
| 663 |
insta::assert_snapshot!(output, @r" |
| 664 |
------- stderr ------- |
| 665 |
Warning: Duplicating commit 5d93a4b8f4bd as a descendant of itself. |
| 666 |
Duplicated 5d93a4b8f4bd as opwsxtwu 7548fb00 (empty) a1 |
| 667 |
Rebased 1 commits onto duplicated commits. |
| 668 |
[EOF] |
| 669 |
"); |
| 670 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 671 |
@ 3e122d6a4b70 d2 |
| 672 |
○ ae61a031221a d1 |
| 673 |
│ ○ 47a79ab4bbc6 c2 |
| 674 |
│ ○ 9b24b49f717e c1 |
| 675 |
├─╯ |
| 676 |
│ ○ 784c89a5ba72 a4 |
| 677 |
│ ○ 7548fb00a50a a1 |
| 678 |
│ ├─╮ |
| 679 |
│ │ ○ 65b6f1fe6b41 b2 |
| 680 |
│ │ ○ 6a9343b8797a b1 |
| 681 |
├───╯ |
| 682 |
│ ○ 5fb83d2b58d6 a3 |
| 683 |
│ ○ 7bfd9fbe959c a2 |
| 684 |
│ ○ 5d93a4b8f4bd a1 |
| 685 |
├─╯ |
| 686 |
◆ 000000000000 |
| 687 |
[EOF] |
| 688 |
"); |
| 689 |
work_dir.run_jj(["op", "restore", &setup_opid]).success(); |
| 690 |
|
| 691 |
// Duplicate multiple commits without a direct ancestry relationship after a |
| 692 |
// single commit without a direct relationship. |
| 693 |
let output = work_dir.run_jj(["duplicate", "a1", "b1", "--after", "c1"]); |
| 694 |
insta::assert_snapshot!(output, @r" |
| 695 |
------- stderr ------- |
| 696 |
Duplicated 5d93a4b8f4bd as ukwxllxp 0cedc1c7 a1 |
| 697 |
Duplicated 6a9343b8797a as yrwmsomt 0d18a4ba b1 |
| 698 |
Rebased 1 commits onto duplicated commits. |
| 699 |
[EOF] |
| 700 |
"); |
| 701 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 702 |
@ 3e122d6a4b70 d2 |
| 703 |
○ ae61a031221a d1 |
| 704 |
│ ○ 133e5ef54093 c2 |
| 705 |
│ ├─╮ |
| 706 |
│ │ ○ 0d18a4ba8860 b1 |
| 707 |
│ ○ │ 0cedc1c7f5dc a1 |
| 708 |
│ ├─╯ |
| 709 |
│ ○ 9b24b49f717e c1 |
| 710 |
├─╯ |
| 711 |
│ ○ 65b6f1fe6b41 b2 |
| 712 |
│ ○ 6a9343b8797a b1 |
| 713 |
├─╯ |
| 714 |
│ ○ e9b68b6313be a4 |
| 715 |
│ ○ 5fb83d2b58d6 a3 |
| 716 |
│ ○ 7bfd9fbe959c a2 |
| 717 |
│ ○ 5d93a4b8f4bd a1 |
| 718 |
├─╯ |
| 719 |
◆ 000000000000 |
| 720 |
[EOF] |
| 721 |
"); |
| 722 |
work_dir.run_jj(["op", "restore", &setup_opid]).success(); |
| 723 |
|
| 724 |
// Duplicate multiple commits without a direct ancestry relationship after a |
| 725 |
// single commit which is an ancestor of one of the duplicated commits. |
| 726 |
let output = work_dir.run_jj(["duplicate", "a3", "b1", "--after", "a2"]); |
| 727 |
insta::assert_snapshot!(output, @r" |
| 728 |
------- stderr ------- |
| 729 |
Warning: Duplicating commit 5fb83d2b58d6 as an ancestor of itself. |
| 730 |
Duplicated 5fb83d2b58d6 as szrrkvty 5ea1ddf1 a3 |
| 731 |
Duplicated 6a9343b8797a as wvmrymqu 8081d164 b1 |
| 732 |
Rebased 2 commits onto duplicated commits. |
| 733 |
[EOF] |
| 734 |
"); |
| 735 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 736 |
@ 3e122d6a4b70 d2 |
| 737 |
○ ae61a031221a d1 |
| 738 |
│ ○ 47a79ab4bbc6 c2 |
| 739 |
│ ○ 9b24b49f717e c1 |
| 740 |
├─╯ |
| 741 |
│ ○ 65b6f1fe6b41 b2 |
| 742 |
│ ○ 6a9343b8797a b1 |
| 743 |
├─╯ |
| 744 |
│ ○ e5be4d6a351f a4 |
| 745 |
│ ○ d6fe9e37ad2e a3 |
| 746 |
│ ├─╮ |
| 747 |
│ │ ○ 8081d1648811 b1 |
| 748 |
│ ○ │ 5ea1ddf11f02 a3 |
| 749 |
│ ├─╯ |
| 750 |
│ ○ 7bfd9fbe959c a2 |
| 751 |
│ ○ 5d93a4b8f4bd a1 |
| 752 |
├─╯ |
| 753 |
◆ 000000000000 |
| 754 |
[EOF] |
| 755 |
"); |
| 756 |
work_dir.run_jj(["op", "restore", &setup_opid]).success(); |
| 757 |
|
| 758 |
// Duplicate multiple commits without a direct ancestry relationship after a |
| 759 |
// single commit which is a descendant of one of the duplicated commits. |
| 760 |
let output = work_dir.run_jj(["duplicate", "a1", "b1", "--after", "a3"]); |
| 761 |
insta::assert_snapshot!(output, @r" |
| 762 |
------- stderr ------- |
| 763 |
Warning: Duplicating commit 5d93a4b8f4bd as a descendant of itself. |
| 764 |
Duplicated 5d93a4b8f4bd as ztnvrxlv 896deede (empty) a1 |
| 765 |
Duplicated 6a9343b8797a as upuzqpxs ad048f81 b1 |
| 766 |
Rebased 1 commits onto duplicated commits. |
| 767 |
[EOF] |
| 768 |
"); |
| 769 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 770 |
@ 3e122d6a4b70 d2 |
| 771 |
○ ae61a031221a d1 |
| 772 |
│ ○ 47a79ab4bbc6 c2 |
| 773 |
│ ○ 9b24b49f717e c1 |
| 774 |
├─╯ |
| 775 |
│ ○ 65b6f1fe6b41 b2 |
| 776 |
│ ○ 6a9343b8797a b1 |
| 777 |
├─╯ |
| 778 |
│ ○ 87ec7e281ad9 a4 |
| 779 |
│ ├─╮ |
| 780 |
│ │ ○ ad048f810d3c b1 |
| 781 |
│ ○ │ 896deede3c03 a1 |
| 782 |
│ ├─╯ |
| 783 |
│ ○ 5fb83d2b58d6 a3 |
| 784 |
│ ○ 7bfd9fbe959c a2 |
| 785 |
│ ○ 5d93a4b8f4bd a1 |
| 786 |
├─╯ |
| 787 |
◆ 000000000000 |
| 788 |
[EOF] |
| 789 |
"); |
| 790 |
work_dir.run_jj(["op", "restore", &setup_opid]).success(); |
| 791 |
|
| 792 |
// Duplicate multiple commits without a direct ancestry relationship after |
| 793 |
// multiple commits without a direct relationship to the duplicated commits. |
| 794 |
let output = work_dir.run_jj(["duplicate", "a1", "b1", "--after", "c1", "--after", "d1"]); |
| 795 |
insta::assert_snapshot!(output, @r" |
| 796 |
------- stderr ------- |
| 797 |
Duplicated 5d93a4b8f4bd as muymlknp 7db83f0f a1 |
| 798 |
Duplicated 6a9343b8797a as snrzyvry d10bd4dd b1 |
| 799 |
Rebased 2 commits onto duplicated commits. |
| 800 |
Working copy (@) now at: nmzmmopx 57d2a947 d2 | d2 |
| 801 |
Parent commit (@-) : muymlknp 7db83f0f a1 |
| 802 |
Parent commit (@-) : snrzyvry d10bd4dd b1 |
| 803 |
Added 3 files, modified 0 files, removed 0 files |
| 804 |
[EOF] |
| 805 |
"); |
| 806 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 807 |
@ 57d2a947c305 d2 |
| 808 |
├─╮ |
| 809 |
│ │ ○ aca0050dbbc4 c2 |
| 810 |
╭─┬─╯ |
| 811 |
│ ○ d10bd4ddb880 b1 |
| 812 |
│ ├─╮ |
| 813 |
○ │ │ 7db83f0f554b a1 |
| 814 |
╰─┬─╮ |
| 815 |
│ ○ ae61a031221a d1 |
| 816 |
○ │ 9b24b49f717e c1 |
| 817 |
├─╯ |
| 818 |
○ │ 65b6f1fe6b41 b2 |
| 819 |
○ │ 6a9343b8797a b1 |
| 820 |
├─╯ |
| 821 |
│ ○ e9b68b6313be a4 |
| 822 |
│ ○ 5fb83d2b58d6 a3 |
| 823 |
│ ○ 7bfd9fbe959c a2 |
| 824 |
│ ○ 5d93a4b8f4bd a1 |
| 825 |
├─╯ |
| 826 |
◆ 000000000000 |
| 827 |
[EOF] |
| 828 |
"); |
| 829 |
work_dir.run_jj(["op", "restore", &setup_opid]).success(); |
| 830 |
|
| 831 |
// Duplicate multiple commits without a direct ancestry relationship after |
| 832 |
// multiple commits including an ancestor of one of the duplicated commits. |
| 833 |
let output = work_dir.run_jj(["duplicate", "a3", "b1", "--after", "a1", "--after", "c1"]); |
| 834 |
insta::assert_snapshot!(output, @r" |
| 835 |
------- stderr ------- |
| 836 |
Warning: Duplicating commit 5fb83d2b58d6 as an ancestor of itself. |
| 837 |
Duplicated 5fb83d2b58d6 as vnqwxmpr 749e7782 a3 |
| 838 |
Duplicated 6a9343b8797a as pvqonzsn cdc6ab27 b1 |
| 839 |
Rebased 4 commits onto duplicated commits. |
| 840 |
[EOF] |
| 841 |
"); |
| 842 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 843 |
@ 3e122d6a4b70 d2 |
| 844 |
○ ae61a031221a d1 |
| 845 |
│ ○ 77dbe4a4ab86 c2 |
| 846 |
│ ├─╮ |
| 847 |
│ │ │ ○ 52a5fbe4cfe6 a4 |
| 848 |
│ │ │ ○ 87a6779455c5 a3 |
| 849 |
│ │ │ ○ 1df3435c91be a2 |
| 850 |
│ ╭─┬─╯ |
| 851 |
│ │ ○ cdc6ab279cb7 b1 |
| 852 |
│ │ ├─╮ |
| 853 |
│ ○ │ │ 749e778247d3 a3 |
| 854 |
│ ╰─┬─╮ |
| 855 |
│ │ ○ 9b24b49f717e c1 |
| 856 |
├─────╯ |
| 857 |
│ ○ 5d93a4b8f4bd a1 |
| 858 |
├───╯ |
| 859 |
│ ○ 65b6f1fe6b41 b2 |
| 860 |
│ ○ 6a9343b8797a b1 |
| 861 |
├─╯ |
| 862 |
◆ 000000000000 |
| 863 |
[EOF] |
| 864 |
"); |
| 865 |
work_dir.run_jj(["op", "restore", &setup_opid]).success(); |
| 866 |
|
| 867 |
// Duplicate multiple commits without a direct ancestry relationship after |
| 868 |
// multiple commits including a descendant of one of the duplicated commits. |
| 869 |
let output = work_dir.run_jj(["duplicate", "a1", "b1", "--after", "a3", "--after", "c2"]); |
| 870 |
insta::assert_snapshot!(output, @r" |
| 871 |
------- stderr ------- |
| 872 |
Warning: Duplicating commit 5d93a4b8f4bd as a descendant of itself. |
| 873 |
Duplicated 5d93a4b8f4bd as qtvkyytt e9ac46df (empty) a1 |
| 874 |
Duplicated 6a9343b8797a as ouvslmur bbf796e8 b1 |
| 875 |
Rebased 1 commits onto duplicated commits. |
| 876 |
[EOF] |
| 877 |
"); |
| 878 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 879 |
@ 3e122d6a4b70 d2 |
| 880 |
○ ae61a031221a d1 |
| 881 |
│ ○ ecaa1f7b16fb a4 |
| 882 |
│ ├─╮ |
| 883 |
│ │ ○ bbf796e8f265 b1 |
| 884 |
│ │ ├─╮ |
| 885 |
│ ○ │ │ e9ac46df3691 a1 |
| 886 |
│ ╰─┬─╮ |
| 887 |
│ │ ○ 47a79ab4bbc6 c2 |
| 888 |
│ │ ○ 9b24b49f717e c1 |
| 889 |
├─────╯ |
| 890 |
│ ○ 5fb83d2b58d6 a3 |
| 891 |
│ ○ 7bfd9fbe959c a2 |
| 892 |
│ ○ 5d93a4b8f4bd a1 |
| 893 |
├───╯ |
| 894 |
│ ○ 65b6f1fe6b41 b2 |
| 895 |
│ ○ 6a9343b8797a b1 |
| 896 |
├─╯ |
| 897 |
◆ 000000000000 |
| 898 |
[EOF] |
| 899 |
"); |
| 900 |
work_dir.run_jj(["op", "restore", &setup_opid]).success(); |
| 901 |
|
| 902 |
// Duplicate multiple commits with an ancestry relationship after a single |
| 903 |
// commit without a direct relationship. |
| 904 |
let output = work_dir.run_jj(["duplicate", "a1", "a3", "--after", "c2"]); |
| 905 |
insta::assert_snapshot!(output, @" |
| 906 |
------- stderr ------- |
| 907 |
Duplicated 5d93a4b8f4bd as qowqnpnw 0478473b a1 |
| 908 |
Duplicated 5fb83d2b58d6 as mommxqln 6175d88f a3 |
| 909 |
[EOF] |
| 910 |
"); |
| 911 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 912 |
@ 3e122d6a4b70 d2 |
| 913 |
○ ae61a031221a d1 |
| 914 |
│ ○ 6175d88f3848 a3 |
| 915 |
│ ○ 0478473bfff3 a1 |
| 916 |
│ ○ 47a79ab4bbc6 c2 |
| 917 |
│ ○ 9b24b49f717e c1 |
| 918 |
├─╯ |
| 919 |
│ ○ 65b6f1fe6b41 b2 |
| 920 |
│ ○ 6a9343b8797a b1 |
| 921 |
├─╯ |
| 922 |
│ ○ e9b68b6313be a4 |
| 923 |
│ ○ 5fb83d2b58d6 a3 |
| 924 |
│ ○ 7bfd9fbe959c a2 |
| 925 |
│ ○ 5d93a4b8f4bd a1 |
| 926 |
├─╯ |
| 927 |
◆ 000000000000 |
| 928 |
[EOF] |
| 929 |
"); |
| 930 |
work_dir.run_jj(["op", "restore", &setup_opid]).success(); |
| 931 |
|
| 932 |
// Duplicate multiple commits with an ancestry relationship after a single |
| 933 |
// ancestor commit. |
| 934 |
let output = work_dir.run_jj(["duplicate", "a2", "a3", "--after", "a1"]); |
| 935 |
insta::assert_snapshot!(output, @r" |
| 936 |
------- stderr ------- |
| 937 |
Warning: Duplicating commit 5fb83d2b58d6 as an ancestor of itself. |
| 938 |
Warning: Duplicating commit 7bfd9fbe959c as an ancestor of itself. |
| 939 |
Duplicated 7bfd9fbe959c as qzusktlu abac3b29 a2 |
| 940 |
Duplicated 5fb83d2b58d6 as zryotxso 0ac7bc72 a3 |
| 941 |
Rebased 3 commits onto duplicated commits. |
| 942 |
[EOF] |
| 943 |
"); |
| 944 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 945 |
@ 3e122d6a4b70 d2 |
| 946 |
○ ae61a031221a d1 |
| 947 |
│ ○ 47a79ab4bbc6 c2 |
| 948 |
│ ○ 9b24b49f717e c1 |
| 949 |
├─╯ |
| 950 |
│ ○ 65b6f1fe6b41 b2 |
| 951 |
│ ○ 6a9343b8797a b1 |
| 952 |
├─╯ |
| 953 |
│ ○ e6b5faccb8d6 a4 |
| 954 |
│ ○ 1b0489e81cdf a3 |
| 955 |
│ ○ 91cc24eeda92 a2 |
| 956 |
│ ○ 0ac7bc72e563 a3 |
| 957 |
│ ○ abac3b29eace a2 |
| 958 |
│ ○ 5d93a4b8f4bd a1 |
| 959 |
├─╯ |
| 960 |
◆ 000000000000 |
| 961 |
[EOF] |
| 962 |
"); |
| 963 |
work_dir.run_jj(["op", "restore", &setup_opid]).success(); |
| 964 |
|
| 965 |
// Duplicate multiple commits with an ancestry relationship after a single |
| 966 |
// descendant commit. |
| 967 |
let output = work_dir.run_jj(["duplicate", "a1", "a2", "--after", "a3"]); |
| 968 |
insta::assert_snapshot!(output, @r" |
| 969 |
------- stderr ------- |
| 970 |
Warning: Duplicating commit 7bfd9fbe959c as a descendant of itself. |
| 971 |
Warning: Duplicating commit 5d93a4b8f4bd as a descendant of itself. |
| 972 |
Duplicated 5d93a4b8f4bd as stzvpxow 607f49d4 (empty) a1 |
| 973 |
Duplicated 7bfd9fbe959c as zrzsnomp 802bec72 (empty) a2 |
| 974 |
Rebased 1 commits onto duplicated commits. |
| 975 |
[EOF] |
| 976 |
"); |
| 977 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 978 |
@ 3e122d6a4b70 d2 |
| 979 |
○ ae61a031221a d1 |
| 980 |
│ ○ 47a79ab4bbc6 c2 |
| 981 |
│ ○ 9b24b49f717e c1 |
| 982 |
├─╯ |
| 983 |
│ ○ 65b6f1fe6b41 b2 |
| 984 |
│ ○ 6a9343b8797a b1 |
| 985 |
├─╯ |
| 986 |
│ ○ 5968d4b950df a4 |
| 987 |
│ ○ 802bec723045 a2 |
| 988 |
│ ○ 607f49d4e2dd a1 |
| 989 |
│ ○ 5fb83d2b58d6 a3 |
| 990 |
│ ○ 7bfd9fbe959c a2 |
| 991 |
│ ○ 5d93a4b8f4bd a1 |
| 992 |
├─╯ |
| 993 |
◆ 000000000000 |
| 994 |
[EOF] |
| 995 |
"); |
| 996 |
work_dir.run_jj(["op", "restore", &setup_opid]).success(); |
| 997 |
|
| 998 |
// Duplicate multiple commits with an ancestry relationship after multiple |
| 999 |
// commits without a direct relationship to the duplicated commits. |
| 1000 |
let output = work_dir.run_jj(["duplicate", "a1", "a3", "--after", "c2", "--after", "d2"]); |
| 1001 |
insta::assert_snapshot!(output, @" |
| 1002 |
------- stderr ------- |
| 1003 |
Duplicated 5d93a4b8f4bd as ysllonyo 24a4e9f8 a1 |
| 1004 |
Duplicated 5fb83d2b58d6 as kzxwzvzw 64d6f104 a3 |
| 1005 |
[EOF] |
| 1006 |
"); |
| 1007 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 1008 |
○ 64d6f1045b10 a3 |
| 1009 |
○ 24a4e9f817c7 a1 |
| 1010 |
├─╮ |
| 1011 |
│ @ 3e122d6a4b70 d2 |
| 1012 |
│ ○ ae61a031221a d1 |
| 1013 |
○ │ 47a79ab4bbc6 c2 |
| 1014 |
○ │ 9b24b49f717e c1 |
| 1015 |
├─╯ |
| 1016 |
│ ○ 65b6f1fe6b41 b2 |
| 1017 |
│ ○ 6a9343b8797a b1 |
| 1018 |
├─╯ |
| 1019 |
│ ○ e9b68b6313be a4 |
| 1020 |
│ ○ 5fb83d2b58d6 a3 |
| 1021 |
│ ○ 7bfd9fbe959c a2 |
| 1022 |
│ ○ 5d93a4b8f4bd a1 |
| 1023 |
├─╯ |
| 1024 |
◆ 000000000000 |
| 1025 |
[EOF] |
| 1026 |
"); |
| 1027 |
work_dir.run_jj(["op", "restore", &setup_opid]).success(); |
| 1028 |
|
| 1029 |
// Duplicate multiple commits with an ancestry relationship after multiple |
| 1030 |
// commits including an ancestor of one of the duplicated commits. |
| 1031 |
let output = work_dir.run_jj(["duplicate", "a3", "a4", "--after", "a2", "--after", "c2"]); |
| 1032 |
insta::assert_snapshot!(output, @r" |
| 1033 |
------- stderr ------- |
| 1034 |
Warning: Duplicating commit e9b68b6313be as an ancestor of itself. |
| 1035 |
Warning: Duplicating commit 5fb83d2b58d6 as an ancestor of itself. |
| 1036 |
Duplicated 5fb83d2b58d6 as kvqpkqvl 59583d1b a3 |
| 1037 |
Duplicated e9b68b6313be as zqztuxrl b327e326 a4 |
| 1038 |
Rebased 2 commits onto duplicated commits. |
| 1039 |
[EOF] |
| 1040 |
"); |
| 1041 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 1042 |
@ 3e122d6a4b70 d2 |
| 1043 |
○ ae61a031221a d1 |
| 1044 |
│ ○ c6d033e3dbae a4 |
| 1045 |
│ ○ 969593962a7c a3 |
| 1046 |
│ ○ b327e326e151 a4 |
| 1047 |
│ ○ 59583d1b591c a3 |
| 1048 |
│ ├─╮ |
| 1049 |
│ │ ○ 47a79ab4bbc6 c2 |
| 1050 |
│ │ ○ 9b24b49f717e c1 |
| 1051 |
├───╯ |
| 1052 |
│ ○ 7bfd9fbe959c a2 |
| 1053 |
│ ○ 5d93a4b8f4bd a1 |
| 1054 |
├─╯ |
| 1055 |
│ ○ 65b6f1fe6b41 b2 |
| 1056 |
│ ○ 6a9343b8797a b1 |
| 1057 |
├─╯ |
| 1058 |
◆ 000000000000 |
| 1059 |
[EOF] |
| 1060 |
"); |
| 1061 |
work_dir.run_jj(["op", "restore", &setup_opid]).success(); |
| 1062 |
|
| 1063 |
// Duplicate multiple commits with an ancestry relationship after multiple |
| 1064 |
// commits including a descendant of one of the duplicated commits. |
| 1065 |
let output = work_dir.run_jj(["duplicate", "a1", "a2", "--after", "a3", "--after", "c2"]); |
| 1066 |
insta::assert_snapshot!(output, @r" |
| 1067 |
------- stderr ------- |
| 1068 |
Warning: Duplicating commit 7bfd9fbe959c as a descendant of itself. |
| 1069 |
Warning: Duplicating commit 5d93a4b8f4bd as a descendant of itself. |
| 1070 |
Duplicated 5d93a4b8f4bd as xsvtwpuq 579fa109 (empty) a1 |
| 1071 |
Duplicated 7bfd9fbe959c as tmzzmpyp 995ffc29 (empty) a2 |
| 1072 |
Rebased 1 commits onto duplicated commits. |
| 1073 |
[EOF] |
| 1074 |
"); |
| 1075 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 1076 |
@ 3e122d6a4b70 d2 |
| 1077 |
○ ae61a031221a d1 |
| 1078 |
│ ○ a462f9946f62 a4 |
| 1079 |
│ ○ 995ffc29e76b a2 |
| 1080 |
│ ○ 579fa1093ceb a1 |
| 1081 |
│ ├─╮ |
| 1082 |
│ │ ○ 47a79ab4bbc6 c2 |
| 1083 |
│ │ ○ 9b24b49f717e c1 |
| 1084 |
├───╯ |
| 1085 |
│ ○ 5fb83d2b58d6 a3 |
| 1086 |
│ ○ 7bfd9fbe959c a2 |
| 1087 |
│ ○ 5d93a4b8f4bd a1 |
| 1088 |
├─╯ |
| 1089 |
│ ○ 65b6f1fe6b41 b2 |
| 1090 |
│ ○ 6a9343b8797a b1 |
| 1091 |
├─╯ |
| 1092 |
◆ 000000000000 |
| 1093 |
[EOF] |
| 1094 |
"); |
| 1095 |
work_dir.run_jj(["op", "restore", &setup_opid]).success(); |
| 1096 |
|
| 1097 |
// Should error if a loop will be created. |
| 1098 |
let output = work_dir.run_jj(["duplicate", "a1", "--after", "b1", "--after", "b2"]); |
| 1099 |
insta::assert_snapshot!(output, @" |
| 1100 |
------- stderr ------- |
| 1101 |
Error: Refusing to create a loop: commit 65b6f1fe6b41 would be both an ancestor and a descendant of the duplicated commits |
| 1102 |
[EOF] |
| 1103 |
[exit status: 1] |
| 1104 |
"); |
| 1105 |
} |
| 1106 |
|
| 1107 |
#[test] |
| 1108 |
fn test_duplicate_insert_before() { |
| 1109 |
let test_env = TestEnvironment::default(); |
| 1110 |
test_env.run_jj_in(".", ["git", "init", "repo"]).success(); |
| 1111 |
let work_dir = test_env.work_dir("repo"); |
| 1112 |
|
| 1113 |
create_commit(&work_dir, "a1", &[]); |
| 1114 |
create_commit(&work_dir, "a2", &["a1"]); |
| 1115 |
create_commit(&work_dir, "a3", &["a2"]); |
| 1116 |
create_commit(&work_dir, "a4", &["a3"]); |
| 1117 |
create_commit(&work_dir, "b1", &[]); |
| 1118 |
create_commit(&work_dir, "b2", &["b1"]); |
| 1119 |
create_commit(&work_dir, "c1", &[]); |
| 1120 |
create_commit(&work_dir, "c2", &["c1"]); |
| 1121 |
create_commit(&work_dir, "d1", &[]); |
| 1122 |
create_commit(&work_dir, "d2", &["d1"]); |
| 1123 |
let setup_opid = work_dir.current_operation_id(); |
| 1124 |
|
| 1125 |
// Test the setup |
| 1126 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 1127 |
@ 3e122d6a4b70 d2 |
| 1128 |
○ ae61a031221a d1 |
| 1129 |
│ ○ 47a79ab4bbc6 c2 |
| 1130 |
│ ○ 9b24b49f717e c1 |
| 1131 |
├─╯ |
| 1132 |
│ ○ 65b6f1fe6b41 b2 |
| 1133 |
│ ○ 6a9343b8797a b1 |
| 1134 |
├─╯ |
| 1135 |
│ ○ e9b68b6313be a4 |
| 1136 |
│ ○ 5fb83d2b58d6 a3 |
| 1137 |
│ ○ 7bfd9fbe959c a2 |
| 1138 |
│ ○ 5d93a4b8f4bd a1 |
| 1139 |
├─╯ |
| 1140 |
◆ 000000000000 |
| 1141 |
[EOF] |
| 1142 |
"); |
| 1143 |
|
| 1144 |
// Duplicate a single commit before a single commit with no direct relationship. |
| 1145 |
let output = work_dir.run_jj(["duplicate", "a1", "--before", "b2"]); |
| 1146 |
insta::assert_snapshot!(output, @r" |
| 1147 |
------- stderr ------- |
| 1148 |
Duplicated 5d93a4b8f4bd as nlrtlrxv 52959024 a1 |
| 1149 |
Rebased 1 commits onto duplicated commits. |
| 1150 |
[EOF] |
| 1151 |
"); |
| 1152 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 1153 |
@ 3e122d6a4b70 d2 |
| 1154 |
○ ae61a031221a d1 |
| 1155 |
│ ○ 47a79ab4bbc6 c2 |
| 1156 |
│ ○ 9b24b49f717e c1 |
| 1157 |
├─╯ |
| 1158 |
│ ○ 8124402d0ebe b2 |
| 1159 |
│ ○ 52959024d93a a1 |
| 1160 |
│ ○ 6a9343b8797a b1 |
| 1161 |
├─╯ |
| 1162 |
│ ○ e9b68b6313be a4 |
| 1163 |
│ ○ 5fb83d2b58d6 a3 |
| 1164 |
│ ○ 7bfd9fbe959c a2 |
| 1165 |
│ ○ 5d93a4b8f4bd a1 |
| 1166 |
├─╯ |
| 1167 |
◆ 000000000000 |
| 1168 |
[EOF] |
| 1169 |
"); |
| 1170 |
work_dir.run_jj(["op", "restore", &setup_opid]).success(); |
| 1171 |
|
| 1172 |
// Duplicate a single commit before a single ancestor commit. |
| 1173 |
let output = work_dir.run_jj(["duplicate", "a3", "--before", "a1"]); |
| 1174 |
insta::assert_snapshot!(output, @r" |
| 1175 |
------- stderr ------- |
| 1176 |
Warning: Duplicating commit 5fb83d2b58d6 as an ancestor of itself. |
| 1177 |
Duplicated 5fb83d2b58d6 as uuuvxpvw cbb38dd4 a3 |
| 1178 |
Rebased 4 commits onto duplicated commits. |
| 1179 |
[EOF] |
| 1180 |
"); |
| 1181 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 1182 |
@ 3e122d6a4b70 d2 |
| 1183 |
○ ae61a031221a d1 |
| 1184 |
│ ○ 6d36ca1b1215 a4 |
| 1185 |
│ ○ ec479e2b5c1c a3 |
| 1186 |
│ ○ 54f79ca85067 a2 |
| 1187 |
│ ○ 34db3229bbf9 a1 |
| 1188 |
│ ○ cbb38dd4f677 a3 |
| 1189 |
├─╯ |
| 1190 |
│ ○ 47a79ab4bbc6 c2 |
| 1191 |
│ ○ 9b24b49f717e c1 |
| 1192 |
├─╯ |
| 1193 |
│ ○ 65b6f1fe6b41 b2 |
| 1194 |
│ ○ 6a9343b8797a b1 |
| 1195 |
├─╯ |
| 1196 |
◆ 000000000000 |
| 1197 |
[EOF] |
| 1198 |
"); |
| 1199 |
work_dir.run_jj(["op", "restore", &setup_opid]).success(); |
| 1200 |
|
| 1201 |
// Duplicate a single commit before a single descendant commit. |
| 1202 |
let output = work_dir.run_jj(["duplicate", "a1", "--before", "a3"]); |
| 1203 |
insta::assert_snapshot!(output, @r" |
| 1204 |
------- stderr ------- |
| 1205 |
Warning: Duplicating commit 5d93a4b8f4bd as a descendant of itself. |
| 1206 |
Duplicated 5d93a4b8f4bd as pkstwlsy e6dcd064 (empty) a1 |
| 1207 |
Rebased 2 commits onto duplicated commits. |
| 1208 |
[EOF] |
| 1209 |
"); |
| 1210 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 1211 |
@ 3e122d6a4b70 d2 |
| 1212 |
○ ae61a031221a d1 |
| 1213 |
│ ○ 47a79ab4bbc6 c2 |
| 1214 |
│ ○ 9b24b49f717e c1 |
| 1215 |
├─╯ |
| 1216 |
│ ○ 65b6f1fe6b41 b2 |
| 1217 |
│ ○ 6a9343b8797a b1 |
| 1218 |
├─╯ |
| 1219 |
│ ○ 88ed72c9e2cd a4 |
| 1220 |
│ ○ bf1cebc7b328 a3 |
| 1221 |
│ ○ e6dcd064caba a1 |
| 1222 |
│ ○ 7bfd9fbe959c a2 |
| 1223 |
│ ○ 5d93a4b8f4bd a1 |
| 1224 |
├─╯ |
| 1225 |
◆ 000000000000 |
| 1226 |
[EOF] |
| 1227 |
"); |
| 1228 |
work_dir.run_jj(["op", "restore", &setup_opid]).success(); |
| 1229 |
|
| 1230 |
// Duplicate a single commit before multiple commits with no direct |
| 1231 |
// relationship. |
| 1232 |
let output = work_dir.run_jj(["duplicate", "a1", "--before", "b2", "--before", "c2"]); |
| 1233 |
insta::assert_snapshot!(output, @r" |
| 1234 |
------- stderr ------- |
| 1235 |
Duplicated 5d93a4b8f4bd as zowrlwsv a78c25cc a1 |
| 1236 |
Rebased 2 commits onto duplicated commits. |
| 1237 |
[EOF] |
| 1238 |
"); |
| 1239 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 1240 |
@ 3e122d6a4b70 d2 |
| 1241 |
○ ae61a031221a d1 |
| 1242 |
│ ○ 4150b5a5466e c2 |
| 1243 |
│ │ ○ 4a1f33498a39 b2 |
| 1244 |
│ ├─╯ |
| 1245 |
│ ○ a78c25cc7d58 a1 |
| 1246 |
│ ├─╮ |
| 1247 |
│ │ ○ 9b24b49f717e c1 |
| 1248 |
├───╯ |
| 1249 |
│ ○ 6a9343b8797a b1 |
| 1250 |
├─╯ |
| 1251 |
│ ○ e9b68b6313be a4 |
| 1252 |
│ ○ 5fb83d2b58d6 a3 |
| 1253 |
│ ○ 7bfd9fbe959c a2 |
| 1254 |
│ ○ 5d93a4b8f4bd a1 |
| 1255 |
├─╯ |
| 1256 |
◆ 000000000000 |
| 1257 |
[EOF] |
| 1258 |
"); |
| 1259 |
work_dir.run_jj(["op", "restore", &setup_opid]).success(); |
| 1260 |
|
| 1261 |
// Duplicate a single commit before multiple commits including an ancestor. |
| 1262 |
let output = work_dir.run_jj(["duplicate", "a3", "--before", "a2", "--before", "b2"]); |
| 1263 |
insta::assert_snapshot!(output, @r" |
| 1264 |
------- stderr ------- |
| 1265 |
Warning: Duplicating commit 5fb83d2b58d6 as an ancestor of itself. |
| 1266 |
Duplicated 5fb83d2b58d6 as wvmqtotl 388c8d9d a3 |
| 1267 |
Rebased 4 commits onto duplicated commits. |
| 1268 |
[EOF] |
| 1269 |
"); |
| 1270 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 1271 |
@ 3e122d6a4b70 d2 |
| 1272 |
○ ae61a031221a d1 |
| 1273 |
│ ○ 47a79ab4bbc6 c2 |
| 1274 |
│ ○ 9b24b49f717e c1 |
| 1275 |
├─╯ |
| 1276 |
│ ○ a7c33fa6bdd2 b2 |
| 1277 |
│ │ ○ 4a4c76b85974 a4 |
| 1278 |
│ │ ○ 6e519ad5a603 a3 |
| 1279 |
│ │ ○ 40bb4cf3aecf a2 |
| 1280 |
│ ├─╯ |
| 1281 |
│ ○ 388c8d9d7b49 a3 |
| 1282 |
│ ├─╮ |
| 1283 |
│ │ ○ 6a9343b8797a b1 |
| 1284 |
├───╯ |
| 1285 |
│ ○ 5d93a4b8f4bd a1 |
| 1286 |
├─╯ |
| 1287 |
◆ 000000000000 |
| 1288 |
[EOF] |
| 1289 |
"); |
| 1290 |
work_dir.run_jj(["op", "restore", &setup_opid]).success(); |
| 1291 |
|
| 1292 |
// Duplicate a single commit before multiple commits including a descendant. |
| 1293 |
let output = work_dir.run_jj(["duplicate", "a1", "--before", "a3", "--before", "b2"]); |
| 1294 |
insta::assert_snapshot!(output, @r" |
| 1295 |
------- stderr ------- |
| 1296 |
Warning: Duplicating commit 5d93a4b8f4bd as a descendant of itself. |
| 1297 |
Duplicated 5d93a4b8f4bd as opwsxtwu 644afaf1 (empty) a1 |
| 1298 |
Rebased 3 commits onto duplicated commits. |
| 1299 |
[EOF] |
| 1300 |
"); |
| 1301 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 1302 |
@ 3e122d6a4b70 d2 |
| 1303 |
○ ae61a031221a d1 |
| 1304 |
│ ○ 47a79ab4bbc6 c2 |
| 1305 |
│ ○ 9b24b49f717e c1 |
| 1306 |
├─╯ |
| 1307 |
│ ○ 00f96f926fd4 b2 |
| 1308 |
│ │ ○ b0d1638032b2 a4 |
| 1309 |
│ │ ○ f2d014886a49 a3 |
| 1310 |
│ ├─╯ |
| 1311 |
│ ○ 644afaf17a49 a1 |
| 1312 |
│ ├─╮ |
| 1313 |
│ │ ○ 6a9343b8797a b1 |
| 1314 |
├───╯ |
| 1315 |
│ ○ 7bfd9fbe959c a2 |
| 1316 |
│ ○ 5d93a4b8f4bd a1 |
| 1317 |
├─╯ |
| 1318 |
◆ 000000000000 |
| 1319 |
[EOF] |
| 1320 |
"); |
| 1321 |
work_dir.run_jj(["op", "restore", &setup_opid]).success(); |
| 1322 |
|
| 1323 |
// Duplicate multiple commits without a direct ancestry relationship before a |
| 1324 |
// single commit without a direct relationship. |
| 1325 |
let output = work_dir.run_jj(["duplicate", "a1", "b1", "--before", "c1"]); |
| 1326 |
insta::assert_snapshot!(output, @r" |
| 1327 |
------- stderr ------- |
| 1328 |
Duplicated 5d93a4b8f4bd as ukwxllxp 3323f9c3 a1 |
| 1329 |
Duplicated 6a9343b8797a as yrwmsomt a6ef0369 b1 |
| 1330 |
Rebased 2 commits onto duplicated commits. |
| 1331 |
[EOF] |
| 1332 |
"); |
| 1333 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 1334 |
@ 3e122d6a4b70 d2 |
| 1335 |
○ ae61a031221a d1 |
| 1336 |
│ ○ a0d7984ef9ce c2 |
| 1337 |
│ ○ 2d5211a7d52f c1 |
| 1338 |
│ ├─╮ |
| 1339 |
│ │ ○ a6ef03692b89 b1 |
| 1340 |
├───╯ |
| 1341 |
│ ○ 3323f9c396f8 a1 |
| 1342 |
├─╯ |
| 1343 |
│ ○ 65b6f1fe6b41 b2 |
| 1344 |
│ ○ 6a9343b8797a b1 |
| 1345 |
├─╯ |
| 1346 |
│ ○ e9b68b6313be a4 |
| 1347 |
│ ○ 5fb83d2b58d6 a3 |
| 1348 |
│ ○ 7bfd9fbe959c a2 |
| 1349 |
│ ○ 5d93a4b8f4bd a1 |
| 1350 |
├─╯ |
| 1351 |
◆ 000000000000 |
| 1352 |
[EOF] |
| 1353 |
"); |
| 1354 |
work_dir.run_jj(["op", "restore", &setup_opid]).success(); |
| 1355 |
|
| 1356 |
// Duplicate multiple commits without a direct ancestry relationship before a |
| 1357 |
// single commit which is an ancestor of one of the duplicated commits. |
| 1358 |
let output = work_dir.run_jj(["duplicate", "a3", "b1", "--before", "a2"]); |
| 1359 |
insta::assert_snapshot!(output, @r" |
| 1360 |
------- stderr ------- |
| 1361 |
Warning: Duplicating commit 5fb83d2b58d6 as an ancestor of itself. |
| 1362 |
Duplicated 5fb83d2b58d6 as szrrkvty fa34ba15 a3 |
| 1363 |
Duplicated 6a9343b8797a as wvmrymqu dd6d65a2 b1 |
| 1364 |
Rebased 3 commits onto duplicated commits. |
| 1365 |
[EOF] |
| 1366 |
"); |
| 1367 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 1368 |
@ 3e122d6a4b70 d2 |
| 1369 |
○ ae61a031221a d1 |
| 1370 |
│ ○ 47a79ab4bbc6 c2 |
| 1371 |
│ ○ 9b24b49f717e c1 |
| 1372 |
├─╯ |
| 1373 |
│ ○ 65b6f1fe6b41 b2 |
| 1374 |
│ ○ 6a9343b8797a b1 |
| 1375 |
├─╯ |
| 1376 |
│ ○ 0f4182479035 a4 |
| 1377 |
│ ○ 2ce96f99ba9a a3 |
| 1378 |
│ ○ 18eda16173aa a2 |
| 1379 |
│ ├─╮ |
| 1380 |
│ │ ○ dd6d65a2db44 b1 |
| 1381 |
│ ○ │ fa34ba15a5cc a3 |
| 1382 |
│ ├─╯ |
| 1383 |
│ ○ 5d93a4b8f4bd a1 |
| 1384 |
├─╯ |
| 1385 |
◆ 000000000000 |
| 1386 |
[EOF] |
| 1387 |
"); |
| 1388 |
work_dir.run_jj(["op", "restore", &setup_opid]).success(); |
| 1389 |
|
| 1390 |
// Duplicate multiple commits without a direct ancestry relationship before a |
| 1391 |
// single commit which is a descendant of one of the duplicated commits. |
| 1392 |
let output = work_dir.run_jj(["duplicate", "a1", "b1", "--before", "a3"]); |
| 1393 |
insta::assert_snapshot!(output, @r" |
| 1394 |
------- stderr ------- |
| 1395 |
Warning: Duplicating commit 5d93a4b8f4bd as a descendant of itself. |
| 1396 |
Duplicated 5d93a4b8f4bd as ztnvrxlv 4131a4c1 (empty) a1 |
| 1397 |
Duplicated 6a9343b8797a as upuzqpxs 2a4ce4e3 b1 |
| 1398 |
Rebased 2 commits onto duplicated commits. |
| 1399 |
[EOF] |
| 1400 |
"); |
| 1401 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 1402 |
@ 3e122d6a4b70 d2 |
| 1403 |
○ ae61a031221a d1 |
| 1404 |
│ ○ 47a79ab4bbc6 c2 |
| 1405 |
│ ○ 9b24b49f717e c1 |
| 1406 |
├─╯ |
| 1407 |
│ ○ 65b6f1fe6b41 b2 |
| 1408 |
│ ○ 6a9343b8797a b1 |
| 1409 |
├─╯ |
| 1410 |
│ ○ cf945b2bc8af a4 |
| 1411 |
│ ○ 6f86e945fda5 a3 |
| 1412 |
│ ├─╮ |
| 1413 |
│ │ ○ 2a4ce4e3aebb b1 |
| 1414 |
│ ○ │ 4131a4c1003c a1 |
| 1415 |
│ ├─╯ |
| 1416 |
│ ○ 7bfd9fbe959c a2 |
| 1417 |
│ ○ 5d93a4b8f4bd a1 |
| 1418 |
├─╯ |
| 1419 |
◆ 000000000000 |
| 1420 |
[EOF] |
| 1421 |
"); |
| 1422 |
work_dir.run_jj(["op", "restore", &setup_opid]).success(); |
| 1423 |
|
| 1424 |
// Duplicate multiple commits without a direct ancestry relationship before |
| 1425 |
// multiple commits without a direct relationship to the duplicated commits. |
| 1426 |
let output = work_dir.run_jj(["duplicate", "a1", "b1", "--before", "c1", "--before", "d1"]); |
| 1427 |
insta::assert_snapshot!(output, @r" |
| 1428 |
------- stderr ------- |
| 1429 |
Duplicated 5d93a4b8f4bd as muymlknp 9add628e a1 |
| 1430 |
Duplicated 6a9343b8797a as snrzyvry b63fdd54 b1 |
| 1431 |
Rebased 4 commits onto duplicated commits. |
| 1432 |
Working copy (@) now at: nmzmmopx 1aec68e6 d2 | d2 |
| 1433 |
Parent commit (@-) : xznxytkn 3b2ee7ee d1 | d1 |
| 1434 |
Added 2 files, modified 0 files, removed 0 files |
| 1435 |
[EOF] |
| 1436 |
"); |
| 1437 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 1438 |
@ 1aec68e662c2 d2 |
| 1439 |
○ 3b2ee7eeb0c0 d1 |
| 1440 |
├─╮ |
| 1441 |
│ │ ○ a2adf9d2849d c2 |
| 1442 |
│ │ ○ fdc43aa17cf1 c1 |
| 1443 |
╭─┬─╯ |
| 1444 |
│ ○ b63fdd54c3f9 b1 |
| 1445 |
○ │ 9add628e2f94 a1 |
| 1446 |
├─╯ |
| 1447 |
│ ○ 65b6f1fe6b41 b2 |
| 1448 |
│ ○ 6a9343b8797a b1 |
| 1449 |
├─╯ |
| 1450 |
│ ○ e9b68b6313be a4 |
| 1451 |
│ ○ 5fb83d2b58d6 a3 |
| 1452 |
│ ○ 7bfd9fbe959c a2 |
| 1453 |
│ ○ 5d93a4b8f4bd a1 |
| 1454 |
├─╯ |
| 1455 |
◆ 000000000000 |
| 1456 |
[EOF] |
| 1457 |
"); |
| 1458 |
work_dir.run_jj(["op", "restore", &setup_opid]).success(); |
| 1459 |
|
| 1460 |
// Duplicate multiple commits without a direct ancestry relationship before |
| 1461 |
// multiple commits including an ancestor of one of the duplicated commits. |
| 1462 |
let output = work_dir.run_jj(["duplicate", "a3", "b1", "--before", "a1", "--before", "c1"]); |
| 1463 |
insta::assert_snapshot!(output, @r" |
| 1464 |
------- stderr ------- |
| 1465 |
Warning: Duplicating commit 5fb83d2b58d6 as an ancestor of itself. |
| 1466 |
Duplicated 5fb83d2b58d6 as vnqwxmpr 73f3594f a3 |
| 1467 |
Duplicated 6a9343b8797a as pvqonzsn 67d4a940 b1 |
| 1468 |
Rebased 6 commits onto duplicated commits. |
| 1469 |
[EOF] |
| 1470 |
"); |
| 1471 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 1472 |
@ 3e122d6a4b70 d2 |
| 1473 |
○ ae61a031221a d1 |
| 1474 |
│ ○ 12da11313262 c2 |
| 1475 |
│ ○ dbb8e01766cc c1 |
| 1476 |
│ ├─╮ |
| 1477 |
│ │ │ ○ 622c81500218 a4 |
| 1478 |
│ │ │ ○ ae205a70138e a3 |
| 1479 |
│ │ │ ○ 9e97d48369cd a2 |
| 1480 |
│ │ │ ○ 22afb4fd6d02 a1 |
| 1481 |
│ ╭─┬─╯ |
| 1482 |
│ │ ○ 67d4a9404b6b b1 |
| 1483 |
├───╯ |
| 1484 |
│ ○ 73f3594f082f a3 |
| 1485 |
├─╯ |
| 1486 |
│ ○ 65b6f1fe6b41 b2 |
| 1487 |
│ ○ 6a9343b8797a b1 |
| 1488 |
├─╯ |
| 1489 |
◆ 000000000000 |
| 1490 |
[EOF] |
| 1491 |
"); |
| 1492 |
work_dir.run_jj(["op", "restore", &setup_opid]).success(); |
| 1493 |
|
| 1494 |
// Duplicate multiple commits without a direct ancestry relationship before |
| 1495 |
// multiple commits including a descendant of one of the duplicated commits. |
| 1496 |
let output = work_dir.run_jj(["duplicate", "a1", "b1", "--before", "a3", "--before", "c2"]); |
| 1497 |
insta::assert_snapshot!(output, @r" |
| 1498 |
------- stderr ------- |
| 1499 |
Warning: Duplicating commit 5d93a4b8f4bd as a descendant of itself. |
| 1500 |
Duplicated 5d93a4b8f4bd as qtvkyytt 2a37f838 (empty) a1 |
| 1501 |
Duplicated 6a9343b8797a as ouvslmur f2337ef6 b1 |
| 1502 |
Rebased 3 commits onto duplicated commits. |
| 1503 |
[EOF] |
| 1504 |
"); |
| 1505 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 1506 |
@ 3e122d6a4b70 d2 |
| 1507 |
○ ae61a031221a d1 |
| 1508 |
│ ○ 7562404a5fe2 c2 |
| 1509 |
│ ├─╮ |
| 1510 |
│ │ │ ○ 116b92e839d4 a4 |
| 1511 |
│ │ │ ○ b814e7dd0b6d a3 |
| 1512 |
│ ╭─┬─╯ |
| 1513 |
│ │ ○ f2337ef6d7af b1 |
| 1514 |
│ │ ├─╮ |
| 1515 |
│ ○ │ │ 2a37f83808d9 a1 |
| 1516 |
│ ╰─┬─╮ |
| 1517 |
│ │ ○ 9b24b49f717e c1 |
| 1518 |
├─────╯ |
| 1519 |
│ ○ 7bfd9fbe959c a2 |
| 1520 |
│ ○ 5d93a4b8f4bd a1 |
| 1521 |
├───╯ |
| 1522 |
│ ○ 65b6f1fe6b41 b2 |
| 1523 |
│ ○ 6a9343b8797a b1 |
| 1524 |
├─╯ |
| 1525 |
◆ 000000000000 |
| 1526 |
[EOF] |
| 1527 |
"); |
| 1528 |
work_dir.run_jj(["op", "restore", &setup_opid]).success(); |
| 1529 |
|
| 1530 |
// Duplicate multiple commits with an ancestry relationship before a single |
| 1531 |
// commit without a direct relationship. |
| 1532 |
let output = work_dir.run_jj(["duplicate", "a1", "a3", "--before", "c2"]); |
| 1533 |
insta::assert_snapshot!(output, @r" |
| 1534 |
------- stderr ------- |
| 1535 |
Duplicated 5d93a4b8f4bd as qowqnpnw 1cd05f49 a1 |
| 1536 |
Duplicated 5fb83d2b58d6 as mommxqln 51d00be6 a3 |
| 1537 |
Rebased 1 commits onto duplicated commits. |
| 1538 |
[EOF] |
| 1539 |
"); |
| 1540 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 1541 |
@ 3e122d6a4b70 d2 |
| 1542 |
○ ae61a031221a d1 |
| 1543 |
│ ○ 7d22145dee97 c2 |
| 1544 |
│ ○ 51d00be616d6 a3 |
| 1545 |
│ ○ 1cd05f491a63 a1 |
| 1546 |
│ ○ 9b24b49f717e c1 |
| 1547 |
├─╯ |
| 1548 |
│ ○ 65b6f1fe6b41 b2 |
| 1549 |
│ ○ 6a9343b8797a b1 |
| 1550 |
├─╯ |
| 1551 |
│ ○ e9b68b6313be a4 |
| 1552 |
│ ○ 5fb83d2b58d6 a3 |
| 1553 |
│ ○ 7bfd9fbe959c a2 |
| 1554 |
│ ○ 5d93a4b8f4bd a1 |
| 1555 |
├─╯ |
| 1556 |
◆ 000000000000 |
| 1557 |
[EOF] |
| 1558 |
"); |
| 1559 |
work_dir.run_jj(["op", "restore", &setup_opid]).success(); |
| 1560 |
|
| 1561 |
// Duplicate multiple commits with an ancestry relationship before a single |
| 1562 |
// ancestor commit. |
| 1563 |
let output = work_dir.run_jj(["duplicate", "a1", "a3", "--before", "a1"]); |
| 1564 |
insta::assert_snapshot!(output, @r" |
| 1565 |
------- stderr ------- |
| 1566 |
Warning: Duplicating commit 5fb83d2b58d6 as an ancestor of itself. |
| 1567 |
Warning: Duplicating commit 5d93a4b8f4bd as an ancestor of itself. |
| 1568 |
Duplicated 5d93a4b8f4bd as qzusktlu d8aaed30 a1 |
| 1569 |
Duplicated 5fb83d2b58d6 as zryotxso 701cf123 a3 |
| 1570 |
Rebased 4 commits onto duplicated commits. |
| 1571 |
[EOF] |
| 1572 |
"); |
| 1573 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 1574 |
@ 3e122d6a4b70 d2 |
| 1575 |
○ ae61a031221a d1 |
| 1576 |
│ ○ d44c70bd7777 a4 |
| 1577 |
│ ○ 4898b1b61699 a3 |
| 1578 |
│ ○ c10b845b6926 a2 |
| 1579 |
│ ○ 848ddba9889a a1 |
| 1580 |
│ ○ 701cf1238e40 a3 |
| 1581 |
│ ○ d8aaed30e073 a1 |
| 1582 |
├─╯ |
| 1583 |
│ ○ 47a79ab4bbc6 c2 |
| 1584 |
│ ○ 9b24b49f717e c1 |
| 1585 |
├─╯ |
| 1586 |
│ ○ 65b6f1fe6b41 b2 |
| 1587 |
│ ○ 6a9343b8797a b1 |
| 1588 |
├─╯ |
| 1589 |
◆ 000000000000 |
| 1590 |
[EOF] |
| 1591 |
"); |
| 1592 |
work_dir.run_jj(["op", "restore", &setup_opid]).success(); |
| 1593 |
|
| 1594 |
// Duplicate multiple commits with an ancestry relationship before a single |
| 1595 |
// descendant commit. |
| 1596 |
let output = work_dir.run_jj(["duplicate", "a1", "a2", "--before", "a3"]); |
| 1597 |
insta::assert_snapshot!(output, @r" |
| 1598 |
------- stderr ------- |
| 1599 |
Warning: Duplicating commit 7bfd9fbe959c as a descendant of itself. |
| 1600 |
Warning: Duplicating commit 5d93a4b8f4bd as a descendant of itself. |
| 1601 |
Duplicated 5d93a4b8f4bd as stzvpxow ced08d1e (empty) a1 |
| 1602 |
Duplicated 7bfd9fbe959c as zrzsnomp fe7136d1 (empty) a2 |
| 1603 |
Rebased 2 commits onto duplicated commits. |
| 1604 |
[EOF] |
| 1605 |
"); |
| 1606 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 1607 |
@ 3e122d6a4b70 d2 |
| 1608 |
○ ae61a031221a d1 |
| 1609 |
│ ○ 47a79ab4bbc6 c2 |
| 1610 |
│ ○ 9b24b49f717e c1 |
| 1611 |
├─╯ |
| 1612 |
│ ○ 65b6f1fe6b41 b2 |
| 1613 |
│ ○ 6a9343b8797a b1 |
| 1614 |
├─╯ |
| 1615 |
│ ○ f83372ee5f96 a4 |
| 1616 |
│ ○ aac435e6dffb a3 |
| 1617 |
│ ○ fe7136d10a72 a2 |
| 1618 |
│ ○ ced08d1e6dd9 a1 |
| 1619 |
│ ○ 7bfd9fbe959c a2 |
| 1620 |
│ ○ 5d93a4b8f4bd a1 |
| 1621 |
├─╯ |
| 1622 |
◆ 000000000000 |
| 1623 |
[EOF] |
| 1624 |
"); |
| 1625 |
work_dir.run_jj(["op", "restore", &setup_opid]).success(); |
| 1626 |
|
| 1627 |
// Duplicate multiple commits with an ancestry relationship before multiple |
| 1628 |
// commits without a direct relationship to the duplicated commits. |
| 1629 |
let output = work_dir.run_jj(["duplicate", "a1", "a3", "--before", "c2", "--before", "d2"]); |
| 1630 |
insta::assert_snapshot!(output, @r" |
| 1631 |
------- stderr ------- |
| 1632 |
Duplicated 5d93a4b8f4bd as ysllonyo b9b23a94 a1 |
| 1633 |
Duplicated 5fb83d2b58d6 as kzxwzvzw 22d5f430 a3 |
| 1634 |
Rebased 2 commits onto duplicated commits. |
| 1635 |
Working copy (@) now at: nmzmmopx b00d1c06 d2 | d2 |
| 1636 |
Parent commit (@-) : kzxwzvzw 22d5f430 a3 |
| 1637 |
Added 3 files, modified 0 files, removed 0 files |
| 1638 |
[EOF] |
| 1639 |
"); |
| 1640 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 1641 |
@ b00d1c0624f9 d2 |
| 1642 |
│ ○ bbc756f1d839 c2 |
| 1643 |
├─╯ |
| 1644 |
○ 22d5f4304b47 a3 |
| 1645 |
○ b9b23a944c2a a1 |
| 1646 |
├─╮ |
| 1647 |
│ ○ ae61a031221a d1 |
| 1648 |
○ │ 9b24b49f717e c1 |
| 1649 |
├─╯ |
| 1650 |
│ ○ 65b6f1fe6b41 b2 |
| 1651 |
│ ○ 6a9343b8797a b1 |
| 1652 |
├─╯ |
| 1653 |
│ ○ e9b68b6313be a4 |
| 1654 |
│ ○ 5fb83d2b58d6 a3 |
| 1655 |
│ ○ 7bfd9fbe959c a2 |
| 1656 |
│ ○ 5d93a4b8f4bd a1 |
| 1657 |
├─╯ |
| 1658 |
◆ 000000000000 |
| 1659 |
[EOF] |
| 1660 |
"); |
| 1661 |
work_dir.run_jj(["op", "restore", &setup_opid]).success(); |
| 1662 |
|
| 1663 |
// Duplicate multiple commits with an ancestry relationship before multiple |
| 1664 |
// commits including an ancestor of one of the duplicated commits. |
| 1665 |
let output = work_dir.run_jj(["duplicate", "a3", "a4", "--before", "a2", "--before", "c2"]); |
| 1666 |
insta::assert_snapshot!(output, @r" |
| 1667 |
------- stderr ------- |
| 1668 |
Warning: Duplicating commit e9b68b6313be as an ancestor of itself. |
| 1669 |
Warning: Duplicating commit 5fb83d2b58d6 as an ancestor of itself. |
| 1670 |
Duplicated 5fb83d2b58d6 as kvqpkqvl 469d73d0 a3 |
| 1671 |
Duplicated e9b68b6313be as zqztuxrl 1146a57a a4 |
| 1672 |
Rebased 4 commits onto duplicated commits. |
| 1673 |
[EOF] |
| 1674 |
"); |
| 1675 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 1676 |
@ 3e122d6a4b70 d2 |
| 1677 |
○ ae61a031221a d1 |
| 1678 |
│ ○ 93291babd184 c2 |
| 1679 |
│ │ ○ 83bce95a4e22 a4 |
| 1680 |
│ │ ○ 26314519c960 a3 |
| 1681 |
│ │ ○ 0d0144d0c427 a2 |
| 1682 |
│ ├─╯ |
| 1683 |
│ ○ 1146a57afb7c a4 |
| 1684 |
│ ○ 469d73d08c1b a3 |
| 1685 |
│ ├─╮ |
| 1686 |
│ │ ○ 9b24b49f717e c1 |
| 1687 |
├───╯ |
| 1688 |
│ ○ 5d93a4b8f4bd a1 |
| 1689 |
├─╯ |
| 1690 |
│ ○ 65b6f1fe6b41 b2 |
| 1691 |
│ ○ 6a9343b8797a b1 |
| 1692 |
├─╯ |
| 1693 |
◆ 000000000000 |
| 1694 |
[EOF] |
| 1695 |
"); |
| 1696 |
work_dir.run_jj(["op", "restore", &setup_opid]).success(); |
| 1697 |
|
| 1698 |
// Duplicate multiple commits with an ancestry relationship before multiple |
| 1699 |
// commits including a descendant of one of the duplicated commits. |
| 1700 |
let output = work_dir.run_jj(["duplicate", "a1", "a2", "--before", "a3", "--before", "c2"]); |
| 1701 |
insta::assert_snapshot!(output, @r" |
| 1702 |
------- stderr ------- |
| 1703 |
Warning: Duplicating commit 7bfd9fbe959c as a descendant of itself. |
| 1704 |
Warning: Duplicating commit 5d93a4b8f4bd as a descendant of itself. |
| 1705 |
Duplicated 5d93a4b8f4bd as xsvtwpuq b166c219 (empty) a1 |
| 1706 |
Duplicated 7bfd9fbe959c as tmzzmpyp 111a9c6e (empty) a2 |
| 1707 |
Rebased 3 commits onto duplicated commits. |
| 1708 |
[EOF] |
| 1709 |
"); |
| 1710 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 1711 |
@ 3e122d6a4b70 d2 |
| 1712 |
○ ae61a031221a d1 |
| 1713 |
│ ○ f1c1d4b44d61 c2 |
| 1714 |
│ │ ○ ffef7620a964 a4 |
| 1715 |
│ │ ○ 9b06af9a8d57 a3 |
| 1716 |
│ ├─╯ |
| 1717 |
│ ○ 111a9c6ec9da a2 |
| 1718 |
│ ○ b166c219ae16 a1 |
| 1719 |
│ ├─╮ |
| 1720 |
│ │ ○ 9b24b49f717e c1 |
| 1721 |
├───╯ |
| 1722 |
│ ○ 7bfd9fbe959c a2 |
| 1723 |
│ ○ 5d93a4b8f4bd a1 |
| 1724 |
├─╯ |
| 1725 |
│ ○ 65b6f1fe6b41 b2 |
| 1726 |
│ ○ 6a9343b8797a b1 |
| 1727 |
├─╯ |
| 1728 |
◆ 000000000000 |
| 1729 |
[EOF] |
| 1730 |
"); |
| 1731 |
work_dir.run_jj(["op", "restore", &setup_opid]).success(); |
| 1732 |
|
| 1733 |
// Should error if a loop will be created. |
| 1734 |
let output = work_dir.run_jj(["duplicate", "a1", "--before", "b1", "--before", "b2"]); |
| 1735 |
insta::assert_snapshot!(output, @" |
| 1736 |
------- stderr ------- |
| 1737 |
Error: Refusing to create a loop: commit 6a9343b8797a would be both an ancestor and a descendant of the duplicated commits |
| 1738 |
[EOF] |
| 1739 |
[exit status: 1] |
| 1740 |
"); |
| 1741 |
} |
| 1742 |
|
| 1743 |
#[test] |
| 1744 |
fn test_duplicate_insert_after_before() { |
| 1745 |
let test_env = TestEnvironment::default(); |
| 1746 |
test_env.run_jj_in(".", ["git", "init", "repo"]).success(); |
| 1747 |
let work_dir = test_env.work_dir("repo"); |
| 1748 |
|
| 1749 |
create_commit(&work_dir, "a1", &[]); |
| 1750 |
create_commit(&work_dir, "a2", &["a1"]); |
| 1751 |
create_commit(&work_dir, "a3", &["a2"]); |
| 1752 |
create_commit(&work_dir, "a4", &["a3"]); |
| 1753 |
create_commit(&work_dir, "b1", &[]); |
| 1754 |
create_commit(&work_dir, "b2", &["b1"]); |
| 1755 |
create_commit(&work_dir, "c1", &[]); |
| 1756 |
create_commit(&work_dir, "c2", &["c1"]); |
| 1757 |
create_commit(&work_dir, "d1", &[]); |
| 1758 |
create_commit(&work_dir, "d2", &["d1"]); |
| 1759 |
let setup_opid = work_dir.current_operation_id(); |
| 1760 |
|
| 1761 |
// Test the setup |
| 1762 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 1763 |
@ 3e122d6a4b70 d2 |
| 1764 |
○ ae61a031221a d1 |
| 1765 |
│ ○ 47a79ab4bbc6 c2 |
| 1766 |
│ ○ 9b24b49f717e c1 |
| 1767 |
├─╯ |
| 1768 |
│ ○ 65b6f1fe6b41 b2 |
| 1769 |
│ ○ 6a9343b8797a b1 |
| 1770 |
├─╯ |
| 1771 |
│ ○ e9b68b6313be a4 |
| 1772 |
│ ○ 5fb83d2b58d6 a3 |
| 1773 |
│ ○ 7bfd9fbe959c a2 |
| 1774 |
│ ○ 5d93a4b8f4bd a1 |
| 1775 |
├─╯ |
| 1776 |
◆ 000000000000 |
| 1777 |
[EOF] |
| 1778 |
"); |
| 1779 |
|
| 1780 |
// Duplicate a single commit in between commits with no direct relationship. |
| 1781 |
let output = work_dir.run_jj(["duplicate", "a1", "--before", "b2", "--after", "c2"]); |
| 1782 |
insta::assert_snapshot!(output, @r" |
| 1783 |
------- stderr ------- |
| 1784 |
Duplicated 5d93a4b8f4bd as nlrtlrxv 16aac4ae a1 |
| 1785 |
Rebased 1 commits onto duplicated commits. |
| 1786 |
[EOF] |
| 1787 |
"); |
| 1788 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 1789 |
@ 3e122d6a4b70 d2 |
| 1790 |
○ ae61a031221a d1 |
| 1791 |
│ ○ b0611efaa0d5 b2 |
| 1792 |
│ ├─╮ |
| 1793 |
│ │ ○ 16aac4aec6de a1 |
| 1794 |
│ │ ○ 47a79ab4bbc6 c2 |
| 1795 |
│ │ ○ 9b24b49f717e c1 |
| 1796 |
├───╯ |
| 1797 |
│ ○ 6a9343b8797a b1 |
| 1798 |
├─╯ |
| 1799 |
│ ○ e9b68b6313be a4 |
| 1800 |
│ ○ 5fb83d2b58d6 a3 |
| 1801 |
│ ○ 7bfd9fbe959c a2 |
| 1802 |
│ ○ 5d93a4b8f4bd a1 |
| 1803 |
├─╯ |
| 1804 |
◆ 000000000000 |
| 1805 |
[EOF] |
| 1806 |
"); |
| 1807 |
work_dir.run_jj(["op", "restore", &setup_opid]).success(); |
| 1808 |
|
| 1809 |
// Duplicate a single commit in between ancestor commits. |
| 1810 |
let output = work_dir.run_jj(["duplicate", "a3", "--before", "a2", "--after", "a1"]); |
| 1811 |
insta::assert_snapshot!(output, @r" |
| 1812 |
------- stderr ------- |
| 1813 |
Warning: Duplicating commit 5fb83d2b58d6 as an ancestor of itself. |
| 1814 |
Duplicated 5fb83d2b58d6 as uuuvxpvw f626655e a3 |
| 1815 |
Rebased 3 commits onto duplicated commits. |
| 1816 |
[EOF] |
| 1817 |
"); |
| 1818 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 1819 |
@ 3e122d6a4b70 d2 |
| 1820 |
○ ae61a031221a d1 |
| 1821 |
│ ○ 47a79ab4bbc6 c2 |
| 1822 |
│ ○ 9b24b49f717e c1 |
| 1823 |
├─╯ |
| 1824 |
│ ○ 65b6f1fe6b41 b2 |
| 1825 |
│ ○ 6a9343b8797a b1 |
| 1826 |
├─╯ |
| 1827 |
│ ○ cfea8bb13adf a4 |
| 1828 |
│ ○ 3a595c648b6d a3 |
| 1829 |
│ ○ 307ab42af890 a2 |
| 1830 |
│ ○ f626655ef3dd a3 |
| 1831 |
│ ○ 5d93a4b8f4bd a1 |
| 1832 |
├─╯ |
| 1833 |
◆ 000000000000 |
| 1834 |
[EOF] |
| 1835 |
"); |
| 1836 |
work_dir.run_jj(["op", "restore", &setup_opid]).success(); |
| 1837 |
|
| 1838 |
// Duplicate a single commit in between an ancestor commit and a commit with no |
| 1839 |
// direct relationship. |
| 1840 |
let output = work_dir.run_jj(["duplicate", "a3", "--before", "a2", "--after", "b2"]); |
| 1841 |
insta::assert_snapshot!(output, @r" |
| 1842 |
------- stderr ------- |
| 1843 |
Warning: Duplicating commit 5fb83d2b58d6 as an ancestor of itself. |
| 1844 |
Duplicated 5fb83d2b58d6 as pkstwlsy 99b4ea10 a3 |
| 1845 |
Rebased 3 commits onto duplicated commits. |
| 1846 |
[EOF] |
| 1847 |
"); |
| 1848 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 1849 |
@ 3e122d6a4b70 d2 |
| 1850 |
○ ae61a031221a d1 |
| 1851 |
│ ○ 47a79ab4bbc6 c2 |
| 1852 |
│ ○ 9b24b49f717e c1 |
| 1853 |
├─╯ |
| 1854 |
│ ○ 8671cfa6437d a4 |
| 1855 |
│ ○ b7e2ccc4ab64 a3 |
| 1856 |
│ ○ 44b6be52de17 a2 |
| 1857 |
│ ├─╮ |
| 1858 |
│ │ ○ 99b4ea109aff a3 |
| 1859 |
│ │ ○ 65b6f1fe6b41 b2 |
| 1860 |
│ │ ○ 6a9343b8797a b1 |
| 1861 |
├───╯ |
| 1862 |
│ ○ 5d93a4b8f4bd a1 |
| 1863 |
├─╯ |
| 1864 |
◆ 000000000000 |
| 1865 |
[EOF] |
| 1866 |
"); |
| 1867 |
work_dir.run_jj(["op", "restore", &setup_opid]).success(); |
| 1868 |
|
| 1869 |
// Duplicate a single commit in between descendant commits. |
| 1870 |
let output = work_dir.run_jj(["duplicate", "a1", "--after", "a3", "--before", "a4"]); |
| 1871 |
insta::assert_snapshot!(output, @r" |
| 1872 |
------- stderr ------- |
| 1873 |
Warning: Duplicating commit 5d93a4b8f4bd as a descendant of itself. |
| 1874 |
Duplicated 5d93a4b8f4bd as zowrlwsv 5ba52649 (empty) a1 |
| 1875 |
Rebased 1 commits onto duplicated commits. |
| 1876 |
[EOF] |
| 1877 |
"); |
| 1878 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 1879 |
@ 3e122d6a4b70 d2 |
| 1880 |
○ ae61a031221a d1 |
| 1881 |
│ ○ 47a79ab4bbc6 c2 |
| 1882 |
│ ○ 9b24b49f717e c1 |
| 1883 |
├─╯ |
| 1884 |
│ ○ 65b6f1fe6b41 b2 |
| 1885 |
│ ○ 6a9343b8797a b1 |
| 1886 |
├─╯ |
| 1887 |
│ ○ 2ad2abd6ed40 a4 |
| 1888 |
│ ○ 5ba52649f9f6 a1 |
| 1889 |
│ ○ 5fb83d2b58d6 a3 |
| 1890 |
│ ○ 7bfd9fbe959c a2 |
| 1891 |
│ ○ 5d93a4b8f4bd a1 |
| 1892 |
├─╯ |
| 1893 |
◆ 000000000000 |
| 1894 |
[EOF] |
| 1895 |
"); |
| 1896 |
work_dir.run_jj(["op", "restore", &setup_opid]).success(); |
| 1897 |
|
| 1898 |
// Duplicate a single commit in between a descendant commit and a commit with no |
| 1899 |
// direct relationship. |
| 1900 |
let output = work_dir.run_jj(["duplicate", "a1", "--after", "a3", "--before", "b2"]); |
| 1901 |
insta::assert_snapshot!(output, @r" |
| 1902 |
------- stderr ------- |
| 1903 |
Warning: Duplicating commit 5d93a4b8f4bd as a descendant of itself. |
| 1904 |
Duplicated 5d93a4b8f4bd as wvmqtotl ef1e2f46 (empty) a1 |
| 1905 |
Rebased 1 commits onto duplicated commits. |
| 1906 |
[EOF] |
| 1907 |
"); |
| 1908 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 1909 |
@ 3e122d6a4b70 d2 |
| 1910 |
○ ae61a031221a d1 |
| 1911 |
│ ○ 47a79ab4bbc6 c2 |
| 1912 |
│ ○ 9b24b49f717e c1 |
| 1913 |
├─╯ |
| 1914 |
│ ○ e9701b5153e5 b2 |
| 1915 |
│ ├─╮ |
| 1916 |
│ │ ○ ef1e2f461427 a1 |
| 1917 |
│ ○ │ 6a9343b8797a b1 |
| 1918 |
├─╯ │ |
| 1919 |
│ ○ │ e9b68b6313be a4 |
| 1920 |
│ ├─╯ |
| 1921 |
│ ○ 5fb83d2b58d6 a3 |
| 1922 |
│ ○ 7bfd9fbe959c a2 |
| 1923 |
│ ○ 5d93a4b8f4bd a1 |
| 1924 |
├─╯ |
| 1925 |
◆ 000000000000 |
| 1926 |
[EOF] |
| 1927 |
"); |
| 1928 |
work_dir.run_jj(["op", "restore", &setup_opid]).success(); |
| 1929 |
|
| 1930 |
// Duplicate a single commit in between an ancestor commit and a descendant |
| 1931 |
// commit. |
| 1932 |
let output = work_dir.run_jj(["duplicate", "a2", "--after", "a1", "--before", "a4"]); |
| 1933 |
insta::assert_snapshot!(output, @r" |
| 1934 |
------- stderr ------- |
| 1935 |
Duplicated 7bfd9fbe959c as opwsxtwu c9d7dee9 a2 |
| 1936 |
Rebased 1 commits onto duplicated commits. |
| 1937 |
[EOF] |
| 1938 |
"); |
| 1939 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 1940 |
@ 3e122d6a4b70 d2 |
| 1941 |
○ ae61a031221a d1 |
| 1942 |
│ ○ 47a79ab4bbc6 c2 |
| 1943 |
│ ○ 9b24b49f717e c1 |
| 1944 |
├─╯ |
| 1945 |
│ ○ 65b6f1fe6b41 b2 |
| 1946 |
│ ○ 6a9343b8797a b1 |
| 1947 |
├─╯ |
| 1948 |
│ ○ 5249308b5df2 a4 |
| 1949 |
│ ├─╮ |
| 1950 |
│ │ ○ c9d7dee9b730 a2 |
| 1951 |
│ ○ │ 5fb83d2b58d6 a3 |
| 1952 |
│ ○ │ 7bfd9fbe959c a2 |
| 1953 |
│ ├─╯ |
| 1954 |
│ ○ 5d93a4b8f4bd a1 |
| 1955 |
├─╯ |
| 1956 |
◆ 000000000000 |
| 1957 |
[EOF] |
| 1958 |
"); |
| 1959 |
work_dir.run_jj(["op", "restore", &setup_opid]).success(); |
| 1960 |
|
| 1961 |
// Duplicate multiple commits without a direct ancestry relationship between |
| 1962 |
// commits without a direct relationship. |
| 1963 |
let output = work_dir.run_jj(["duplicate", "a1", "b1", "--after", "c1", "--before", "d2"]); |
| 1964 |
insta::assert_snapshot!(output, @r" |
| 1965 |
------- stderr ------- |
| 1966 |
Duplicated 5d93a4b8f4bd as ukwxllxp 0cedc1c7 a1 |
| 1967 |
Duplicated 6a9343b8797a as yrwmsomt 0d18a4ba b1 |
| 1968 |
Rebased 1 commits onto duplicated commits. |
| 1969 |
Working copy (@) now at: nmzmmopx 4aafd744 d2 | d2 |
| 1970 |
Parent commit (@-) : xznxytkn ae61a031 d1 | d1 |
| 1971 |
Parent commit (@-) : ukwxllxp 0cedc1c7 a1 |
| 1972 |
Parent commit (@-) : yrwmsomt 0d18a4ba b1 |
| 1973 |
Added 3 files, modified 0 files, removed 0 files |
| 1974 |
[EOF] |
| 1975 |
"); |
| 1976 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 1977 |
@ 4aafd7445a66 d2 |
| 1978 |
├─┬─╮ |
| 1979 |
│ │ ○ 0d18a4ba8860 b1 |
| 1980 |
│ ○ │ 0cedc1c7f5dc a1 |
| 1981 |
│ ├─╯ |
| 1982 |
○ │ ae61a031221a d1 |
| 1983 |
│ │ ○ 47a79ab4bbc6 c2 |
| 1984 |
│ ├─╯ |
| 1985 |
│ ○ 9b24b49f717e c1 |
| 1986 |
├─╯ |
| 1987 |
│ ○ 65b6f1fe6b41 b2 |
| 1988 |
│ ○ 6a9343b8797a b1 |
| 1989 |
├─╯ |
| 1990 |
│ ○ e9b68b6313be a4 |
| 1991 |
│ ○ 5fb83d2b58d6 a3 |
| 1992 |
│ ○ 7bfd9fbe959c a2 |
| 1993 |
│ ○ 5d93a4b8f4bd a1 |
| 1994 |
├─╯ |
| 1995 |
◆ 000000000000 |
| 1996 |
[EOF] |
| 1997 |
"); |
| 1998 |
work_dir.run_jj(["op", "restore", &setup_opid]).success(); |
| 1999 |
|
| 2000 |
// Duplicate multiple commits without a direct ancestry relationship between a |
| 2001 |
// commit which is an ancestor of one of the duplicated commits and a commit |
| 2002 |
// with no direct relationship. |
| 2003 |
let output = work_dir.run_jj(["duplicate", "a3", "b1", "--after", "a2", "--before", "c2"]); |
| 2004 |
insta::assert_snapshot!(output, @r" |
| 2005 |
------- stderr ------- |
| 2006 |
Duplicated 5fb83d2b58d6 as szrrkvty 5ea1ddf1 a3 |
| 2007 |
Duplicated 6a9343b8797a as wvmrymqu 8081d164 b1 |
| 2008 |
Rebased 1 commits onto duplicated commits. |
| 2009 |
[EOF] |
| 2010 |
"); |
| 2011 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 2012 |
@ 3e122d6a4b70 d2 |
| 2013 |
○ ae61a031221a d1 |
| 2014 |
│ ○ 410b365b142e c2 |
| 2015 |
│ ├─┬─╮ |
| 2016 |
│ │ │ ○ 8081d1648811 b1 |
| 2017 |
│ │ ○ │ 5ea1ddf11f02 a3 |
| 2018 |
│ │ ├─╯ |
| 2019 |
│ ○ │ 9b24b49f717e c1 |
| 2020 |
├─╯ │ |
| 2021 |
│ ○ │ 65b6f1fe6b41 b2 |
| 2022 |
│ ○ │ 6a9343b8797a b1 |
| 2023 |
├─╯ │ |
| 2024 |
│ ○ │ e9b68b6313be a4 |
| 2025 |
│ ○ │ 5fb83d2b58d6 a3 |
| 2026 |
│ ├─╯ |
| 2027 |
│ ○ 7bfd9fbe959c a2 |
| 2028 |
│ ○ 5d93a4b8f4bd a1 |
| 2029 |
├─╯ |
| 2030 |
◆ 000000000000 |
| 2031 |
[EOF] |
| 2032 |
"); |
| 2033 |
work_dir.run_jj(["op", "restore", &setup_opid]).success(); |
| 2034 |
|
| 2035 |
// Duplicate multiple commits without a direct ancestry relationship between a |
| 2036 |
// commit which is a descendant of one of the duplicated commits and a |
| 2037 |
// commit with no direct relationship. |
| 2038 |
let output = work_dir.run_jj(["duplicate", "a1", "b1", "--after", "a3", "--before", "c2"]); |
| 2039 |
insta::assert_snapshot!(output, @r" |
| 2040 |
------- stderr ------- |
| 2041 |
Warning: Duplicating commit 5d93a4b8f4bd as a descendant of itself. |
| 2042 |
Duplicated 5d93a4b8f4bd as ztnvrxlv 896deede (empty) a1 |
| 2043 |
Duplicated 6a9343b8797a as upuzqpxs ad048f81 b1 |
| 2044 |
Rebased 1 commits onto duplicated commits. |
| 2045 |
[EOF] |
| 2046 |
"); |
| 2047 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 2048 |
@ 3e122d6a4b70 d2 |
| 2049 |
○ ae61a031221a d1 |
| 2050 |
│ ○ e5e35bfebdf4 c2 |
| 2051 |
│ ├─┬─╮ |
| 2052 |
│ │ │ ○ ad048f810d3c b1 |
| 2053 |
│ │ ○ │ 896deede3c03 a1 |
| 2054 |
│ │ ├─╯ |
| 2055 |
│ ○ │ 9b24b49f717e c1 |
| 2056 |
├─╯ │ |
| 2057 |
│ ○ │ 65b6f1fe6b41 b2 |
| 2058 |
│ ○ │ 6a9343b8797a b1 |
| 2059 |
├─╯ │ |
| 2060 |
│ ○ │ e9b68b6313be a4 |
| 2061 |
│ ├─╯ |
| 2062 |
│ ○ 5fb83d2b58d6 a3 |
| 2063 |
│ ○ 7bfd9fbe959c a2 |
| 2064 |
│ ○ 5d93a4b8f4bd a1 |
| 2065 |
├─╯ |
| 2066 |
◆ 000000000000 |
| 2067 |
[EOF] |
| 2068 |
"); |
| 2069 |
work_dir.run_jj(["op", "restore", &setup_opid]).success(); |
| 2070 |
|
| 2071 |
// Duplicate multiple commits without a direct ancestry relationship between |
| 2072 |
// commits without a direct relationship to the duplicated commits. |
| 2073 |
let output = work_dir.run_jj(["duplicate", "a1", "b1", "--after", "c1", "--before", "d2"]); |
| 2074 |
insta::assert_snapshot!(output, @r" |
| 2075 |
------- stderr ------- |
| 2076 |
Duplicated 5d93a4b8f4bd as muymlknp e3890eb5 a1 |
| 2077 |
Duplicated 6a9343b8797a as snrzyvry d3066453 b1 |
| 2078 |
Rebased 1 commits onto duplicated commits. |
| 2079 |
Working copy (@) now at: nmzmmopx 12e787a7 d2 | d2 |
| 2080 |
Parent commit (@-) : xznxytkn ae61a031 d1 | d1 |
| 2081 |
Parent commit (@-) : muymlknp e3890eb5 a1 |
| 2082 |
Parent commit (@-) : snrzyvry d3066453 b1 |
| 2083 |
Added 3 files, modified 0 files, removed 0 files |
| 2084 |
[EOF] |
| 2085 |
"); |
| 2086 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 2087 |
@ 12e787a7acb9 d2 |
| 2088 |
├─┬─╮ |
| 2089 |
│ │ ○ d30664539118 b1 |
| 2090 |
│ ○ │ e3890eb5520e a1 |
| 2091 |
│ ├─╯ |
| 2092 |
○ │ ae61a031221a d1 |
| 2093 |
│ │ ○ 47a79ab4bbc6 c2 |
| 2094 |
│ ├─╯ |
| 2095 |
│ ○ 9b24b49f717e c1 |
| 2096 |
├─╯ |
| 2097 |
│ ○ 65b6f1fe6b41 b2 |
| 2098 |
│ ○ 6a9343b8797a b1 |
| 2099 |
├─╯ |
| 2100 |
│ ○ e9b68b6313be a4 |
| 2101 |
│ ○ 5fb83d2b58d6 a3 |
| 2102 |
│ ○ 7bfd9fbe959c a2 |
| 2103 |
│ ○ 5d93a4b8f4bd a1 |
| 2104 |
├─╯ |
| 2105 |
◆ 000000000000 |
| 2106 |
[EOF] |
| 2107 |
"); |
| 2108 |
work_dir.run_jj(["op", "restore", &setup_opid]).success(); |
| 2109 |
|
| 2110 |
// Duplicate multiple commits with an ancestry relationship between |
| 2111 |
// commits without a direct relationship to the duplicated commits. |
| 2112 |
let output = work_dir.run_jj(["duplicate", "a1", "a3", "--after", "c1", "--before", "d2"]); |
| 2113 |
insta::assert_snapshot!(output, @r" |
| 2114 |
------- stderr ------- |
| 2115 |
Duplicated 5d93a4b8f4bd as vnqwxmpr 0a6ab30c a1 |
| 2116 |
Duplicated 5fb83d2b58d6 as pvqonzsn eb5c8329 a3 |
| 2117 |
Rebased 1 commits onto duplicated commits. |
| 2118 |
Working copy (@) now at: nmzmmopx e3fab709 d2 | d2 |
| 2119 |
Parent commit (@-) : xznxytkn ae61a031 d1 | d1 |
| 2120 |
Parent commit (@-) : pvqonzsn eb5c8329 a3 |
| 2121 |
Added 3 files, modified 0 files, removed 0 files |
| 2122 |
[EOF] |
| 2123 |
"); |
| 2124 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 2125 |
@ e3fab7093036 d2 |
| 2126 |
├─╮ |
| 2127 |
│ ○ eb5c832980d2 a3 |
| 2128 |
│ ○ 0a6ab30c6a03 a1 |
| 2129 |
○ │ ae61a031221a d1 |
| 2130 |
│ │ ○ 47a79ab4bbc6 c2 |
| 2131 |
│ ├─╯ |
| 2132 |
│ ○ 9b24b49f717e c1 |
| 2133 |
├─╯ |
| 2134 |
│ ○ 65b6f1fe6b41 b2 |
| 2135 |
│ ○ 6a9343b8797a b1 |
| 2136 |
├─╯ |
| 2137 |
│ ○ e9b68b6313be a4 |
| 2138 |
│ ○ 5fb83d2b58d6 a3 |
| 2139 |
│ ○ 7bfd9fbe959c a2 |
| 2140 |
│ ○ 5d93a4b8f4bd a1 |
| 2141 |
├─╯ |
| 2142 |
◆ 000000000000 |
| 2143 |
[EOF] |
| 2144 |
"); |
| 2145 |
work_dir.run_jj(["op", "restore", &setup_opid]).success(); |
| 2146 |
|
| 2147 |
// Duplicate multiple commits with an ancestry relationship between a commit |
| 2148 |
// which is an ancestor of one of the duplicated commits and a commit |
| 2149 |
// without a direct relationship. |
| 2150 |
let output = work_dir.run_jj(["duplicate", "a3", "a4", "--after", "a2", "--before", "c2"]); |
| 2151 |
insta::assert_snapshot!(output, @r" |
| 2152 |
------- stderr ------- |
| 2153 |
Duplicated 5fb83d2b58d6 as qtvkyytt 92720226 a3 |
| 2154 |
Duplicated e9b68b6313be as ouvslmur c565fb9e a4 |
| 2155 |
Rebased 1 commits onto duplicated commits. |
| 2156 |
[EOF] |
| 2157 |
"); |
| 2158 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 2159 |
@ 3e122d6a4b70 d2 |
| 2160 |
○ ae61a031221a d1 |
| 2161 |
│ ○ 45da82514fef c2 |
| 2162 |
│ ├─╮ |
| 2163 |
│ │ ○ c565fb9eec0b a4 |
| 2164 |
│ │ ○ 927202268f69 a3 |
| 2165 |
│ ○ │ 9b24b49f717e c1 |
| 2166 |
├─╯ │ |
| 2167 |
│ ○ │ 65b6f1fe6b41 b2 |
| 2168 |
│ ○ │ 6a9343b8797a b1 |
| 2169 |
├─╯ │ |
| 2170 |
│ ○ │ e9b68b6313be a4 |
| 2171 |
│ ○ │ 5fb83d2b58d6 a3 |
| 2172 |
│ ├─╯ |
| 2173 |
│ ○ 7bfd9fbe959c a2 |
| 2174 |
│ ○ 5d93a4b8f4bd a1 |
| 2175 |
├─╯ |
| 2176 |
◆ 000000000000 |
| 2177 |
[EOF] |
| 2178 |
"); |
| 2179 |
work_dir.run_jj(["op", "restore", &setup_opid]).success(); |
| 2180 |
|
| 2181 |
// Duplicate multiple commits with an ancestry relationship between a commit |
| 2182 |
// which is a a descendant of one of the duplicated commits and a commit |
| 2183 |
// with no direct relationship. |
| 2184 |
let output = work_dir.run_jj(["duplicate", "a1", "a2", "--before", "a3", "--after", "c2"]); |
| 2185 |
insta::assert_snapshot!(output, @r" |
| 2186 |
------- stderr ------- |
| 2187 |
Duplicated 5d93a4b8f4bd as qowqnpnw 0478473b a1 |
| 2188 |
Duplicated 7bfd9fbe959c as mommxqln fd58dece a2 |
| 2189 |
Rebased 2 commits onto duplicated commits. |
| 2190 |
[EOF] |
| 2191 |
"); |
| 2192 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 2193 |
@ 3e122d6a4b70 d2 |
| 2194 |
○ ae61a031221a d1 |
| 2195 |
│ ○ 58ed94dc9684 a4 |
| 2196 |
│ ○ 678cebe68e8a a3 |
| 2197 |
│ ├─╮ |
| 2198 |
│ │ ○ fd58dece7c4f a2 |
| 2199 |
│ │ ○ 0478473bfff3 a1 |
| 2200 |
│ │ ○ 47a79ab4bbc6 c2 |
| 2201 |
│ │ ○ 9b24b49f717e c1 |
| 2202 |
├───╯ |
| 2203 |
│ ○ 7bfd9fbe959c a2 |
| 2204 |
│ ○ 5d93a4b8f4bd a1 |
| 2205 |
├─╯ |
| 2206 |
│ ○ 65b6f1fe6b41 b2 |
| 2207 |
│ ○ 6a9343b8797a b1 |
| 2208 |
├─╯ |
| 2209 |
◆ 000000000000 |
| 2210 |
[EOF] |
| 2211 |
"); |
| 2212 |
work_dir.run_jj(["op", "restore", &setup_opid]).success(); |
| 2213 |
|
| 2214 |
// Duplicate multiple commits with an ancestry relationship between descendant |
| 2215 |
// commits. |
| 2216 |
let output = work_dir.run_jj(["duplicate", "a3", "a4", "--after", "a1", "--before", "a2"]); |
| 2217 |
insta::assert_snapshot!(output, @r" |
| 2218 |
------- stderr ------- |
| 2219 |
Warning: Duplicating commit e9b68b6313be as an ancestor of itself. |
| 2220 |
Warning: Duplicating commit 5fb83d2b58d6 as an ancestor of itself. |
| 2221 |
Duplicated 5fb83d2b58d6 as qzusktlu bfad21d4 a3 |
| 2222 |
Duplicated e9b68b6313be as zryotxso a83e9a5d a4 |
| 2223 |
Rebased 3 commits onto duplicated commits. |
| 2224 |
[EOF] |
| 2225 |
"); |
| 2226 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 2227 |
@ 3e122d6a4b70 d2 |
| 2228 |
○ ae61a031221a d1 |
| 2229 |
│ ○ 47a79ab4bbc6 c2 |
| 2230 |
│ ○ 9b24b49f717e c1 |
| 2231 |
├─╯ |
| 2232 |
│ ○ 65b6f1fe6b41 b2 |
| 2233 |
│ ○ 6a9343b8797a b1 |
| 2234 |
├─╯ |
| 2235 |
│ ○ b88510005789 a4 |
| 2236 |
│ ○ 55fd608caaf7 a3 |
| 2237 |
│ ○ d375a67f0929 a2 |
| 2238 |
│ ○ a83e9a5d4771 a4 |
| 2239 |
│ ○ bfad21d45a87 a3 |
| 2240 |
│ ○ 5d93a4b8f4bd a1 |
| 2241 |
├─╯ |
| 2242 |
◆ 000000000000 |
| 2243 |
[EOF] |
| 2244 |
"); |
| 2245 |
work_dir.run_jj(["op", "restore", &setup_opid]).success(); |
| 2246 |
|
| 2247 |
// Duplicate multiple commits with an ancestry relationship between ancestor |
| 2248 |
// commits. |
| 2249 |
let output = work_dir.run_jj(["duplicate", "a1", "a2", "--after", "a3", "--before", "a4"]); |
| 2250 |
insta::assert_snapshot!(output, @r" |
| 2251 |
------- stderr ------- |
| 2252 |
Warning: Duplicating commit 7bfd9fbe959c as a descendant of itself. |
| 2253 |
Warning: Duplicating commit 5d93a4b8f4bd as a descendant of itself. |
| 2254 |
Duplicated 5d93a4b8f4bd as stzvpxow 607f49d4 (empty) a1 |
| 2255 |
Duplicated 7bfd9fbe959c as zrzsnomp 802bec72 (empty) a2 |
| 2256 |
Rebased 1 commits onto duplicated commits. |
| 2257 |
[EOF] |
| 2258 |
"); |
| 2259 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 2260 |
@ 3e122d6a4b70 d2 |
| 2261 |
○ ae61a031221a d1 |
| 2262 |
│ ○ 47a79ab4bbc6 c2 |
| 2263 |
│ ○ 9b24b49f717e c1 |
| 2264 |
├─╯ |
| 2265 |
│ ○ 65b6f1fe6b41 b2 |
| 2266 |
│ ○ 6a9343b8797a b1 |
| 2267 |
├─╯ |
| 2268 |
│ ○ 5968d4b950df a4 |
| 2269 |
│ ○ 802bec723045 a2 |
| 2270 |
│ ○ 607f49d4e2dd a1 |
| 2271 |
│ ○ 5fb83d2b58d6 a3 |
| 2272 |
│ ○ 7bfd9fbe959c a2 |
| 2273 |
│ ○ 5d93a4b8f4bd a1 |
| 2274 |
├─╯ |
| 2275 |
◆ 000000000000 |
| 2276 |
[EOF] |
| 2277 |
"); |
| 2278 |
work_dir.run_jj(["op", "restore", &setup_opid]).success(); |
| 2279 |
|
| 2280 |
// Duplicate multiple commits with an ancestry relationship between an ancestor |
| 2281 |
// commit and a descendant commit. |
| 2282 |
let output = work_dir.run_jj(["duplicate", "a2", "a3", "--after", "a1", "--before", "a4"]); |
| 2283 |
insta::assert_snapshot!(output, @r" |
| 2284 |
------- stderr ------- |
| 2285 |
Duplicated 7bfd9fbe959c as ysllonyo b3b3e9e3 a2 |
| 2286 |
Duplicated 5fb83d2b58d6 as kzxwzvzw b5e1d0bf a3 |
| 2287 |
Rebased 1 commits onto duplicated commits. |
| 2288 |
[EOF] |
| 2289 |
"); |
| 2290 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 2291 |
@ 3e122d6a4b70 d2 |
| 2292 |
○ ae61a031221a d1 |
| 2293 |
│ ○ 47a79ab4bbc6 c2 |
| 2294 |
│ ○ 9b24b49f717e c1 |
| 2295 |
├─╯ |
| 2296 |
│ ○ 65b6f1fe6b41 b2 |
| 2297 |
│ ○ 6a9343b8797a b1 |
| 2298 |
├─╯ |
| 2299 |
│ ○ 90e48c697af8 a4 |
| 2300 |
│ ├─╮ |
| 2301 |
│ │ ○ b5e1d0bf2f7a a3 |
| 2302 |
│ │ ○ b3b3e9e342b9 a2 |
| 2303 |
│ ○ │ 5fb83d2b58d6 a3 |
| 2304 |
│ ○ │ 7bfd9fbe959c a2 |
| 2305 |
│ ├─╯ |
| 2306 |
│ ○ 5d93a4b8f4bd a1 |
| 2307 |
├─╯ |
| 2308 |
◆ 000000000000 |
| 2309 |
[EOF] |
| 2310 |
"); |
| 2311 |
work_dir.run_jj(["op", "restore", &setup_opid]).success(); |
| 2312 |
|
| 2313 |
// Should error if a loop will be created. |
| 2314 |
let output = work_dir.run_jj(["duplicate", "a1", "--after", "b2", "--before", "b1"]); |
| 2315 |
insta::assert_snapshot!(output, @" |
| 2316 |
------- stderr ------- |
| 2317 |
Error: Refusing to create a loop: commit 65b6f1fe6b41 would be both an ancestor and a descendant of the duplicated commits |
| 2318 |
[EOF] |
| 2319 |
[exit status: 1] |
| 2320 |
"); |
| 2321 |
} |
| 2322 |
|
| 2323 |
// https://github.com/jj-vcs/jj/issues/1050 |
| 2324 |
#[test] |
| 2325 |
fn test_undo_after_duplicate() { |
| 2326 |
let test_env = TestEnvironment::default(); |
| 2327 |
test_env.run_jj_in(".", ["git", "init", "repo"]).success(); |
| 2328 |
let work_dir = test_env.work_dir("repo"); |
| 2329 |
|
| 2330 |
create_commit(&work_dir, "a", &[]); |
| 2331 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 2332 |
@ 7d980be7a1d4 a |
| 2333 |
◆ 000000000000 |
| 2334 |
[EOF] |
| 2335 |
"); |
| 2336 |
|
| 2337 |
// exercise --quiet while here |
| 2338 |
let output = work_dir.run_jj(["duplicate", "a", "--quiet"]); |
| 2339 |
insta::assert_snapshot!(output, @""); |
| 2340 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 2341 |
@ 7d980be7a1d4 a |
| 2342 |
│ ○ 346a7abed73c a |
| 2343 |
├─╯ |
| 2344 |
◆ 000000000000 |
| 2345 |
[EOF] |
| 2346 |
"); |
| 2347 |
|
| 2348 |
let output = work_dir.run_jj(["undo"]); |
| 2349 |
insta::assert_snapshot!(output, @" |
| 2350 |
------- stderr ------- |
| 2351 |
Undid operation: 034b58b0d7cb (2001-02-03 08:05:11) duplicate 1 commit(s) |
| 2352 |
Restored to operation: 6edf1ea72afe (2001-02-03 08:05:09) create bookmark a pointing to commit 7d980be7a1d499e4d316ab4c01242885032f7eaf |
| 2353 |
[EOF] |
| 2354 |
"); |
| 2355 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 2356 |
@ 7d980be7a1d4 a |
| 2357 |
◆ 000000000000 |
| 2358 |
[EOF] |
| 2359 |
"); |
| 2360 |
} |
| 2361 |
|
| 2362 |
// https://github.com/jj-vcs/jj/issues/694 |
| 2363 |
#[test] |
| 2364 |
fn test_rebase_duplicates() { |
| 2365 |
let test_env = TestEnvironment::default(); |
| 2366 |
test_env.run_jj_in(".", ["git", "init", "repo"]).success(); |
| 2367 |
let work_dir = test_env.work_dir("repo"); |
| 2368 |
|
| 2369 |
create_commit(&work_dir, "a", &[]); |
| 2370 |
create_commit(&work_dir, "b", &["a"]); |
| 2371 |
create_commit(&work_dir, "c", &["b"]); |
| 2372 |
// Test the setup |
| 2373 |
insta::assert_snapshot!(get_log_output_with_ts(&work_dir), @" |
| 2374 |
@ dffaa0d4dacc c @ 2001-02-03 04:05:13.000 +07:00 |
| 2375 |
○ 123b4d91f6e5 b @ 2001-02-03 04:05:11.000 +07:00 |
| 2376 |
○ 7d980be7a1d4 a @ 2001-02-03 04:05:09.000 +07:00 |
| 2377 |
◆ 000000000000 @ 1970-01-01 00:00:00.000 +00:00 |
| 2378 |
[EOF] |
| 2379 |
"); |
| 2380 |
|
| 2381 |
let output = work_dir.run_jj(["duplicate", "c"]); |
| 2382 |
insta::assert_snapshot!(output, @" |
| 2383 |
------- stderr ------- |
| 2384 |
Duplicated dffaa0d4dacc as yostqsxw fc2e8dc2 c |
| 2385 |
[EOF] |
| 2386 |
"); |
| 2387 |
let output = work_dir.run_jj(["duplicate", "c"]); |
| 2388 |
insta::assert_snapshot!(output, @" |
| 2389 |
------- stderr ------- |
| 2390 |
Duplicated dffaa0d4dacc as znkkpsqq 14e2803a c |
| 2391 |
[EOF] |
| 2392 |
"); |
| 2393 |
insta::assert_snapshot!(get_log_output_with_ts(&work_dir), @" |
| 2394 |
@ dffaa0d4dacc c @ 2001-02-03 04:05:13.000 +07:00 |
| 2395 |
│ ○ 14e2803a4b0e c @ 2001-02-03 04:05:16.000 +07:00 |
| 2396 |
├─╯ |
| 2397 |
│ ○ fc2e8dc218ab c @ 2001-02-03 04:05:15.000 +07:00 |
| 2398 |
├─╯ |
| 2399 |
○ 123b4d91f6e5 b @ 2001-02-03 04:05:11.000 +07:00 |
| 2400 |
○ 7d980be7a1d4 a @ 2001-02-03 04:05:09.000 +07:00 |
| 2401 |
◆ 000000000000 @ 1970-01-01 00:00:00.000 +00:00 |
| 2402 |
[EOF] |
| 2403 |
"); |
| 2404 |
|
| 2405 |
let output = work_dir.run_jj(["rebase", "-s", "b", "-o", "root()"]); |
| 2406 |
insta::assert_snapshot!(output, @r" |
| 2407 |
------- stderr ------- |
| 2408 |
Rebased 4 commits to destination. |
| 2409 |
Working copy (@) now at: royxmykx fa60711d c | c |
| 2410 |
Parent commit (@-) : zsuskuln 594e9d32 b | b |
| 2411 |
Added 0 files, modified 0 files, removed 1 files |
| 2412 |
[EOF] |
| 2413 |
"); |
| 2414 |
// Some of the duplicate commits' timestamps were changed a little to make them |
| 2415 |
// have distinct commit ids. |
| 2416 |
insta::assert_snapshot!(get_log_output_with_ts(&work_dir), @" |
| 2417 |
@ fa60711d6bd1 c @ 2001-02-03 04:05:18.000 +07:00 |
| 2418 |
│ ○ e320e3d23be0 c @ 2001-02-03 04:05:18.000 +07:00 |
| 2419 |
├─╯ |
| 2420 |
│ ○ f9c10a3b2cfd c @ 2001-02-03 04:05:18.000 +07:00 |
| 2421 |
├─╯ |
| 2422 |
○ 594e9d322230 b @ 2001-02-03 04:05:18.000 +07:00 |
| 2423 |
│ ○ 7d980be7a1d4 a @ 2001-02-03 04:05:09.000 +07:00 |
| 2424 |
├─╯ |
| 2425 |
◆ 000000000000 @ 1970-01-01 00:00:00.000 +00:00 |
| 2426 |
[EOF] |
| 2427 |
"); |
| 2428 |
} |
| 2429 |
|
| 2430 |
#[test] |
| 2431 |
fn test_duplicate_description_template() { |
| 2432 |
let test_env = TestEnvironment::default(); |
| 2433 |
test_env.run_jj_in(".", ["git", "init", "repo"]).success(); |
| 2434 |
let work_dir = test_env.work_dir("repo"); |
| 2435 |
|
| 2436 |
create_commit(&work_dir, "a", &[]); |
| 2437 |
create_commit(&work_dir, "b", &["a"]); |
| 2438 |
create_commit(&work_dir, "c", &["b"]); |
| 2439 |
|
| 2440 |
// Test the setup |
| 2441 |
insta::assert_snapshot!(get_log_output(&work_dir), @" |
| 2442 |
@ dffaa0d4dacc c |
| 2443 |
○ 123b4d91f6e5 b |
| 2444 |
○ 7d980be7a1d4 a |
| 2445 |
◆ 000000000000 |
| 2446 |
[EOF] |
| 2447 |
"); |
| 2448 |
|
| 2449 |
// Test duplicate_commits() |
| 2450 |
test_env.add_config(r#"templates.duplicate_description = "concat(description, '\n(cherry picked from commit ', commit_id, ')')""#); |
| 2451 |
let output = work_dir.run_jj(["duplicate", "a"]); |
| 2452 |
insta::assert_snapshot!(output, @" |
| 2453 |
------- stderr ------- |
| 2454 |
Duplicated 7d980be7a1d4 as yostqsxw f73017d9 a |
| 2455 |
[EOF] |
| 2456 |
"); |
| 2457 |
|
| 2458 |
// Test duplicate_commits_onto_parents() |
| 2459 |
let output = work_dir.run_jj(["duplicate", "a", "-B", "b"]); |
| 2460 |
insta::assert_snapshot!(output, @r" |
| 2461 |
------- stderr ------- |
| 2462 |
Warning: Duplicating commit 7d980be7a1d4 as a descendant of itself. |
| 2463 |
Duplicated 7d980be7a1d4 as znkkpsqq fdd77a5e (empty) a |
| 2464 |
Rebased 2 commits onto duplicated commits. |
| 2465 |
Working copy (@) now at: royxmykx 5679a60a c | c |
| 2466 |
Parent commit (@-) : zsuskuln cb58e31e b | b |
| 2467 |
[EOF] |
| 2468 |
"); |
| 2469 |
|
| 2470 |
// Test empty template |
| 2471 |
test_env.add_config("templates.duplicate_description = ''"); |
| 2472 |
let output = work_dir.run_jj(["duplicate", "b", "-o", "root()"]); |
| 2473 |
insta::assert_snapshot!(output, @" |
| 2474 |
------- stderr ------- |
| 2475 |
Duplicated cb58e31ed5d4 as kpqxywon 33044659 (no description set) |
| 2476 |
[EOF] |
| 2477 |
"); |
| 2478 |
|
| 2479 |
// Test `description` as an alias |
| 2480 |
test_env.add_config("templates.duplicate_description = 'description'"); |
| 2481 |
let output = work_dir.run_jj([ |
| 2482 |
"duplicate", |
| 2483 |
"c", |
| 2484 |
"-o", |
| 2485 |
"root()", |
| 2486 |
// Use an argument here so we can actually see the log in the last test |
| 2487 |
// (We don't have a way to remove a config in TestEnvironment) |
| 2488 |
"--config", |
| 2489 |
"template-aliases.description='\"alias\"'", |
| 2490 |
]); |
| 2491 |
insta::assert_snapshot!(output, @" |
| 2492 |
------- stderr ------- |
| 2493 |
Duplicated 5679a60ab86b as kmkuslsw e36bebd2 alias |
| 2494 |
[EOF] |
| 2495 |
"); |
| 2496 |
|
| 2497 |
let template = r#"commit_id.short() ++ "\n" ++ description ++ "[END]\n""#; |
| 2498 |
let output = work_dir.run_jj(["log", "-T", template]); |
| 2499 |
insta::assert_snapshot!(output, @" |
| 2500 |
@ 5679a60ab86b |
| 2501 |
│ c |
| 2502 |
│ [END] |
| 2503 |
○ cb58e31ed5d4 |
| 2504 |
│ b |
| 2505 |
│ [END] |
| 2506 |
○ fdd77a5e11d5 |
| 2507 |
│ a |
| 2508 |
│ |
| 2509 |
│ (cherry picked from commit 7d980be7a1d499e4d316ab4c01242885032f7eaf) |
| 2510 |
│ [END] |
| 2511 |
○ 7d980be7a1d4 |
| 2512 |
│ a |
| 2513 |
│ [END] |
| 2514 |
│ ○ e36bebd28ab6 |
| 2515 |
├─╯ alias |
| 2516 |
│ [END] |
| 2517 |
│ ○ 33044659b895 |
| 2518 |
├─╯ [END] |
| 2519 |
│ ○ f73017d958e7 |
| 2520 |
├─╯ a |
| 2521 |
│ |
| 2522 |
│ (cherry picked from commit 7d980be7a1d499e4d316ab4c01242885032f7eaf) |
| 2523 |
│ [END] |
| 2524 |
◆ 000000000000 |
| 2525 |
[END] |
| 2526 |
[EOF] |
| 2527 |
"); |
| 2528 |
} |
| 2529 |
|
| 2530 |
#[must_use] |
| 2531 |
fn get_log_output(work_dir: &TestWorkDir) -> CommandOutput { |
| 2532 |
let template = r#"commit_id.short() ++ " " ++ description.first_line()"#; |
| 2533 |
work_dir.run_jj(["log", "-T", template]) |
| 2534 |
} |
| 2535 |
|
| 2536 |
#[must_use] |
| 2537 |
fn get_log_output_with_ts(work_dir: &TestWorkDir) -> CommandOutput { |
| 2538 |
let template = r#" |
| 2539 |
commit_id.short() ++ " " ++ description.first_line() ++ " @ " ++ committer.timestamp() |
| 2540 |
"#; |
| 2541 |
work_dir.run_jj(["log", "-T", template]) |
| 2542 |
} |