##// END OF EJS Templates
shelve: make unshelve not crash when there are missing files (issue4176)...
Kostia Balytskyi -
r30846:dfc6663f stable
parent child Browse files
Show More
@@ -650,7 +650,7 b' def _commitworkingcopychanges(ui, repo, '
650 # contains unknown files that are part of the pending change
650 # contains unknown files that are part of the pending change
651 s = repo.status()
651 s = repo.status()
652 addedbefore = frozenset(s.added)
652 addedbefore = frozenset(s.added)
653 if not (s.modified or s.added or s.removed or s.deleted):
653 if not (s.modified or s.added or s.removed):
654 return tmpwctx, addedbefore
654 return tmpwctx, addedbefore
655 ui.status(_("temporarily committing pending changes "
655 ui.status(_("temporarily committing pending changes "
656 "(restore with 'hg unshelve --abort')\n"))
656 "(restore with 'hg unshelve --abort')\n"))
@@ -729,6 +729,17 b' def _finishunshelve(repo, oldtiprev, tr)'
729 repo.unfiltered().changelog.strip(oldtiprev, tr)
729 repo.unfiltered().changelog.strip(oldtiprev, tr)
730 _aborttransaction(repo)
730 _aborttransaction(repo)
731
731
732 def _checkunshelveuntrackedproblems(ui, repo, shelvectx):
733 """Check potential problems which may result from working
734 copy having untracked changes."""
735 wcdeleted = set(repo.status().deleted)
736 shelvetouched = set(shelvectx.files())
737 intersection = wcdeleted.intersection(shelvetouched)
738 if intersection:
739 m = _("shelved change touches missing files")
740 hint = _("run hg status to see which files are missing")
741 raise error.Abort(m, hint=hint)
742
732 @command('unshelve',
743 @command('unshelve',
733 [('a', 'abort', None,
744 [('a', 'abort', None,
734 _('abort an incomplete unshelve operation')),
745 _('abort an incomplete unshelve operation')),
@@ -857,7 +868,7 b' def _dounshelve(ui, repo, *shelved, **op'
857 tmpwctx)
868 tmpwctx)
858
869
859 repo, shelvectx = _unshelverestorecommit(ui, repo, basename, oldquiet)
870 repo, shelvectx = _unshelverestorecommit(ui, repo, basename, oldquiet)
860
871 _checkunshelveuntrackedproblems(ui, repo, shelvectx)
861 branchtorestore = ''
872 branchtorestore = ''
862 if shelvectx.branch() != shelvectx.p1().branch():
873 if shelvectx.branch() != shelvectx.p1().branch():
863 branchtorestore = shelvectx.branch()
874 branchtorestore = shelvectx.branch()
@@ -1710,3 +1710,30 b' Unshelve respects --keep even if user in'
1710 $ hg shelve --list
1710 $ hg shelve --list
1711 default (*s ago) changes to: 1 (glob)
1711 default (*s ago) changes to: 1 (glob)
1712 $ cd ..
1712 $ cd ..
1713
1714 Unshelving when there are deleted files does not crash (issue4176)
1715 $ hg init unshelve-deleted-file && cd unshelve-deleted-file
1716 $ echo a > a && echo b > b && hg ci -Am ab
1717 adding a
1718 adding b
1719 $ echo aa > a && hg shelve
1720 shelved as default
1721 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
1722 $ rm b
1723 $ hg st
1724 ! b
1725 $ hg unshelve
1726 unshelving change 'default'
1727 $ hg shelve
1728 shelved as default
1729 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
1730 $ rm a && echo b > b
1731 $ hg st
1732 ! a
1733 $ hg unshelve
1734 unshelving change 'default'
1735 abort: shelved change touches missing files
1736 (run hg status to see which files are missing)
1737 [255]
1738 $ hg st
1739 ! a
General Comments 0
You need to be logged in to leave comments. Login now