Skip to content
Snippets Groups Projects
Commit ca8170b5 authored by Christian Delahousse's avatar Christian Delahousse
Browse files

shelve: delete shelve statefile on any exception during abort

When a user's repository is in an unfinished unshelve state and they choose to
abort, at a minimum, the repo should be out of that state. We've found
situations where the user could not leave the state unless manually deleting the
state file. This fix ensures that no matter what exception may be raised during
the abort, the shelved state file will be deleted, the user will be out of the
unshelve state and they can get their repository into a workable condition.
parent 7a3f6490
No related branches found
No related tags found
No related merge requests found
......@@ -482,5 +482,6 @@
mergefiles(ui, repo, state.wctx, state.pendingctx)
repair.strip(ui, repo, state.stripnodes, backup=False, topic='shelve')
finally:
shelvedstate.clear(repo)
ui.warn(_("unshelve of '%s' aborted\n") % state.name)
......@@ -485,6 +486,5 @@
shelvedstate.clear(repo)
ui.warn(_("unshelve of '%s' aborted\n") % state.name)
finally:
lockmod.release(lock, wlock)
def mergefiles(ui, repo, wctx, shelvectx):
......
......@@ -1010,3 +1010,43 @@
changegroup -- "{'version': '02'}"
7e30d8ac6f23cfc84330fd7e698730374615d21a
$ cd ..
test Abort unshelve always gets user out of the unshelved state
---------------------------------------------------------------
$ hg init salvage
$ cd salvage
$ echo 'content' > root
$ hg commit -A -m 'root' -q
$ echo '' > root
$ hg shelve -q
$ echo 'contADDent' > root
$ hg unshelve -q
warning: conflicts while merging root! (edit, then use 'hg resolve --mark')
unresolved conflicts (see 'hg resolve', then 'hg unshelve --continue')
[1]
Wreak havoc on the unshelve process
$ rm .hg/unshelverebasestate
$ hg unshelve --abort
unshelve of 'default' aborted
abort: No such file or directory
[255]
Can the user leave the current state?
$ hg up -C .
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
Try again but with a corrupted shelve state file
$ hg strip -r 2 -r 1 -q
$ hg up -r 0 -q
$ echo '' > root
$ hg shelve -q
$ echo 'contADDent' > root
$ hg unshelve -q
warning: conflicts while merging root! (edit, then use 'hg resolve --mark')
unresolved conflicts (see 'hg resolve', then 'hg unshelve --continue')
[1]
$ sed 's/ae8c668541e8/123456789012/' .hg/shelvedstate > ../corrupt-shelvedstate
$ mv ../corrupt-shelvedstate .hg/histedit-state
$ hg unshelve --abort |& grep 'rebase aborted'
rebase aborted
$ hg up -C .
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment