This is an RFC patch. This does three things:
- Adds an --unresolved flag to hg shelve.
- Adds an --unresolved flag to hg unshelve.
- Adds an experimental config option store-in-extra to handle storage method.
When experimental.store-in-extra == True:
The mergestate records are stored in changeset extras. I have used the storage
format supported for hg versions 3.7 or later. For the time being, I have omitted
the storage of the content of the local version of unresolved files.
Otherwise:
The usual mergestate information in $HGRCPATH/merge/ is moved to
$HGRCPATH/merge-unresolved/<basename>/.
After shelving, and the working directory is updated to p1().
Unresolved shelve changesets are stored with the extra mapping
{'unresolved-merge': True}. Also, hg shelve --patch and
hg shelve --list will show unresolved files separately as:
$ hg shelve --list default (unresolved) (1s ago) changes to: C
hg shelve will abort when:
- No merge is active on calling with --unresolved.
- No unresolved files found in active merge on calling with --unresolved.
- Merge is active on calling without --unresolved.
hg unshelve --unresolved will get the user back to the old unresolved merge by
the following steps:
Step 1: If the user has committed new changesets after shelving the changes,
they must update the working directory to one of the merge parents.
Step 2: Change parents of dirstate to p1 and p2.
Step 3: In order to restore our partially resolved state, we will move the
contents of $HGRCPATH/merge-unresolved/<basename>/
to $HGRCPATH/merge/ if experimental.store-in-extra not
set True. Otherwise, we'll write from data stored in changeset extras.
Step 4: We now have a state in which files marked as resolved might have
conflicts. But, we will apply the changes in shelve on the top of this so that we
can get our old unresolved merge again by the usual unshelve mechanism.
The usual rebase step is avoided on unresolved shelve changesets. Also, we
use the functions present in merge.py to read/write mergestate records
from/to changeset extras.
$ hg unshelve --unresolved will abort when:
- The working directory is dirty.
- If there is an ongoing merge.
- If the working directory is not at either p1 or p2.
(p1, p2 are the parents of the unresolved shelve changeset)
I think I'd like to see at least two changes here: one that introduces the code for storing merge state in extra, and then a second that uses it in shelve.