##// END OF EJS Templates
abort: added support for unshelve...
Taapas Agrawal -
r42802:3fb04938 default
parent child Browse files
Show More
@@ -6182,6 +6182,12 b' def unshelve(ui, repo, *shelved, **opts)'
6182 6182 with repo.wlock():
6183 6183 return shelvemod.dounshelve(ui, repo, *shelved, **opts)
6184 6184
6185 statemod.addunfinished(
6186 'unshelve', fname='shelvedstate', continueflag=True,
6187 abortfunc=shelvemod.hgabortunshelve,
6188 cmdmsg=_('unshelve already in progress'),
6189 )
6190
6185 6191 @command('update|up|checkout|co',
6186 6192 [('C', 'clean', None, _('discard uncommitted changes (no backup)')),
6187 6193 ('c', 'check', None, _('require clean working directory')),
@@ -624,7 +624,30 b' def checkparents(repo, state):'
624 624 raise error.Abort(_('working directory parents do not match unshelve '
625 625 'state'))
626 626
627 def unshelveabort(ui, repo, state, opts):
627 def _loadshelvedstate(ui, repo, opts):
628 try:
629 state = shelvedstate.load(repo)
630 if opts.get('keep') is None:
631 opts['keep'] = state.keep
632 except IOError as err:
633 if err.errno != errno.ENOENT:
634 raise
635 cmdutil.wrongtooltocontinue(repo, _('unshelve'))
636 except error.CorruptedState as err:
637 ui.debug(pycompat.bytestr(err) + '\n')
638 if opts.get('continue'):
639 msg = _('corrupted shelved state file')
640 hint = _('please run hg unshelve --abort to abort unshelve '
641 'operation')
642 raise error.Abort(msg, hint=hint)
643 elif opts.get('abort'):
644 shelvedstate.clear(repo)
645 raise error.Abort(_('could not read shelved state file, your '
646 'working copy may be in an unexpected state\n'
647 'please update to some commit\n'))
648 return state
649
650 def unshelveabort(ui, repo, state):
628 651 """subcommand that abort an in-progress unshelve"""
629 652 with repo.lock():
630 653 try:
@@ -642,6 +665,12 b' def unshelveabort(ui, repo, state, opts)'
642 665 shelvedstate.clear(repo)
643 666 ui.warn(_("unshelve of '%s' aborted\n") % state.name)
644 667
668 def hgabortunshelve(ui, repo):
669 """logic to abort unshelve using 'hg abort"""
670 with repo.wlock():
671 state = _loadshelvedstate(ui, repo, {'abort' : True})
672 return unshelveabort(ui, repo, state)
673
645 674 def mergefiles(ui, repo, wctx, shelvectx):
646 675 """updates to wctx and merges the changes from shelvectx into the
647 676 dirstate."""
@@ -665,7 +694,6 b' def unshelvecleanup(ui, repo, name, opts'
665 694 if shfile.exists():
666 695 shfile.movetobackup()
667 696 cleanupoldbackups(repo)
668
669 697 def unshelvecontinue(ui, repo, state, opts):
670 698 """subcommand to continue an in-progress unshelve"""
671 699 # We're finishing off a merge. First parent is our original
@@ -864,29 +892,9 b' def dounshelve(ui, repo, *shelved, **opt'
864 892 if abortf and opts.get('tool', False):
865 893 ui.warn(_('tool option will be ignored\n'))
866 894
867 try:
868 state = shelvedstate.load(repo)
869 if opts.get('keep') is None:
870 opts['keep'] = state.keep
871 except IOError as err:
872 if err.errno != errno.ENOENT:
873 raise
874 cmdutil.wrongtooltocontinue(repo, _('unshelve'))
875 except error.CorruptedState as err:
876 ui.debug(pycompat.bytestr(err) + '\n')
877 if continuef:
878 msg = _('corrupted shelved state file')
879 hint = _('please run hg unshelve --abort to abort unshelve '
880 'operation')
881 raise error.Abort(msg, hint=hint)
882 elif abortf:
883 shelvedstate.clear(repo)
884 raise error.Abort(_('could not read shelved state file, your '
885 'working copy may be in an unexpected state\n'
886 'please update to some commit\n'))
887
895 state = _loadshelvedstate(ui, repo, opts)
888 896 if abortf:
889 return unshelveabort(ui, repo, state, opts)
897 return unshelveabort(ui, repo, state)
890 898 elif continuef:
891 899 return unshelvecontinue(ui, repo, state, opts)
892 900 elif len(shelved) > 1:
@@ -194,10 +194,6 b' def addunfinished(opname, fname, clearab'
194 194 _unfinishedstates.insert(0, statecheckobj)
195 195
196 196 addunfinished(
197 'unshelve', fname='shelvedstate', continueflag=True,
198 cmdmsg=_('unshelve already in progress')
199 )
200 addunfinished(
201 197 'update', fname='updatestate', clearable=True,
202 198 cmdmsg=_('last update was interrupted'),
203 199 cmdhint=_("use 'hg update' to get a consistent checkout"),
@@ -1,4 +1,5 b''
1 1 #testcases stripbased phasebased
2 #testcases abortflag abortcommand
2 3
3 4 $ cat <<EOF >> $HGRCPATH
4 5 > [extensions]
@@ -19,6 +20,13 b''
19 20
20 21 #endif
21 22
23 #if abortflag
24 $ cat >> $HGRCPATH <<EOF
25 > [alias]
26 > abort = unshelve --abort
27 > EOF
28 #endif
29
22 30 shelve should leave dirstate clean (issue4055)
23 31
24 32 $ hg init shelverebase
@@ -285,7 +293,14 b' unshelve and conflicts with tracked and '
285 293 >>>>>>> working-copy: aef214a5229c - shelve: changes to: commit stuff
286 294 $ cat f.orig
287 295 g
288 $ hg unshelve --abort
296
297 #if abortcommand
298 when in dry-run mode
299 $ hg abort --dry-run
300 unshelve in progress, will be aborted
301 #endif
302
303 $ hg abort
289 304 unshelve of 'default' aborted
290 305 $ hg st
291 306 ? f.orig
@@ -695,7 +710,7 b' Unshelve --continue fails with appropria'
695 710 [255]
696 711
697 712 Unshelve --abort works with a corrupted shelvedstate
698 $ hg unshelve --abort
713 $ hg abort
699 714 abort: could not read shelved state file, your working copy may be in an unexpected state
700 715 please update to some commit
701 716
@@ -703,8 +718,10 b' Unshelve --abort works with a corrupted '
703 718
704 719 Unshelve --abort fails with appropriate message if there's no unshelve in
705 720 progress
706 $ hg unshelve --abort
707 abort: no unshelve in progress
721 $ hg abort
722 abort: no unshelve in progress (abortflag !)
723 abort: merge in progress but does not support 'hg abort' (no-abortflag !)
724 (use 'hg commit' or 'hg merge --abort') (no-abortflag !)
708 725 [255]
709 726 $ cd ..
710 727
@@ -824,7 +841,7 b' Test with the `.shelve` missing, but the'
824 841 warning: conflicts while merging a! (edit, then use 'hg resolve --mark')
825 842 unresolved conflicts (see 'hg resolve', then 'hg unshelve --continue')
826 843 [1]
827 $ hg unshelve --abort
844 $ hg abort
828 845 unshelve of 'default' aborted
829 846
830 847 Unshelve without .shelve metadata (can happen when upgrading a repository with old shelve)
@@ -843,7 +860,7 b' Unshelve without .shelve metadata (can h'
843 860 [1]
844 861 $ cat .hg/shelved/default.shelve
845 862 node=82e0cb9893247d12667017593ce1e5655860f1ac
846 $ hg unshelve --abort
863 $ hg abort
847 864 unshelve of 'default' aborted
848 865
849 866 #endif
General Comments 0
You need to be logged in to leave comments. Login now