Show More
@@ -167,6 +167,7 b' class shelvedstate(object):' | |||||
167 | pendingctx = fp.readline().strip() |
|
167 | pendingctx = fp.readline().strip() | |
168 | parents = [nodemod.bin(h) for h in fp.readline().split()] |
|
168 | parents = [nodemod.bin(h) for h in fp.readline().split()] | |
169 | stripnodes = [nodemod.bin(h) for h in fp.readline().split()] |
|
169 | stripnodes = [nodemod.bin(h) for h in fp.readline().split()] | |
|
170 | branchtorestore = fp.readline().strip() | |||
170 | finally: |
|
171 | finally: | |
171 | fp.close() |
|
172 | fp.close() | |
172 |
|
173 | |||
@@ -176,11 +177,13 b' class shelvedstate(object):' | |||||
176 | obj.pendingctx = repo[nodemod.bin(pendingctx)] |
|
177 | obj.pendingctx = repo[nodemod.bin(pendingctx)] | |
177 | obj.parents = parents |
|
178 | obj.parents = parents | |
178 | obj.stripnodes = stripnodes |
|
179 | obj.stripnodes = stripnodes | |
|
180 | obj.branchtorestore = branchtorestore | |||
179 |
|
181 | |||
180 | return obj |
|
182 | return obj | |
181 |
|
183 | |||
182 | @classmethod |
|
184 | @classmethod | |
183 |
def save(cls, repo, name, originalwctx, pendingctx, stripnodes |
|
185 | def save(cls, repo, name, originalwctx, pendingctx, stripnodes, | |
|
186 | branchtorestore): | |||
184 | fp = repo.vfs(cls._filename, 'wb') |
|
187 | fp = repo.vfs(cls._filename, 'wb') | |
185 | fp.write('%i\n' % cls._version) |
|
188 | fp.write('%i\n' % cls._version) | |
186 | fp.write('%s\n' % name) |
|
189 | fp.write('%s\n' % name) | |
@@ -190,6 +193,7 b' class shelvedstate(object):' | |||||
190 | ' '.join([nodemod.hex(p) for p in repo.dirstate.parents()])) |
|
193 | ' '.join([nodemod.hex(p) for p in repo.dirstate.parents()])) | |
191 | fp.write('%s\n' % |
|
194 | fp.write('%s\n' % | |
192 | ' '.join([nodemod.hex(n) for n in stripnodes])) |
|
195 | ' '.join([nodemod.hex(n) for n in stripnodes])) | |
|
196 | fp.write('%s\n' % branchtorestore) | |||
193 | fp.close() |
|
197 | fp.close() | |
194 |
|
198 | |||
195 | @classmethod |
|
199 | @classmethod | |
@@ -555,6 +559,12 b' def mergefiles(ui, repo, wctx, shelvectx' | |||||
555 | finally: |
|
559 | finally: | |
556 | ui.quiet = oldquiet |
|
560 | ui.quiet = oldquiet | |
557 |
|
561 | |||
|
562 | def restorebranch(ui, repo, branchtorestore): | |||
|
563 | if branchtorestore and branchtorestore != repo.dirstate.branch(): | |||
|
564 | repo.dirstate.setbranch(branchtorestore) | |||
|
565 | ui.status(_('marked working directory as branch %s\n') | |||
|
566 | % branchtorestore) | |||
|
567 | ||||
558 | def unshelvecleanup(ui, repo, name, opts): |
|
568 | def unshelvecleanup(ui, repo, name, opts): | |
559 | """remove related files after an unshelve""" |
|
569 | """remove related files after an unshelve""" | |
560 | if not opts.get('keep'): |
|
570 | if not opts.get('keep'): | |
@@ -594,6 +604,7 b' def unshelvecontinue(ui, repo, state, op' | |||||
594 | state.stripnodes.append(shelvectx.node()) |
|
604 | state.stripnodes.append(shelvectx.node()) | |
595 |
|
605 | |||
596 | mergefiles(ui, repo, state.wctx, shelvectx) |
|
606 | mergefiles(ui, repo, state.wctx, shelvectx) | |
|
607 | restorebranch(ui, repo, state.branchtorestore) | |||
597 |
|
608 | |||
598 | repair.strip(ui, repo, state.stripnodes, backup=False, topic='shelve') |
|
609 | repair.strip(ui, repo, state.stripnodes, backup=False, topic='shelve') | |
599 | shelvedstate.clear(repo) |
|
610 | shelvedstate.clear(repo) | |
@@ -632,6 +643,10 b' def unshelve(ui, repo, *shelved, **opts)' | |||||
632 | that causes a conflict. This reverts the unshelved changes, and |
|
643 | that causes a conflict. This reverts the unshelved changes, and | |
633 | leaves the bundle in place.) |
|
644 | leaves the bundle in place.) | |
634 |
|
645 | |||
|
646 | If bare shelved change(when no files are specified, without interactive, | |||
|
647 | include and exclude option) was done on newly created branch it would | |||
|
648 | restore branch information to the working directory. | |||
|
649 | ||||
635 | After a successful unshelve, the shelved changes are stored in a |
|
650 | After a successful unshelve, the shelved changes are stored in a | |
636 | backup directory. Only the N most recent backups are kept. N |
|
651 | backup directory. Only the N most recent backups are kept. N | |
637 | defaults to 10 but can be overridden using the ``shelve.maxbackups`` |
|
652 | defaults to 10 but can be overridden using the ``shelve.maxbackups`` | |
@@ -740,6 +755,10 b' def _dounshelve(ui, repo, *shelved, **op' | |||||
740 |
|
755 | |||
741 | shelvectx = repo['tip'] |
|
756 | shelvectx = repo['tip'] | |
742 |
|
757 | |||
|
758 | branchtorestore = '' | |||
|
759 | if shelvectx.branch() != shelvectx.p1().branch(): | |||
|
760 | branchtorestore = shelvectx.branch() | |||
|
761 | ||||
743 | # If the shelve is not immediately on top of the commit |
|
762 | # If the shelve is not immediately on top of the commit | |
744 | # we'll be merging with, rebase it to be on top. |
|
763 | # we'll be merging with, rebase it to be on top. | |
745 | if tmpwctx.node() != shelvectx.parents()[0].node(): |
|
764 | if tmpwctx.node() != shelvectx.parents()[0].node(): | |
@@ -756,7 +775,8 b' def _dounshelve(ui, repo, *shelved, **op' | |||||
756 |
|
775 | |||
757 | stripnodes = [repo.changelog.node(rev) |
|
776 | stripnodes = [repo.changelog.node(rev) | |
758 | for rev in xrange(oldtiprev, len(repo))] |
|
777 | for rev in xrange(oldtiprev, len(repo))] | |
759 |
shelvedstate.save(repo, basename, pctx, tmpwctx, stripnodes |
|
778 | shelvedstate.save(repo, basename, pctx, tmpwctx, stripnodes, | |
|
779 | branchtorestore) | |||
760 |
|
780 | |||
761 | util.rename(repo.join('rebasestate'), |
|
781 | util.rename(repo.join('rebasestate'), | |
762 | repo.join('unshelverebasestate')) |
|
782 | repo.join('unshelverebasestate')) | |
@@ -772,6 +792,7 b' def _dounshelve(ui, repo, *shelved, **op' | |||||
772 | shelvectx = tmpwctx |
|
792 | shelvectx = tmpwctx | |
773 |
|
793 | |||
774 | mergefiles(ui, repo, pctx, shelvectx) |
|
794 | mergefiles(ui, repo, pctx, shelvectx) | |
|
795 | restorebranch(ui, repo, branchtorestore) | |||
775 |
|
796 | |||
776 | # Forget any files that were unknown before the shelve, unknown before |
|
797 | # Forget any files that were unknown before the shelve, unknown before | |
777 | # unshelve started, but are now added. |
|
798 | # unshelve started, but are now added. | |
@@ -841,6 +862,12 b' def shelvecmd(ui, repo, *pats, **opts):' | |||||
841 | files. If specific files or directories are named, only changes to |
|
862 | files. If specific files or directories are named, only changes to | |
842 | those files are shelved. |
|
863 | those files are shelved. | |
843 |
|
864 | |||
|
865 | In bare shelve(when no files are specified, without interactive, | |||
|
866 | include and exclude option), shelving remembers information if the | |||
|
867 | working directory was on newly created branch, in other words working | |||
|
868 | directory was on different branch than its first parent. In this | |||
|
869 | situation unshelving restores branch information to the working directory. | |||
|
870 | ||||
844 | Each shelved change has a name that makes it easier to find later. |
|
871 | Each shelved change has a name that makes it easier to find later. | |
845 | The name of a shelved change defaults to being based on the active |
|
872 | The name of a shelved change defaults to being based on the active | |
846 | bookmark, or if there is no active bookmark, the current named |
|
873 | bookmark, or if there is no active bookmark, the current named |
@@ -36,6 +36,12 b' shelve has a help message' | |||||
36 | specific files or directories are named, only changes to those files are |
|
36 | specific files or directories are named, only changes to those files are | |
37 | shelved. |
|
37 | shelved. | |
38 |
|
38 | |||
|
39 | In bare shelve(when no files are specified, without interactive, include | |||
|
40 | and exclude option), shelving remembers information if the working | |||
|
41 | directory was on newly created branch, in other words working directory | |||
|
42 | was on different branch than its first parent. In this situation | |||
|
43 | unshelving restores branch information to the working directory. | |||
|
44 | ||||
39 | Each shelved change has a name that makes it easier to find later. The |
|
45 | Each shelved change has a name that makes it easier to find later. The | |
40 | name of a shelved change defaults to being based on the active bookmark, |
|
46 | name of a shelved change defaults to being based on the active bookmark, | |
41 | or if there is no active bookmark, the current named branch. To specify a |
|
47 | or if there is no active bookmark, the current named branch. To specify a | |
@@ -1377,3 +1383,202 b' We expect that bare-shelve will not keep' | |||||
1377 | $ hg branch |
|
1383 | $ hg branch | |
1378 | default |
|
1384 | default | |
1379 |
|
1385 | |||
|
1386 | When i shelve commit on newly created branch i expect | |||
|
1387 | that after unshelve newly created branch will be preserved. | |||
|
1388 | ||||
|
1389 | $ hg init shelve_on_new_branch_simple | |||
|
1390 | $ cd shelve_on_new_branch_simple | |||
|
1391 | $ echo "aaa" >> a | |||
|
1392 | $ hg commit -A -m "a" | |||
|
1393 | adding a | |||
|
1394 | $ hg branch | |||
|
1395 | default | |||
|
1396 | $ hg branch test | |||
|
1397 | marked working directory as branch test | |||
|
1398 | (branches are permanent and global, did you want a bookmark?) | |||
|
1399 | $ echo "bbb" >> a | |||
|
1400 | $ hg status | |||
|
1401 | M a | |||
|
1402 | $ hg shelve | |||
|
1403 | shelved as default | |||
|
1404 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |||
|
1405 | $ hg branch | |||
|
1406 | default | |||
|
1407 | $ echo "bbb" >> b | |||
|
1408 | $ hg status | |||
|
1409 | ? b | |||
|
1410 | $ hg unshelve | |||
|
1411 | unshelving change 'default' | |||
|
1412 | marked working directory as branch test | |||
|
1413 | $ hg status | |||
|
1414 | M a | |||
|
1415 | ? b | |||
|
1416 | $ hg branch | |||
|
1417 | test | |||
|
1418 | ||||
|
1419 | When i shelve commit on newly created branch, make | |||
|
1420 | some changes, unshelve it and running into merge | |||
|
1421 | conflicts i expect that after fixing them and | |||
|
1422 | running unshelve --continue newly created branch | |||
|
1423 | will be preserved. | |||
|
1424 | ||||
|
1425 | $ hg init shelve_on_new_branch_conflict | |||
|
1426 | $ cd shelve_on_new_branch_conflict | |||
|
1427 | $ echo "aaa" >> a | |||
|
1428 | $ hg commit -A -m "a" | |||
|
1429 | adding a | |||
|
1430 | $ hg branch | |||
|
1431 | default | |||
|
1432 | $ hg branch test | |||
|
1433 | marked working directory as branch test | |||
|
1434 | (branches are permanent and global, did you want a bookmark?) | |||
|
1435 | $ echo "bbb" >> a | |||
|
1436 | $ hg status | |||
|
1437 | M a | |||
|
1438 | $ hg shelve | |||
|
1439 | shelved as default | |||
|
1440 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |||
|
1441 | $ hg branch | |||
|
1442 | default | |||
|
1443 | $ echo "ccc" >> a | |||
|
1444 | $ hg status | |||
|
1445 | M a | |||
|
1446 | $ hg unshelve | |||
|
1447 | unshelving change 'default' | |||
|
1448 | temporarily committing pending changes (restore with 'hg unshelve --abort') | |||
|
1449 | rebasing shelved changes | |||
|
1450 | rebasing 2:425c97ef07f3 "changes to: a" (tip) | |||
|
1451 | merging a | |||
|
1452 | warning: conflicts while merging a! (edit, then use 'hg resolve --mark') | |||
|
1453 | unresolved conflicts (see 'hg resolve', then 'hg unshelve --continue') | |||
|
1454 | [1] | |||
|
1455 | $ echo "aaabbbccc" > a | |||
|
1456 | $ rm a.orig | |||
|
1457 | $ hg resolve --mark a | |||
|
1458 | (no more unresolved files) | |||
|
1459 | continue: hg unshelve --continue | |||
|
1460 | $ hg unshelve --continue | |||
|
1461 | rebasing 2:425c97ef07f3 "changes to: a" (tip) | |||
|
1462 | marked working directory as branch test | |||
|
1463 | unshelve of 'default' complete | |||
|
1464 | $ cat a | |||
|
1465 | aaabbbccc | |||
|
1466 | $ hg status | |||
|
1467 | M a | |||
|
1468 | $ hg branch | |||
|
1469 | test | |||
|
1470 | $ hg commit -m "test-commit" | |||
|
1471 | ||||
|
1472 | When i shelve on test branch, update to default branch | |||
|
1473 | and unshelve i expect that it will not preserve previous | |||
|
1474 | test branch. | |||
|
1475 | ||||
|
1476 | $ echo "xxx" > b | |||
|
1477 | $ hg add b | |||
|
1478 | $ hg shelve | |||
|
1479 | shelved as test | |||
|
1480 | 0 files updated, 0 files merged, 1 files removed, 0 files unresolved | |||
|
1481 | $ hg update -r default | |||
|
1482 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |||
|
1483 | $ hg unshelve | |||
|
1484 | unshelving change 'test' | |||
|
1485 | rebasing shelved changes | |||
|
1486 | rebasing 2:357525f34729 "changes to: test-commit" (tip) | |||
|
1487 | $ hg status | |||
|
1488 | A b | |||
|
1489 | $ hg branch | |||
|
1490 | default | |||
|
1491 | ||||
|
1492 | When i unshelve resulting in merge conflicts and makes saved | |||
|
1493 | file shelvedstate looks like in previous versions in | |||
|
1494 | mercurial(without restore branch information in 7th line) i | |||
|
1495 | expect that after resolving conflicts and succesfully | |||
|
1496 | running 'shelve --continue' the branch information won't be | |||
|
1497 | restored and branch will be unchanged. | |||
|
1498 | ||||
|
1499 | $ hg init shelve_on_new_branch_conflict_with_previous_shelvedstate | |||
|
1500 | $ cd shelve_on_new_branch_conflict_with_previous_shelvedstate | |||
|
1501 | $ echo "aaa" >> a | |||
|
1502 | $ hg commit -A -m "a" | |||
|
1503 | adding a | |||
|
1504 | $ hg branch | |||
|
1505 | default | |||
|
1506 | $ hg branch test | |||
|
1507 | marked working directory as branch test | |||
|
1508 | (branches are permanent and global, did you want a bookmark?) | |||
|
1509 | $ echo "bbb" >> a | |||
|
1510 | $ hg status | |||
|
1511 | M a | |||
|
1512 | $ hg shelve | |||
|
1513 | shelved as default | |||
|
1514 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |||
|
1515 | $ hg branch | |||
|
1516 | default | |||
|
1517 | $ echo "ccc" >> a | |||
|
1518 | $ hg status | |||
|
1519 | M a | |||
|
1520 | $ hg unshelve | |||
|
1521 | unshelving change 'default' | |||
|
1522 | temporarily committing pending changes (restore with 'hg unshelve --abort') | |||
|
1523 | rebasing shelved changes | |||
|
1524 | rebasing 2:425c97ef07f3 "changes to: a" (tip) | |||
|
1525 | merging a | |||
|
1526 | warning: conflicts while merging a! (edit, then use 'hg resolve --mark') | |||
|
1527 | unresolved conflicts (see 'hg resolve', then 'hg unshelve --continue') | |||
|
1528 | [1] | |||
|
1529 | ||||
|
1530 | Removing restore branch information from shelvedstate file(making it looks like | |||
|
1531 | in previous versions) and running unshelve --continue | |||
|
1532 | ||||
|
1533 | $ head -n 6 < .hg/shelvedstate > .hg/shelvedstate_oldformat | |||
|
1534 | $ rm .hg/shelvedstate | |||
|
1535 | $ mv .hg/shelvedstate_oldformat .hg/shelvedstate | |||
|
1536 | ||||
|
1537 | $ echo "aaabbbccc" > a | |||
|
1538 | $ rm a.orig | |||
|
1539 | $ hg resolve --mark a | |||
|
1540 | (no more unresolved files) | |||
|
1541 | continue: hg unshelve --continue | |||
|
1542 | $ hg unshelve --continue | |||
|
1543 | rebasing 2:425c97ef07f3 "changes to: a" (tip) | |||
|
1544 | unshelve of 'default' complete | |||
|
1545 | $ cat a | |||
|
1546 | aaabbbccc | |||
|
1547 | $ hg status | |||
|
1548 | M a | |||
|
1549 | $ hg branch | |||
|
1550 | default | |||
|
1551 | ||||
|
1552 | On non bare shelve the branch information shouldn't be restored | |||
|
1553 | ||||
|
1554 | $ hg init bare_shelve_on_new_branch | |||
|
1555 | $ cd bare_shelve_on_new_branch | |||
|
1556 | $ echo "aaa" >> a | |||
|
1557 | $ hg commit -A -m "a" | |||
|
1558 | adding a | |||
|
1559 | $ hg branch | |||
|
1560 | default | |||
|
1561 | $ hg branch test | |||
|
1562 | marked working directory as branch test | |||
|
1563 | (branches are permanent and global, did you want a bookmark?) | |||
|
1564 | $ echo "bbb" >> a | |||
|
1565 | $ hg status | |||
|
1566 | M a | |||
|
1567 | $ hg shelve a | |||
|
1568 | shelved as default | |||
|
1569 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |||
|
1570 | $ hg branch | |||
|
1571 | test | |||
|
1572 | $ hg branch default | |||
|
1573 | marked working directory as branch default | |||
|
1574 | (branches are permanent and global, did you want a bookmark?) | |||
|
1575 | $ echo "bbb" >> b | |||
|
1576 | $ hg status | |||
|
1577 | ? b | |||
|
1578 | $ hg unshelve | |||
|
1579 | unshelving change 'default' | |||
|
1580 | $ hg status | |||
|
1581 | M a | |||
|
1582 | ? b | |||
|
1583 | $ hg branch | |||
|
1584 | default |
General Comments 0
You need to be logged in to leave comments.
Login now