comparison tests/test-rewind.t @ 5830:67fc03f42d92 mercurial-5.0

test-compat: merge mercurial-5.1 into mercurial-5.0 # no-check-commit
author Anton Shestakov <av6@dwimlabs.net>
date Thu, 11 Mar 2021 14:22:45 +0800
parents c2c85576ddfb fd039a7f0c3c
children be8f7eb3f3a0
comparison
equal deleted inserted replaced
5763:c2c85576ddfb 5830:67fc03f42d92
6 $ cat >> $HGRCPATH << EOF 6 $ cat >> $HGRCPATH << EOF
7 > [phases] 7 > [phases]
8 > publish = false 8 > publish = false
9 > [alias] 9 > [alias]
10 > glf = log -GT "{rev}: {desc} ({files})" 10 > glf = log -GT "{rev}: {desc} ({files})"
11 > glhf = log -GT "{rev}:{node|short} {desc} ({files})"
11 > [extensions] 12 > [extensions]
12 > evolve = 13 > evolve =
13 > EOF 14 > EOF
14 15
15 $ hg init rewind-testing-base 16 $ hg init rewind-testing-base
661 662
662 $ hg rewind --to '9576e80d6851+a0316c4c5417' --hidden --dry-run 663 $ hg rewind --to '9576e80d6851+a0316c4c5417' --hidden --dry-run
663 rewinding 4535d0af405c to 2 changesets: a0316c4c5417 9576e80d6851 664 rewinding 4535d0af405c to 2 changesets: a0316c4c5417 9576e80d6851
664 $ hg rewind --to '9576e80d6851' --hidden --dry-run 665 $ hg rewind --to '9576e80d6851' --hidden --dry-run
665 rewinding 4535d0af405c to 2 changesets: a0316c4c5417 9576e80d6851 666 rewinding 4535d0af405c to 2 changesets: a0316c4c5417 9576e80d6851
666
667 XXX this should also give us 2 changesets
668
669 $ hg rewind --to 'a0316c4c5417' --hidden --dry-run 667 $ hg rewind --to 'a0316c4c5417' --hidden --dry-run
670 rewinding 4535d0af405c to 1 changesets: a0316c4c5417 668 rewinding 4535d0af405c to 2 changesets: a0316c4c5417 9576e80d6851
671 669
672 $ hg rewind --to '9576e80d6851' --exact --hidden --dry-run 670 $ hg rewind --to '9576e80d6851' --exact --hidden --dry-run
673 rewinding 4535d0af405c to 1 changesets: 9576e80d6851 671 rewinding 4535d0af405c to 2 changesets: a0316c4c5417 9576e80d6851
674 $ hg rewind --to 'a0316c4c5417' --exact --hidden --dry-run 672 $ hg rewind --to 'a0316c4c5417' --exact --hidden --dry-run
675 rewinding 4535d0af405c to 1 changesets: a0316c4c5417 673 rewinding 4535d0af405c to 2 changesets: a0316c4c5417 9576e80d6851
676 674
677 actual rewind 675 actual rewind
678 676
679 $ hg rewind --to '9576e80d6851+a0316c4c5417' --hidden 677 $ hg rewind --to '9576e80d6851+a0316c4c5417' --hidden
680 rewound to 2 changesets 678 rewound to 2 changesets
863 o changeset: 0:eba9c2249fe7 861 o changeset: 0:eba9c2249fe7
864 user: test 862 user: test
865 date: Thu Jan 01 00:00:00 1970 +0000 863 date: Thu Jan 01 00:00:00 1970 +0000
866 summary: c_ROOT 864 summary: c_ROOT
867 865
866
867 $ hg rewind --hidden --to 'allpredecessors(desc("c_B0"))' --dry-run
868 abort: not rewinding, a65fceb2324a is a successor of 7e594302a05d
869 (pick only one of these changesets, possibly with --exact)
870 [255]
871 $ hg rewind --hidden --to 'allpredecessors(desc("c_B0"))' --dry-run --exact
872 abort: not rewinding, a65fceb2324a is a successor of 7e594302a05d
873 (pick only one of these changesets, possibly with --exact)
874 [255]
875 $ hg rewind --hidden --to 'allpredecessors(desc("c_B0"))' --dry-run --as-divergence
876 abort: not rewinding, a65fceb2324a is a successor of 7e594302a05d
877 (pick only one of these changesets, possibly with --exact)
878 [255]
868 879
869 Testing the defaults 880 Testing the defaults
870 -------------------- 881 --------------------
871 882
872 rewind with no arguments should be equivalent to `--from .` 883 rewind with no arguments should be equivalent to `--from .`
1193 XXX: Unfortunately, even with --keep it's not allowed 1204 XXX: Unfortunately, even with --keep it's not allowed
1194 1205
1195 $ hg rewind --keep --to 'desc("amended")' --hidden 1206 $ hg rewind --keep --to 'desc("amended")' --hidden
1196 abort: uncommitted changes 1207 abort: uncommitted changes
1197 [255] 1208 [255]
1209
1210 $ cd ..
1211
1212 Extra cases related to folds
1213 ============================
1214
1215 folding with a changeset created after the rewind target
1216 --------------------------------------------------------
1217
1218 .. B0 ⇠\
1219 .. | ⇠ AB2
1220 .. A0 ⇠ A1 ⇠/
1221
1222 this simple test case introduces the idea of making rewind consider different
1223 evolutions of fold components: "parent" evolution of A has more predecessors
1224
1225 $ hg init extra-fold-case-1
1226 $ cd extra-fold-case-1
1227
1228 $ echo R > R
1229 $ hg ci -qAm R
1230 $ echo A > A
1231 $ hg ci -qAm A0
1232 $ hg amend -m A1
1233 $ echo B > B
1234 $ hg ci -qAm B0
1235 $ hg fold -r 'desc("A1")::' -m AB2 --exact -q
1236
1237 $ hg glhf --hidden
1238 @ 4:7f9a5314ef94 AB2 (A B)
1239 |
1240 | x 3:16429ed4b6cb B0 (B)
1241 | |
1242 | x 2:3748b241cad8 A1 (A)
1243 |/
1244 | x 1:fa8956746c52 A0 (A)
1245 |/
1246 o 0:167e04d3d1b2 R (R)
1247
1248
1249 target selection
1250
1251 when rewinding from a fold, rewind to all of its components (at various points
1252 in their evolution) to not lose work
1253
1254 $ hg rewind --hidden --to 'desc("A0")' --dry-run
1255 rewinding 7f9a5314ef94 to 2 changesets: fa8956746c52 16429ed4b6cb
1256 $ hg rewind --hidden --to 'desc("B0")' --dry-run
1257 rewinding 7f9a5314ef94 to 2 changesets: 3748b241cad8 16429ed4b6cb
1258 $ hg rewind --from 'desc("AB2")' --dry-run
1259 rewinding 7f9a5314ef94 to 2 changesets: 3748b241cad8 16429ed4b6cb
1260
1261 $ hg rewind --hidden --to 'allpredecessors(desc("AB2"))' --dry-run
1262 abort: not rewinding, 3748b241cad8 is a successor of fa8956746c52
1263 (pick only one of these changesets, possibly with --exact)
1264 [255]
1265
1266 $ cd ..
1267
1268 folding with a changeset we rebased onto
1269 ----------------------------------------
1270
1271 .. A0 ⇠ A1 ⇠\
1272 .. | ⇠ AB2
1273 .. B0 ⇠/
1274
1275 similar to the previous case, but this time evolution of A has more
1276 predecessors and at some point starts to be based on B
1277
1278 $ hg init extra-fold-case-2
1279 $ cd extra-fold-case-2
1280
1281 $ echo R > R
1282 $ hg ci -qAm R
1283 $ echo A > A
1284 $ hg ci -qAm A0
1285 $ hg up 'desc("R")' -q
1286 $ echo B > B
1287 $ hg ci -qAm B0
1288 $ echo A > A
1289 $ hg ci -qAm A1
1290 $ hg prune -r 'desc("A0")' -s 'desc("A1")'
1291 1 changesets pruned
1292
1293 $ hg fold -r 'desc("B0")::' -m AB2 --exact -q
1294
1295 $ hg glhf --hidden
1296 @ 4:1988e9fe9517 AB2 (A B)
1297 |
1298 | x 3:7175ff74409b A1 (A)
1299 | |
1300 | x 2:d6ed1d624918 B0 (B)
1301 |/
1302 | x 1:fa8956746c52 A0 (A)
1303 |/
1304 o 0:167e04d3d1b2 R (R)
1305
1306
1307 target selection
1308
1309 when rewinding from a fold, rewind to all of its components (at various points
1310 in their evolution) to not lose work
1311
1312 $ hg rewind --hidden --to 'desc("A0")' --dry-run
1313 rewinding 1988e9fe9517 to 2 changesets: fa8956746c52 d6ed1d624918
1314 $ hg rewind --hidden --to 'desc("B0")' --dry-run
1315 rewinding 1988e9fe9517 to 2 changesets: d6ed1d624918 7175ff74409b
1316 $ hg rewind --from 'desc("AB2")' --dry-run
1317 rewinding 1988e9fe9517 to 2 changesets: d6ed1d624918 7175ff74409b
1318
1319 $ cd ..
1320
1321 folding with a changeset that rebased on us
1322 -------------------------------------------
1323
1324 .. B0 ⇠⇠⇠⇠ B1 ⇠\
1325 .. | | ⇠ AB2
1326 .. | A0 ⇠ A1 ⇠/
1327
1328 now evolutions of A and B have the same amount of changesets, but at point 0
1329 they aren't yet related
1330
1331 $ hg init extra-fold-case-3
1332 $ cd extra-fold-case-3
1333
1334 $ echo R > R
1335 $ hg ci -qAm R
1336 $ echo A > A
1337 $ hg ci -qAm A0
1338 $ hg amend -m A1
1339 $ hg up 'desc("R")' -q
1340 $ echo B > B
1341 $ hg ci -qAm B0
1342 $ hg up 'desc("A1")' -q
1343 $ echo B > B
1344 $ hg ci -qAm B1
1345 $ hg prune -r 'desc("B0")' -s 'desc("B1")'
1346 1 changesets pruned
1347
1348 $ hg fold -r 'desc("A1")::' -m AB2 --exact -q
1349
1350 $ hg glhf --hidden
1351 @ 5:7f9a5314ef94 AB2 (A B)
1352 |
1353 | x 4:fe7a7d317e16 B1 (B)
1354 | |
1355 +---x 3:d6ed1d624918 B0 (B)
1356 | |
1357 | x 2:3748b241cad8 A1 (A)
1358 |/
1359 | x 1:fa8956746c52 A0 (A)
1360 |/
1361 o 0:167e04d3d1b2 R (R)
1362
1363
1364 target selection
1365
1366 $ hg rewind --hidden --to 'desc("A0")' --dry-run
1367 rewinding 7f9a5314ef94 to 2 changesets: fa8956746c52 fe7a7d317e16
1368 $ hg rewind --hidden --to 'desc("B0")' --dry-run
1369 rewinding 7f9a5314ef94 to 2 changesets: 3748b241cad8 d6ed1d624918
1370 $ hg rewind --hidden --to 'desc("A1")' --dry-run
1371 rewinding 7f9a5314ef94 to 2 changesets: 3748b241cad8 fe7a7d317e16
1372 $ hg rewind --hidden --to 'desc("B1")' --dry-run
1373 rewinding 7f9a5314ef94 to 2 changesets: 3748b241cad8 fe7a7d317e16
1374 $ hg rewind --from 'desc("AB2")' --dry-run
1375 rewinding 7f9a5314ef94 to 2 changesets: 3748b241cad8 fe7a7d317e16
1376
1377 actual rewind
1378
1379 $ hg rewind --hidden --to 'desc("A0")'
1380 1 new orphan changesets
1381 rewound to 2 changesets
1382 (1 changesets obsoleted)
1383 working directory is now at e492d2f9be46
1384
1385 after rewind to A0:
1386 - A0' and B1' are successors to AB2 (split using rewind)
1387 - A0' is a successor of A0 (operation: rewind)
1388 - A0' is a child of R (just like A0)
1389 - B1' is a successor of B1 (operation: rewind)
1390 - B1' is a child of A1 (just like B1), and therefore an orphan
1391
1392 $ hg obslog -a
1393 o 54b340ce1d87 (6) A0
1394 |\ split(description, meta, parent, content) from 7f9a5314ef94 using rewind by test (Thu Jan 01 00:00:06 1970 +0000)
1395 | | meta-changed(meta) from fa8956746c52 using rewind by test (Thu Jan 01 00:00:06 1970 +0000)
1396 | |
1397 +---@ e492d2f9be46 (7) B1
1398 | | | split(description, meta, parent, content) from 7f9a5314ef94 using rewind by test (Thu Jan 01 00:00:06 1970 +0000)
1399 | | | meta-changed(meta) from fe7a7d317e16 using rewind by test (Thu Jan 01 00:00:06 1970 +0000)
1400 | | |
1401 x---+ 7f9a5314ef94 (5) AB2
1402 | | | folded(description, parent, content) from 3748b241cad8, fe7a7d317e16 using fold by test (Thu Jan 01 00:00:06 1970 +0000)
1403 | | |
1404 x | | 3748b241cad8 (2) A1
1405 |/ / reworded(description) from fa8956746c52 using amend by test (Thu Jan 01 00:00:06 1970 +0000)
1406 | |
1407 | x fe7a7d317e16 (4) B1
1408 | | rewritten(description, parent) from d6ed1d624918 using prune by test (Thu Jan 01 00:00:06 1970 +0000)
1409 | |
1410 | x d6ed1d624918 (3) B0
1411 |
1412 x fa8956746c52 (1) A0
1413
1414 $ hg glhf
1415 @ 7:e492d2f9be46 B1 (B)
1416 |
1417 | o 6:54b340ce1d87 A0 (A)
1418 | |
1419 x | 2:3748b241cad8 A1 (A)
1420 |/
1421 o 0:167e04d3d1b2 R (R)
1422
1423
1424 $ hg debugobsolete --exclusive -r 'first(head())'
1425 7f9a5314ef94f5856ee90661268194cc5ce9b332 54b340ce1d87f3593fd9de2a742e7b444e5136ed e492d2f9be46b73c0cfa51709e92db864b8f3ed9 0 (Thu Jan 01 00:00:06 1970 +0000) {'ef1': '15', 'operation': 'rewind', 'user': 'test'}
1426 fa8956746c5294ce3351309133b450c5930f30f5 54b340ce1d87f3593fd9de2a742e7b444e5136ed 4 (Thu Jan 01 00:00:06 1970 +0000) {'ef1': '2', 'operation': 'rewind', 'user': 'test'}
1427 $ hg debugobsolete --exclusive -r 'last(head())'
1428 7f9a5314ef94f5856ee90661268194cc5ce9b332 54b340ce1d87f3593fd9de2a742e7b444e5136ed e492d2f9be46b73c0cfa51709e92db864b8f3ed9 0 (Thu Jan 01 00:00:06 1970 +0000) {'ef1': '15', 'operation': 'rewind', 'user': 'test'}
1429 fe7a7d317e168a15e8aa43131b54d3256443d728 e492d2f9be46b73c0cfa51709e92db864b8f3ed9 4 (Thu Jan 01 00:00:06 1970 +0000) {'ef1': '2', 'operation': 'rewind', 'user': 'test'}
1430
1431 $ cd ..
1432
1433 simple fold with a missing part
1434 -------------------------------
1435
1436 .. B0 ⇠ (B1) ⇠\
1437 .. | | ⇠ AB2
1438 .. A0 ⇠ A1 ⇠/
1439
1440 a stack was rewritten, but then a part of it became unknown locally
1441
1442 $ hg init extra-fold-case-4
1443 $ cd extra-fold-case-4
1444
1445 $ echo R > R
1446 $ hg ci -qAm R
1447 $ echo A > A
1448 $ hg ci -qAm A0
1449 $ echo B > B
1450 $ hg ci -qAm B0
1451 $ hg up 'desc("R")' -q
1452 $ echo A > A
1453 $ hg ci -qAm A1
1454 $ echo B > B
1455 $ hg ci -qAm B1
1456 $ hg prune -r 'desc("A0")+desc("B0")' -s 'desc("A1")+desc("B1")' --biject
1457 2 changesets pruned
1458
1459 $ hg fold -r 'desc("A1") + desc("B1")' -m AB2 --exact -q
1460
1461 $ hg glhf --hidden
1462 @ 5:1988e9fe9517 AB2 (A B)
1463 |
1464 | x 4:25210d726f52 B1 (B)
1465 | |
1466 | x 3:9c76368ab336 A1 (A)
1467 |/
1468 | x 2:a07c12c45197 B0 (B)
1469 | |
1470 | x 1:fa8956746c52 A0 (A)
1471 |/
1472 o 0:167e04d3d1b2 R (R)
1473
1474
1475 target selection
1476
1477 $ hg rewind --hidden --to 'desc("A0")' --dry-run
1478 rewinding 1988e9fe9517 to 2 changesets: fa8956746c52 25210d726f52
1479 $ hg rewind --hidden --to 'desc("A1")' --dry-run
1480 rewinding 1988e9fe9517 to 2 changesets: 9c76368ab336 25210d726f52
1481 $ hg rewind --hidden --to 'desc("B1")' --dry-run
1482 rewinding 1988e9fe9517 to 2 changesets: 9c76368ab336 25210d726f52
1483
1484 because B0 is a child of A0, we use A0 instead of A1 unless --exact is given
1485
1486 XXX the semantic of --exact might need clarification here,
1487 XXX for example, shouln't --exact make sure we only rewind to the `--to` target ?
1488
1489 $ hg rewind --hidden --to 'desc("B0")' --dry-run
1490 rewinding 1988e9fe9517 to 2 changesets: fa8956746c52 a07c12c45197
1491 $ hg rewind --hidden --to 'desc("B0")' --exact --dry-run
1492 rewinding 1988e9fe9517 to 2 changesets: a07c12c45197 9c76368ab336
1493
1494 stripping one of the fold parts
1495
1496 $ hg strip --config extensions.strip= -r 'desc("B1")' --hidden -q
1497
1498 $ hg glhf --hidden
1499 @ 4:1988e9fe9517 AB2 (A B)
1500 |
1501 | x 3:9c76368ab336 A1 (A)
1502 |/
1503 | x 2:a07c12c45197 B0 (B)
1504 | |
1505 | x 1:fa8956746c52 A0 (A)
1506 |/
1507 o 0:167e04d3d1b2 R (R)
1508
1509
1510 target selection
1511
1512 the obvious challenge here is to somehow work around the missing fold
1513 component, but we can't do much because it is one of the latest predecessors of
1514 AB2 fold
1515
1516 in future we might have a way to allow rewind to skip changesets unknown
1517 locally and still proceed (and lose the least amount of work possible)
1518
1519 $ hg rewind --hidden --to 'desc("A0")+desc("B0")' --exact --dry-run
1520 rewinding 1988e9fe9517 to 2 changesets: fa8956746c52 a07c12c45197
1521 $ hg rewind --hidden --to 'desc("A0")' --dry-run
1522 abort: not rewinding, some predecessors are unknown locally: 25210d726f52
1523 (try selecting all changesets to rewind to manually, possibly with --exact)
1524 [255]
1525 $ hg rewind --hidden --to 'desc("A1")' --dry-run
1526 abort: not rewinding, some predecessors are unknown locally: 25210d726f52
1527 (try selecting all changesets to rewind to manually, possibly with --exact)
1528 [255]
1529
1530 XXX the semantic of --exact might need clarification here,
1531 XXX for example, shouln't --exact make sure we only rewind to the `--to` target ?
1532
1533 $ hg rewind --hidden --to 'desc("A1")' --exact --dry-run
1534 abort: not rewinding, some predecessors are unknown locally: 25210d726f52
1535 (try selecting all changesets to rewind to manually, possibly with --exact)
1536 [255]
1537 $ hg rewind --from 'desc("AB2")' --dry-run
1538 abort: not rewinding, some predecessors are unknown locally: 25210d726f52
1539 (try selecting all changesets to rewind to manually, possibly with --exact)
1540 [255]
1541 $ hg rewind --from 'desc("AB2")' --exact --dry-run
1542 abort: not rewinding, some predecessors are unknown locally: 25210d726f52
1543 (try selecting all changesets to rewind to manually, possibly with --exact)
1544 [255]
1545
1546 $ cd ..
1547
1548 split and then fold with a missing part
1549 ---------------------------------------
1550
1551 .. /⇠ (C1) ⇠\
1552 .. BC0 ⇠ | \
1553 .. | \⇠ B1 ⇠ AC2
1554 .. A0 ⇠⇠⇠⇠⇠⇠⇠⇠⇠⇠⇠/
1555
1556 here we have a case when walking successors and then predecessors of target
1557 revisions just once might not be enough, because it's a more complex DAG with a
1558 changeset missing from local repo
1559
1560 $ hg init extra-fold-case-5
1561 $ cd extra-fold-case-5
1562
1563 $ echo R > R
1564 $ hg ci -qAm R
1565 $ echo A > A
1566 $ hg ci -qAm A0
1567 $ echo B > B
1568 $ echo C > C
1569 $ hg ci -qAm BC0
1570 $ hg up 'desc("A0")' -q
1571 $ echo B > B
1572 $ hg ci -qAm B1
1573 $ echo C > C
1574 $ hg ci -qAm C1
1575
1576 $ hg prune -r 'desc("BC0")' -s 'desc("B1")+desc("C1")' --split
1577 1 changesets pruned
1578
1579 $ hg up 'desc("R")' -q
1580 $ echo A > A
1581 $ echo C > C
1582 $ hg ci -qAm AC2
1583
1584 $ hg prune -r 'desc("A0")+desc("C1")' -s 'desc("AC2")' --fold
1585 2 changesets pruned
1586 1 new orphan changesets
1587
1588 $ hg glhf --hidden
1589 @ 5:9ccaac2e5fbb AC2 (A C)
1590 |
1591 | x 4:2e4ab803d8ae C1 (C)
1592 | |
1593 | * 3:44774eafdc1c B1 (B)
1594 | |
1595 | | x 2:883d75400657 BC0 (B C)
1596 | |/
1597 | x 1:fa8956746c52 A0 (A)
1598 |/
1599 o 0:167e04d3d1b2 R (R)
1600
1601
1602 target selection
1603
1604 $ hg rewind --hidden --to 'desc("A0")' --dry-run
1605 rewinding 9ccaac2e5fbb to 2 changesets: fa8956746c52 2e4ab803d8ae
1606 $ hg rewind --hidden --to 'desc("BC0")' --dry-run
1607 rewinding 44774eafdc1c to 1 changesets: 883d75400657
1608 rewinding 9ccaac2e5fbb to 2 changesets: fa8956746c52 883d75400657
1609 $ hg rewind --from 'desc("AC2")' --dry-run
1610 rewinding 9ccaac2e5fbb to 2 changesets: fa8956746c52 2e4ab803d8ae
1611
1612 stripping a component of AC2 fold
1613
1614 $ hg strip --config extensions.strip= --hidden -r 'desc("C1")' -q
1615 warning: ignoring unknown working parent 9ccaac2e5fbb!
1616
1617 target selection
1618
1619 at the moment, there's not much that we can do here because of missing C1
1620
1621 in future we might have a way to allow rewind to skip changesets unknown
1622 locally and still proceed (and lose the least amount of work possible)
1623
1624 XXX the semantic of --exact might need clarification here,
1625 XXX for example, shouln't --exact make sure we only rewind to the `--to` target ?
1626
1627 $ hg rewind --hidden --to 'desc("A0")' --dry-run
1628 abort: not rewinding, some predecessors are unknown locally: 2e4ab803d8ae
1629 (try selecting all changesets to rewind to manually, possibly with --exact)
1630 [255]
1631 $ hg rewind --hidden --to 'desc("BC0")' --dry-run
1632 rewinding 44774eafdc1c to 1 changesets: 883d75400657
1633 rewinding 9ccaac2e5fbb to 2 changesets: fa8956746c52 883d75400657
1634 $ hg rewind --from 'desc("AC2")' --dry-run
1635 abort: not rewinding, some predecessors are unknown locally: 2e4ab803d8ae
1636 (try selecting all changesets to rewind to manually, possibly with --exact)
1637 [255]
1638 $ hg rewind --from 'desc("AC2")' --exact --dry-run
1639 abort: not rewinding, some predecessors are unknown locally: 2e4ab803d8ae
1640 (try selecting all changesets to rewind to manually, possibly with --exact)
1641 [255]