Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use "hg unshelve" like unstashing with Git

When invoking hg unshelve --keep and I get a conflict, I need to resolve the conflict and then invoke hg unshelve --continue --keep again. Why is the last step necessary? And why I can't invoke hg unshelve --continue --keep directly without resolving the commit - to get out of the unshelving state?

c:\temp\hg test>hg st
M new.txt

c:\temp\hg test>hg commit -m "fjdjkfs"

c:\temp\hg test>hg unshelve --keep
unshelving change 'shelve'
adding changesets
adding manifests
adding file changes
added 1 changesets with 1 changes to 1 files (+1 heads)
merging new.txt
warning: conflicts during merge.
merging new.txt incomplete! (edit conflicts, then use 'hg resolve --mark')
unresolved conflicts (see 'hg resolve', then 'hg unshelve --continue')

c:\temp\hg test>hg st
M new.txt
? new.txt.orig

c:\temp\hg test>hg unshelve --keep --continue
abort: unresolved conflicts, can't continue
(see 'hg resolve', then 'hg unshelve --continue')

c:\temp\hg test>hg resolve --mark

c:\temp\hg test>hg unshelve --keep --continue
no changes needed to new.txt
unshelve of 'shelve' complete

c:\temp\hg test>hg st
warning: ignoring unknown working parent 11667b875a2d!
? new.txt.orig
like image 496
Thomas S. Avatar asked Apr 07 '15 17:04

Thomas S.


People also ask

What is HG shelve?

Description. The "hg shelve" command saves changes made to the working directory and reverts those changes, resetting the working directory to a clean state.


1 Answers

Why is the last step necessary?

Because it's possible that not all changes have been applied yet. The merge conflict may happen halfway through the unshelving operation. In this case, you need to pass control back to Mercurial to apply the remaining changes.

And why I can't invoke hg unshelve --continue --keep directly without resolving the commit - to get out of the unshelving state?

If you just want to get out of the unshelving state, and don't care about applying the changes correctly to your working directory, you should just do hg unshelve --abort. The --continue flag is for resuming the unshelve after fixing merge conflicts. Mercurial won't let you do that without resolving the conflicts because this would leave your working directory in a broken state.

See hg help unshelve for more information about these arguments.

like image 108
Kevin Avatar answered Oct 07 '22 11:10

Kevin