comparison tests/test-rewind.t @ 5833:be8f7eb3f3a0 mercurial-4.7

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