tests/test-shelve.t
changeset 40870 1b836cee2d91
parent 39894 d9ba836fc234
child 40967 8604f130eb43
equal deleted inserted replaced
40869:74e3df766052 40870:1b836cee2d91
   666   $ hg --config extensions.mq=! unshelve
   666   $ hg --config extensions.mq=! unshelve
   667   unshelving change 'test'
   667   unshelving change 'test'
   668   $ hg bookmark
   668   $ hg bookmark
   669    \* test                      (4|13):33f7f61e6c5e (re)
   669    \* test                      (4|13):33f7f61e6c5e (re)
   670 
   670 
   671 shelve should leave dirstate clean (issue4055)
       
   672 
       
   673   $ cd ..
       
   674   $ hg init shelverebase
       
   675   $ cd shelverebase
       
   676   $ printf 'x\ny\n' > x
       
   677   $ echo z > z
       
   678   $ hg commit -Aqm xy
       
   679   $ echo z >> x
       
   680   $ hg commit -Aqm z
       
   681   $ hg up 5c4c67fb7dce
       
   682   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
       
   683   $ printf 'a\nx\ny\nz\n' > x
       
   684   $ hg commit -Aqm xyz
       
   685   $ echo c >> z
       
   686   $ hg shelve
       
   687   shelved as default
       
   688   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
       
   689 
       
   690   $ hg rebase -d 6c103be8f4e4 --config extensions.rebase=
       
   691   rebasing 2:323bfa07f744 "xyz"( \(tip\))? (re)
       
   692   merging x
       
   693   saved backup bundle to \$TESTTMP/shelverebase/.hg/strip-backup/323bfa07f744-(78114325|7ae538ef)-rebase.hg (re)
       
   694   $ hg unshelve
       
   695   unshelving change 'default'
       
   696   rebasing shelved changes
       
   697   $ hg status
       
   698   M z
       
   699 
       
   700   $ cd ..
       
   701 
       
   702 shelve should only unshelve pending changes (issue4068)
       
   703 
       
   704   $ hg init onlypendingchanges
       
   705   $ cd onlypendingchanges
       
   706   $ touch a
       
   707   $ hg ci -Aqm a
       
   708   $ touch b
       
   709   $ hg ci -Aqm b
       
   710   $ hg up -q 3903775176ed
       
   711   $ touch c
       
   712   $ hg ci -Aqm c
       
   713 
       
   714   $ touch d
       
   715   $ hg add d
       
   716   $ hg shelve
       
   717   shelved as default
       
   718   0 files updated, 0 files merged, 1 files removed, 0 files unresolved
       
   719   $ hg up -q 0e067c57feba
       
   720   $ hg unshelve
       
   721   unshelving change 'default'
       
   722   rebasing shelved changes
       
   723   $ hg status
       
   724   A d
       
   725 
       
   726 unshelve should work on an ancestor of the original commit
       
   727 
       
   728   $ hg shelve
       
   729   shelved as default
       
   730   0 files updated, 0 files merged, 1 files removed, 0 files unresolved
       
   731   $ hg up 3903775176ed
       
   732   0 files updated, 0 files merged, 1 files removed, 0 files unresolved
       
   733   $ hg unshelve
       
   734   unshelving change 'default'
       
   735   rebasing shelved changes
       
   736   $ hg status
       
   737   A d
       
   738 
       
   739 test bug 4073 we need to enable obsolete markers for it
       
   740 
       
   741   $ cat >> $HGRCPATH << EOF
       
   742   > [experimental]
       
   743   > evolution.createmarkers=True
       
   744   > EOF
       
   745   $ hg shelve
       
   746   shelved as default
       
   747   0 files updated, 0 files merged, 1 files removed, 0 files unresolved
       
   748   $ hg debugobsolete `hg log -r 0e067c57feba -T '{node}'`
       
   749   obsoleted 1 changesets
       
   750   $ hg unshelve
       
   751   unshelving change 'default'
       
   752 
       
   753 unshelve should leave unknown files alone (issue4113)
       
   754 
       
   755   $ echo e > e
       
   756   $ hg shelve
       
   757   shelved as default
       
   758   0 files updated, 0 files merged, 1 files removed, 0 files unresolved
       
   759   $ hg status
       
   760   ? e
       
   761   $ hg unshelve
       
   762   unshelving change 'default'
       
   763   $ hg status
       
   764   A d
       
   765   ? e
       
   766   $ cat e
       
   767   e
       
   768 
       
   769 unshelve should keep a copy of unknown files
       
   770 
       
   771   $ hg add e
       
   772   $ hg shelve
       
   773   shelved as default
       
   774   0 files updated, 0 files merged, 2 files removed, 0 files unresolved
       
   775   $ echo z > e
       
   776   $ hg unshelve
       
   777   unshelving change 'default'
       
   778   $ cat e
       
   779   e
       
   780   $ cat e.orig
       
   781   z
       
   782 
       
   783 
       
   784 unshelve and conflicts with tracked and untracked files
       
   785 
       
   786  preparing:
       
   787 
       
   788   $ rm *.orig
       
   789   $ hg ci -qm 'commit stuff'
       
   790   $ hg phase -p null:
       
   791 
       
   792  no other changes - no merge:
       
   793 
       
   794   $ echo f > f
       
   795   $ hg add f
       
   796   $ hg shelve
       
   797   shelved as default
       
   798   0 files updated, 0 files merged, 1 files removed, 0 files unresolved
       
   799   $ echo g > f
       
   800   $ hg unshelve
       
   801   unshelving change 'default'
       
   802   $ hg st
       
   803   A f
       
   804   ? f.orig
       
   805   $ cat f
       
   806   f
       
   807   $ cat f.orig
       
   808   g
       
   809 
       
   810  other uncommitted changes - merge:
       
   811 
       
   812   $ hg st
       
   813   A f
       
   814   ? f.orig
       
   815   $ hg shelve
       
   816   shelved as default
       
   817   0 files updated, 0 files merged, 1 files removed, 0 files unresolved
       
   818 #if repobundlerepo
       
   819   $ hg log -G --template '{rev}  {desc|firstline}  {author}' -R bundle://.hg/shelved/default.hg -r 'bundle()' --hidden
       
   820   o  [48]  changes to: commit stuff  shelve@localhost (re)
       
   821   |
       
   822   ~
       
   823 #endif
       
   824   $ hg log -G --template '{rev}  {desc|firstline}  {author}'
       
   825   @  [37]  commit stuff  test (re)
       
   826   |
       
   827   | o  2  c  test
       
   828   |/
       
   829   o  0  a  test
       
   830   
       
   831   $ mv f.orig f
       
   832   $ echo 1 > a
       
   833   $ hg unshelve --date '1073741824 0'
       
   834   unshelving change 'default'
       
   835   temporarily committing pending changes (restore with 'hg unshelve --abort')
       
   836   rebasing shelved changes
       
   837   merging f
       
   838   warning: conflicts while merging f! (edit, then use 'hg resolve --mark')
       
   839   unresolved conflicts (see 'hg resolve', then 'hg unshelve --continue')
       
   840   [1]
       
   841 
       
   842 #if phasebased
       
   843   $ hg log -G --template '{rev}  {desc|firstline}  {author}  {date|isodate}'
       
   844   @  9  pending changes temporary commit  shelve@localhost  2004-01-10 13:37 +0000
       
   845   |
       
   846   | @  8  changes to: commit stuff  shelve@localhost  1970-01-01 00:00 +0000
       
   847   |/
       
   848   o  7  commit stuff  test  1970-01-01 00:00 +0000
       
   849   |
       
   850   | o  2  c  test  1970-01-01 00:00 +0000
       
   851   |/
       
   852   o  0  a  test  1970-01-01 00:00 +0000
       
   853   
       
   854 #endif
       
   855 
       
   856 #if stripbased
       
   857   $ hg log -G --template '{rev}  {desc|firstline}  {author}  {date|isodate}'
       
   858   @  5  changes to: commit stuff  shelve@localhost  1970-01-01 00:00 +0000
       
   859   |
       
   860   | @  4  pending changes temporary commit  shelve@localhost  2004-01-10 13:37 +0000
       
   861   |/
       
   862   o  3  commit stuff  test  1970-01-01 00:00 +0000
       
   863   |
       
   864   | o  2  c  test  1970-01-01 00:00 +0000
       
   865   |/
       
   866   o  0  a  test  1970-01-01 00:00 +0000
       
   867   
       
   868 #endif
       
   869 
       
   870   $ hg st
       
   871   M f
       
   872   ? f.orig
       
   873   $ cat f
       
   874   <<<<<<< shelve:       d44eae5c3d33 - shelve: pending changes temporary commit
       
   875   g
       
   876   =======
       
   877   f
       
   878   >>>>>>> working-copy: aef214a5229c - shelve: changes to: commit stuff
       
   879   $ cat f.orig
       
   880   g
       
   881   $ hg unshelve --abort -t false
       
   882   tool option will be ignored
       
   883   unshelve of 'default' aborted
       
   884   $ hg st
       
   885   M a
       
   886   ? f.orig
       
   887   $ cat f.orig
       
   888   g
       
   889   $ hg unshelve
       
   890   unshelving change 'default'
       
   891   temporarily committing pending changes (restore with 'hg unshelve --abort')
       
   892   rebasing shelved changes
       
   893   $ hg st
       
   894   M a
       
   895   A f
       
   896   ? f.orig
       
   897 
       
   898  other committed changes - merge:
       
   899 
       
   900   $ hg shelve f
       
   901   shelved as default
       
   902   0 files updated, 0 files merged, 1 files removed, 0 files unresolved
       
   903   $ hg ci a -m 'intermediate other change'
       
   904   $ mv f.orig f
       
   905   $ hg unshelve
       
   906   unshelving change 'default'
       
   907   rebasing shelved changes
       
   908   merging f
       
   909   warning: conflicts while merging f! (edit, then use 'hg resolve --mark')
       
   910   unresolved conflicts (see 'hg resolve', then 'hg unshelve --continue')
       
   911   [1]
       
   912   $ hg st
       
   913   M f
       
   914   ? f.orig
       
   915   $ cat f
       
   916   <<<<<<< shelve:       6b563750f973 - test: intermediate other change
       
   917   g
       
   918   =======
       
   919   f
       
   920   >>>>>>> working-copy: aef214a5229c - shelve: changes to: commit stuff
       
   921   $ cat f.orig
       
   922   g
       
   923   $ hg unshelve --abort
       
   924   unshelve of 'default' aborted
       
   925   $ hg st
       
   926   ? f.orig
       
   927   $ cat f.orig
       
   928   g
       
   929   $ hg shelve --delete default
       
   930 
       
   931 Recreate some conflict again
   671 Recreate some conflict again
   932 
   672 
   933   $ cd ../repo
       
   934   $ hg up -C -r 2e69b451d1ea
   673   $ hg up -C -r 2e69b451d1ea
   935   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   674   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   936   (leaving bookmark test)
   675   (leaving bookmark test)
   937   $ echo y >> a/a
   676   $ echo y >> a/a
   938   $ hg shelve
   677   $ hg shelve
  1141   @@ -0,0 +1,1 @@
   880   @@ -0,0 +1,1 @@
  1142   +patch b
   881   +patch b
  1143 
   882 
  1144   $ cd ..
   883   $ cd ..
  1145 
   884 
  1146 you shouldn't be able to ask for the patch/stats of the most recent shelve if
       
  1147 there are no shelves
       
  1148 
       
  1149   $ hg init noshelves
       
  1150   $ cd noshelves
       
  1151 
       
  1152   $ hg shelve --patch
       
  1153   abort: there are no shelves to show
       
  1154   [255]
       
  1155   $ hg shelve --stat
       
  1156   abort: there are no shelves to show
       
  1157   [255]
       
  1158 
       
  1159   $ cd ..
       
  1160 
       
  1161 Shelve from general delta repo uses bundle2 on disk
   885 Shelve from general delta repo uses bundle2 on disk
  1162 --------------------------------------------------
   886 --------------------------------------------------
  1163 
   887 
  1164 no general delta
   888 no general delta
  1165 
   889 
  1325   ACTUAL  (5|19):703117a2acfb (re)
  1049   ACTUAL  (5|19):703117a2acfb (re)
  1326   ====
  1050   ====
  1327 
  1051 
  1328   $ cd ..
  1052   $ cd ..
  1329 
  1053 
  1330 test .orig files go where the user wants them to
       
  1331 ---------------------------------------------------------------
       
  1332   $ hg init salvage
       
  1333   $ cd salvage
       
  1334   $ echo 'content' > root
       
  1335   $ hg commit -A -m 'root' -q
       
  1336   $ echo '' > root
       
  1337   $ hg shelve -q
       
  1338   $ echo 'contADDent' > root
       
  1339   $ hg unshelve -q --config 'ui.origbackuppath=.hg/origbackups'
       
  1340   warning: conflicts while merging root! (edit, then use 'hg resolve --mark')
       
  1341   unresolved conflicts (see 'hg resolve', then 'hg unshelve --continue')
       
  1342   [1]
       
  1343   $ ls .hg/origbackups
       
  1344   root
       
  1345   $ rm -rf .hg/origbackups
       
  1346 
       
  1347 test Abort unshelve always gets user out of the unshelved state
       
  1348 ---------------------------------------------------------------
       
  1349 
       
  1350 with a corrupted shelve state file
       
  1351   $ sed 's/ae8c668541e8/123456789012/' .hg/shelvedstate > ../corrupt-shelvedstate
       
  1352   $ mv ../corrupt-shelvedstate .hg/shelvestate
       
  1353   $ hg unshelve --abort 2>&1 | grep 'aborted'
       
  1354   unshelve of 'default' aborted
       
  1355   $ hg summary
       
  1356   parent: 0:ae8c668541e8 tip
       
  1357    root
       
  1358   branch: default
       
  1359   commit: 1 modified
       
  1360   update: (current)
       
  1361   phases: 1 draft
       
  1362   $ hg up -C .
       
  1363   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
       
  1364 
       
  1365   $ cd ..
       
  1366 
       
  1367 Keep active bookmark while (un)shelving even on shared repo (issue4940)
  1054 Keep active bookmark while (un)shelving even on shared repo (issue4940)
  1368 -----------------------------------------------------------------------
  1055 -----------------------------------------------------------------------
  1369 
  1056 
  1370   $ cat <<EOF >> $HGRCPATH
  1057   $ cat <<EOF >> $HGRCPATH
  1371   > [extensions]
  1058   > [extensions]
  1398   $ hg bookmarks
  1085   $ hg bookmarks
  1399    \* foo                       (5|19):703117a2acfb (re)
  1086    \* foo                       (5|19):703117a2acfb (re)
  1400      test                      (4|13):33f7f61e6c5e (re)
  1087      test                      (4|13):33f7f61e6c5e (re)
  1401 
  1088 
  1402   $ cd ..
  1089   $ cd ..
  1403 
       
  1404 Shelve and unshelve unknown files. For the purposes of unshelve, a shelved
       
  1405 unknown file is the same as a shelved added file, except that it will be in
       
  1406 unknown state after unshelve if and only if it was either absent or unknown
       
  1407 before the unshelve operation.
       
  1408 
       
  1409   $ hg init unknowns
       
  1410   $ cd unknowns
       
  1411 
       
  1412 The simplest case is if I simply have an unknown file that I shelve and unshelve
       
  1413 
       
  1414   $ echo unknown > unknown
       
  1415   $ hg status
       
  1416   ? unknown
       
  1417   $ hg shelve --unknown
       
  1418   shelved as default
       
  1419   0 files updated, 0 files merged, 1 files removed, 0 files unresolved
       
  1420   $ hg status
       
  1421   $ hg unshelve
       
  1422   unshelving change 'default'
       
  1423   $ hg status
       
  1424   ? unknown
       
  1425   $ rm unknown
       
  1426 
       
  1427 If I shelve, add the file, and unshelve, does it stay added?
       
  1428 
       
  1429   $ echo unknown > unknown
       
  1430   $ hg shelve -u
       
  1431   shelved as default
       
  1432   0 files updated, 0 files merged, 1 files removed, 0 files unresolved
       
  1433   $ hg status
       
  1434   $ touch unknown
       
  1435   $ hg add unknown
       
  1436   $ hg status
       
  1437   A unknown
       
  1438   $ hg unshelve
       
  1439   unshelving change 'default'
       
  1440   temporarily committing pending changes (restore with 'hg unshelve --abort')
       
  1441   rebasing shelved changes
       
  1442   merging unknown
       
  1443   $ hg status
       
  1444   A unknown
       
  1445   $ hg forget unknown
       
  1446   $ rm unknown
       
  1447 
       
  1448 And if I shelve, commit, then unshelve, does it become modified?
       
  1449 
       
  1450   $ echo unknown > unknown
       
  1451   $ hg shelve -u
       
  1452   shelved as default
       
  1453   0 files updated, 0 files merged, 1 files removed, 0 files unresolved
       
  1454   $ hg status
       
  1455   $ touch unknown
       
  1456   $ hg add unknown
       
  1457   $ hg commit -qm "Add unknown"
       
  1458   $ hg status
       
  1459   $ hg unshelve
       
  1460   unshelving change 'default'
       
  1461   rebasing shelved changes
       
  1462   merging unknown
       
  1463   $ hg status
       
  1464   M unknown
       
  1465   $ hg remove --force unknown
       
  1466   $ hg commit -qm "Remove unknown"
       
  1467 
       
  1468   $ cd ..
       
  1469 
       
  1470 We expects that non-bare shelve keeps newly created branch in
       
  1471 working directory.
       
  1472 
       
  1473   $ hg init shelve-preserve-new-branch
       
  1474   $ cd shelve-preserve-new-branch
       
  1475   $ echo "a" >> a
       
  1476   $ hg add a
       
  1477   $ echo "b" >> b
       
  1478   $ hg add b
       
  1479   $ hg commit -m "ab"
       
  1480   $ echo "aa" >> a
       
  1481   $ echo "bb" >> b
       
  1482   $ hg branch new-branch
       
  1483   marked working directory as branch new-branch
       
  1484   (branches are permanent and global, did you want a bookmark?)
       
  1485   $ hg status
       
  1486   M a
       
  1487   M b
       
  1488   $ hg branch
       
  1489   new-branch
       
  1490   $ hg shelve a
       
  1491   shelved as default
       
  1492   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
       
  1493   $ hg branch
       
  1494   new-branch
       
  1495   $ hg status
       
  1496   M b
       
  1497   $ touch "c" >> c
       
  1498   $ hg add c
       
  1499   $ hg status
       
  1500   M b
       
  1501   A c
       
  1502   $ hg shelve --exclude c
       
  1503   shelved as default-01
       
  1504   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
       
  1505   $ hg branch
       
  1506   new-branch
       
  1507   $ hg status
       
  1508   A c
       
  1509   $ hg shelve --include c
       
  1510   shelved as default-02
       
  1511   0 files updated, 0 files merged, 1 files removed, 0 files unresolved
       
  1512   $ hg branch
       
  1513   new-branch
       
  1514   $ hg status
       
  1515   $ echo "d" >> d
       
  1516   $ hg add d
       
  1517   $ hg status
       
  1518   A d
       
  1519 
       
  1520 We expect that bare-shelve will not keep branch in current working directory.
       
  1521 
       
  1522   $ hg shelve
       
  1523   shelved as default-03
       
  1524   0 files updated, 0 files merged, 1 files removed, 0 files unresolved
       
  1525   $ hg branch
       
  1526   default
       
  1527   $ cd ..
       
  1528 
       
  1529 When i shelve commit on newly created branch i expect
       
  1530 that after unshelve newly created branch will be preserved.
       
  1531 
       
  1532   $ hg init shelve_on_new_branch_simple
       
  1533   $ cd shelve_on_new_branch_simple
       
  1534   $ echo "aaa" >> a
       
  1535   $ hg commit -A -m "a"
       
  1536   adding a
       
  1537   $ hg branch
       
  1538   default
       
  1539   $ hg branch test
       
  1540   marked working directory as branch test
       
  1541   (branches are permanent and global, did you want a bookmark?)
       
  1542   $ echo "bbb" >> a
       
  1543   $ hg status
       
  1544   M a
       
  1545   $ hg shelve
       
  1546   shelved as default
       
  1547   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
       
  1548   $ hg branch
       
  1549   default
       
  1550   $ echo "bbb" >> b
       
  1551   $ hg status
       
  1552   ? b
       
  1553   $ hg unshelve
       
  1554   unshelving change 'default'
       
  1555   marked working directory as branch test
       
  1556   $ hg status
       
  1557   M a
       
  1558   ? b
       
  1559   $ hg branch
       
  1560   test
       
  1561   $ cd ..
       
  1562 
       
  1563 When i shelve commit on newly created branch, make
       
  1564 some changes, unshelve it and running into merge
       
  1565 conflicts i expect that after fixing them and
       
  1566 running unshelve --continue newly created branch
       
  1567 will be preserved.
       
  1568 
       
  1569   $ hg init shelve_on_new_branch_conflict
       
  1570   $ cd shelve_on_new_branch_conflict
       
  1571   $ echo "aaa" >> a
       
  1572   $ hg commit -A -m "a"
       
  1573   adding a
       
  1574   $ hg branch
       
  1575   default
       
  1576   $ hg branch test
       
  1577   marked working directory as branch test
       
  1578   (branches are permanent and global, did you want a bookmark?)
       
  1579   $ echo "bbb" >> a
       
  1580   $ hg status
       
  1581   M a
       
  1582   $ hg shelve
       
  1583   shelved as default
       
  1584   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
       
  1585   $ hg branch
       
  1586   default
       
  1587   $ echo "ccc" >> a
       
  1588   $ hg status
       
  1589   M a
       
  1590   $ hg unshelve
       
  1591   unshelving change 'default'
       
  1592   temporarily committing pending changes (restore with 'hg unshelve --abort')
       
  1593   rebasing shelved changes
       
  1594   merging a
       
  1595   warning: conflicts while merging a! (edit, then use 'hg resolve --mark')
       
  1596   unresolved conflicts (see 'hg resolve', then 'hg unshelve --continue')
       
  1597   [1]
       
  1598   $ echo "aaabbbccc" > a
       
  1599   $ rm a.orig
       
  1600   $ hg resolve --mark a
       
  1601   (no more unresolved files)
       
  1602   continue: hg unshelve --continue
       
  1603   $ hg unshelve --continue
       
  1604   marked working directory as branch test
       
  1605   unshelve of 'default' complete
       
  1606   $ cat a
       
  1607   aaabbbccc
       
  1608   $ hg status
       
  1609   M a
       
  1610   $ hg branch
       
  1611   test
       
  1612   $ hg commit -m "test-commit"
       
  1613 
       
  1614 When i shelve on test branch, update to default branch
       
  1615 and unshelve i expect that it will not preserve previous
       
  1616 test branch.
       
  1617 
       
  1618   $ echo "xxx" > b
       
  1619   $ hg add b
       
  1620   $ hg shelve
       
  1621   shelved as test
       
  1622   0 files updated, 0 files merged, 1 files removed, 0 files unresolved
       
  1623   $ hg update -r 7049e48789d7
       
  1624   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
       
  1625   $ hg unshelve
       
  1626   unshelving change 'test'
       
  1627   rebasing shelved changes
       
  1628   $ hg status
       
  1629   A b
       
  1630   $ hg branch
       
  1631   default
       
  1632   $ cd ..
       
  1633 
       
  1634 When i unshelve resulting in merge conflicts and makes saved
       
  1635 file shelvedstate looks like in previous versions in
       
  1636 mercurial(without restore branch information in 7th line) i
       
  1637 expect that after resolving conflicts and successfully
       
  1638 running 'shelve --continue' the branch information won't be
       
  1639 restored and branch will be unchanged.
       
  1640 
       
  1641 shelve on new branch, conflict with previous shelvedstate
       
  1642 
       
  1643   $ hg init conflict
       
  1644   $ cd conflict
       
  1645   $ echo "aaa" >> a
       
  1646   $ hg commit -A -m "a"
       
  1647   adding a
       
  1648   $ hg branch
       
  1649   default
       
  1650   $ hg branch test
       
  1651   marked working directory as branch test
       
  1652   (branches are permanent and global, did you want a bookmark?)
       
  1653   $ echo "bbb" >> a
       
  1654   $ hg status
       
  1655   M a
       
  1656   $ hg shelve
       
  1657   shelved as default
       
  1658   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
       
  1659   $ hg branch
       
  1660   default
       
  1661   $ echo "ccc" >> a
       
  1662   $ hg status
       
  1663   M a
       
  1664   $ hg unshelve
       
  1665   unshelving change 'default'
       
  1666   temporarily committing pending changes (restore with 'hg unshelve --abort')
       
  1667   rebasing shelved changes
       
  1668   merging a
       
  1669   warning: conflicts while merging a! (edit, then use 'hg resolve --mark')
       
  1670   unresolved conflicts (see 'hg resolve', then 'hg unshelve --continue')
       
  1671   [1]
       
  1672 
       
  1673 Removing restore branch information from shelvedstate file(making it looks like
       
  1674 in previous versions) and running unshelve --continue
       
  1675 
       
  1676   $ cp .hg/shelvedstate .hg/shelvedstate_old
       
  1677   $ cat .hg/shelvedstate_old | grep -v 'branchtorestore' > .hg/shelvedstate
       
  1678 
       
  1679   $ echo "aaabbbccc" > a
       
  1680   $ rm a.orig
       
  1681   $ hg resolve --mark a
       
  1682   (no more unresolved files)
       
  1683   continue: hg unshelve --continue
       
  1684   $ hg unshelve --continue
       
  1685   unshelve of 'default' complete
       
  1686   $ cat a
       
  1687   aaabbbccc
       
  1688   $ hg status
       
  1689   M a
       
  1690   $ hg branch
       
  1691   default
       
  1692   $ cd ..
       
  1693 
       
  1694 On non bare shelve the branch information shouldn't be restored
       
  1695 
       
  1696   $ hg init bare_shelve_on_new_branch
       
  1697   $ cd bare_shelve_on_new_branch
       
  1698   $ echo "aaa" >> a
       
  1699   $ hg commit -A -m "a"
       
  1700   adding a
       
  1701   $ hg branch
       
  1702   default
       
  1703   $ hg branch test
       
  1704   marked working directory as branch test
       
  1705   (branches are permanent and global, did you want a bookmark?)
       
  1706   $ echo "bbb" >> a
       
  1707   $ hg status
       
  1708   M a
       
  1709   $ hg shelve a
       
  1710   shelved as default
       
  1711   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
       
  1712   $ hg branch
       
  1713   test
       
  1714   $ hg branch default
       
  1715   marked working directory as branch default
       
  1716   (branches are permanent and global, did you want a bookmark?)
       
  1717   $ echo "bbb" >> b
       
  1718   $ hg status
       
  1719   ? b
       
  1720   $ hg unshelve
       
  1721   unshelving change 'default'
       
  1722   $ hg status
       
  1723   M a
       
  1724   ? b
       
  1725   $ hg branch
       
  1726   default
       
  1727   $ cd ..
       
  1728 
       
  1729 Prepare unshelve with a corrupted shelvedstate
       
  1730   $ hg init r1 && cd r1
       
  1731   $ echo text1 > file && hg add file
       
  1732   $ hg shelve
       
  1733   shelved as default
       
  1734   0 files updated, 0 files merged, 1 files removed, 0 files unresolved
       
  1735   $ echo text2 > file && hg ci -Am text1
       
  1736   adding file
       
  1737   $ hg unshelve
       
  1738   unshelving change 'default'
       
  1739   rebasing shelved changes
       
  1740   merging file
       
  1741   warning: conflicts while merging file! (edit, then use 'hg resolve --mark')
       
  1742   unresolved conflicts (see 'hg resolve', then 'hg unshelve --continue')
       
  1743   [1]
       
  1744   $ echo somethingsomething > .hg/shelvedstate
       
  1745 
       
  1746 Unshelve --continue fails with appropriate message if shelvedstate is corrupted
       
  1747   $ hg unshelve --continue
       
  1748   abort: corrupted shelved state file
       
  1749   (please run hg unshelve --abort to abort unshelve operation)
       
  1750   [255]
       
  1751 
       
  1752 Unshelve --abort works with a corrupted shelvedstate
       
  1753   $ hg unshelve --abort
       
  1754   could not read shelved state file, your working copy may be in an unexpected state
       
  1755   please update to some commit
       
  1756 
       
  1757 Unshelve --abort fails with appropriate message if there's no unshelve in
       
  1758 progress
       
  1759   $ hg unshelve --abort
       
  1760   abort: no unshelve in progress
       
  1761   [255]
       
  1762   $ cd ..
       
  1763 
       
  1764 Unshelve respects --keep even if user intervention is needed
       
  1765   $ hg init unshelvekeep && cd unshelvekeep
       
  1766   $ echo 1 > file && hg ci -Am 1
       
  1767   adding file
       
  1768   $ echo 2 >> file
       
  1769   $ hg shelve
       
  1770   shelved as default
       
  1771   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
       
  1772   $ echo 3 >> file && hg ci -Am 13
       
  1773   $ hg shelve --list
       
  1774   default         (*s ago) * changes to: 1 (glob)
       
  1775   $ hg unshelve --keep
       
  1776   unshelving change 'default'
       
  1777   rebasing shelved changes
       
  1778   merging file
       
  1779   warning: conflicts while merging file! (edit, then use 'hg resolve --mark')
       
  1780   unresolved conflicts (see 'hg resolve', then 'hg unshelve --continue')
       
  1781   [1]
       
  1782   $ hg resolve --mark file
       
  1783   (no more unresolved files)
       
  1784   continue: hg unshelve --continue
       
  1785   $ hg unshelve --continue
       
  1786   unshelve of 'default' complete
       
  1787   $ hg shelve --list
       
  1788   default         (*s ago) * changes to: 1 (glob)
       
  1789   $ cd ..
       
  1790 
       
  1791 Unshelving when there are deleted files does not crash (issue4176)
       
  1792   $ hg init unshelve-deleted-file && cd unshelve-deleted-file
       
  1793   $ echo a > a && echo b > b && hg ci -Am ab
       
  1794   adding a
       
  1795   adding b
       
  1796   $ echo aa > a && hg shelve
       
  1797   shelved as default
       
  1798   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
       
  1799   $ rm b
       
  1800   $ hg st
       
  1801   ! b
       
  1802   $ hg unshelve
       
  1803   unshelving change 'default'
       
  1804   $ hg shelve
       
  1805   shelved as default
       
  1806   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
       
  1807   $ rm a && echo b > b
       
  1808   $ hg st
       
  1809   ! a
       
  1810   $ hg unshelve
       
  1811   unshelving change 'default'
       
  1812   abort: shelved change touches missing files
       
  1813   (run hg status to see which files are missing)
       
  1814   [255]
       
  1815   $ hg st
       
  1816   ! a
       
  1817   $ cd ..
       
  1818 
       
  1819 New versions of Mercurial know how to read onld shelvedstate files
       
  1820   $ hg init oldshelvedstate
       
  1821   $ cd oldshelvedstate
       
  1822   $ echo root > root && hg ci -Am root
       
  1823   adding root
       
  1824   $ echo 1 > a
       
  1825   $ hg add a
       
  1826   $ hg shelve --name ashelve
       
  1827   shelved as ashelve
       
  1828   0 files updated, 0 files merged, 1 files removed, 0 files unresolved
       
  1829   $ echo 2 > a
       
  1830   $ hg ci -Am a
       
  1831   adding a
       
  1832   $ hg unshelve
       
  1833   unshelving change 'ashelve'
       
  1834   rebasing shelved changes
       
  1835   merging a
       
  1836   warning: conflicts while merging a! (edit, then use 'hg resolve --mark')
       
  1837   unresolved conflicts (see 'hg resolve', then 'hg unshelve --continue')
       
  1838   [1]
       
  1839 putting v1 shelvedstate file in place of a created v2
       
  1840   $ cat << EOF > .hg/shelvedstate
       
  1841   > 1
       
  1842   > ashelve
       
  1843   > 8b058dae057a5a78f393f4535d9e363dd5efac9d
       
  1844   > 8b058dae057a5a78f393f4535d9e363dd5efac9d
       
  1845   > 8b058dae057a5a78f393f4535d9e363dd5efac9d f543b27db2cdb41737e2e0008dc524c471da1446
       
  1846   > f543b27db2cdb41737e2e0008dc524c471da1446
       
  1847   > 
       
  1848   > nokeep
       
  1849   > :no-active-bookmark
       
  1850   > EOF
       
  1851   $ echo 1 > a
       
  1852   $ hg resolve --mark a
       
  1853   (no more unresolved files)
       
  1854   continue: hg unshelve --continue
       
  1855 mercurial does not crash
       
  1856   $ hg unshelve --continue
       
  1857   unshelve of 'ashelve' complete
       
  1858 
       
  1859 #if phasebased
       
  1860 
       
  1861 Unshelve with some metadata file missing
       
  1862 ----------------------------------------
       
  1863 
       
  1864   $ hg shelve
       
  1865   shelved as default
       
  1866   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
       
  1867   $ echo 3 > a
       
  1868 
       
  1869 Test with the `.shelve` missing, but the changeset still in the repo (non-natural case)
       
  1870 
       
  1871   $ rm .hg/shelved/default.shelve
       
  1872   $ hg unshelve
       
  1873   unshelving change 'default'
       
  1874   temporarily committing pending changes (restore with 'hg unshelve --abort')
       
  1875   rebasing shelved changes
       
  1876   merging a
       
  1877   warning: conflicts while merging a! (edit, then use 'hg resolve --mark')
       
  1878   unresolved conflicts (see 'hg resolve', then 'hg unshelve --continue')
       
  1879   [1]
       
  1880   $ hg unshelve --abort
       
  1881   unshelve of 'default' aborted
       
  1882 
       
  1883 Unshelve without .shelve metadata (can happen when upgrading a repository with old shelve)
       
  1884 
       
  1885   $ cat .hg/shelved/default.shelve
       
  1886   node=82e0cb9893247d12667017593ce1e5655860f1ac
       
  1887   $ hg strip --hidden --rev 82e0cb989324 --no-backup
       
  1888   $ rm .hg/shelved/default.shelve
       
  1889   $ hg unshelve
       
  1890   unshelving change 'default'
       
  1891   temporarily committing pending changes (restore with 'hg unshelve --abort')
       
  1892   rebasing shelved changes
       
  1893   merging a
       
  1894   warning: conflicts while merging a! (edit, then use 'hg resolve --mark')
       
  1895   unresolved conflicts (see 'hg resolve', then 'hg unshelve --continue')
       
  1896   [1]
       
  1897   $ cat .hg/shelved/default.shelve
       
  1898   node=82e0cb9893247d12667017593ce1e5655860f1ac
       
  1899   $ hg unshelve --abort
       
  1900   unshelve of 'default' aborted
       
  1901 
       
  1902 #endif
       
  1903 
       
  1904   $ cd ..