This is an archive of the discontinued Mercurial Phabricator instance.

unshelve: disable unshelve during merge (issue5123)
ClosedPublic

Authored by navaneeth.suresh on Mar 25 2019, 3:17 AM.

Details

Summary

As stated in the issue5123, unshelve can destroy the second parent of
the context when tried to unshelve with an uncommitted merge. This
patch makes unshelve to abort when called with an uncommitted merge.

See how shelve.mergefiles works. Commit structure looks like this:

... -> pctx -> tmpwctx -> shelvectx
                  /
                 /
        second
        merge parent

pctx = parent before merging working context(first merge parent)
tmpwctx = commited working directory after merge(with two parents)
shelvectx = shelved context

shelve.mergefiles first updates to pctx then it reverts shelvectx to pctx with:

cmdutil.revert(ui, repo, shelvectx, repo.dirstate.parents(),
                       *pathtofiles(repo, files),
                       **{'no_backup': True})

Reverting tmpwctx files that were merged from second parent to pctx makes them
added because they are not in pctx.

Changing this revert operation is crucial to restore parents after unshelve. This is a
complicated issue as this is not fixing a regression. Thus, for the time being,
unshelve during an uncommitted merge can be aborted.

(Details taken from http://mercurial.808500.n3.nabble.com/PATCH-V3-shelve-restore-parents-after-unshelve-issue5123-tt4036858.html#a4037408)

Diff Detail

Repository
rHG Mercurial
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

yuja added a subscriber: yuja.Mar 25 2019, 6:29 PM
As stated in the issue5123, unshelve can destroy the second parent of
the context when tried to unshelve with an uncommitted merge. This
patch makes unshelve to abort when called with an uncommitted merge.

Is it difficult to fix unshelve to not lose merge parents?

https://bz.mercurial-scm.org/show_bug.cgi?id=5123#c2

Is it difficult to fix unshelve to not lose merge parents?
https://bz.mercurial-scm.org/show_bug.cgi?id=5123#c2

I'll try to come up with a fix. But, hg shelve is aborting during a merge. Can unshelve be aborted too? I don't have a strong opinion on this. I am just asking.

yuja added a comment.Mar 27 2019, 6:35 PM
> Is it difficult to fix unshelve to not lose merge parents?
> 
> https://bz.mercurial-scm.org/show_bug.cgi?id=5123#c2
I'll try to come up with a fix. But, `hg shelve` is aborting during a merge. Can `unshelve` be aborted too?

It could abort, but mpm said there would be no reason to, and I agree with
that. Unshelving on top of a merge seems somewhat useful.

yuja added a comment.Apr 1 2019, 7:04 PM
I saw some patches[0][1][2] trying to fix this issue. It seems like it's difficult to preserve the second parent.
[0]: http://mercurial.808500.n3.nabble.com/PATCH-shelve-adds-restoring-original-parents-after-unshelve-issue5123-tc4035657.html#none
[1]: http://mercurial.808500.n3.nabble.com/PATCH-V2-shelve-restore-parents-after-unshelve-issue5123-tc4036093.html#a4037370
[2]: http://mercurial.808500.n3.nabble.com/PATCH-V3-shelve-restore-parents-after-unshelve-issue5123-tt4036858.html#a4037408

Okay, let's disable unshelve then. Can you update the commit message to
include why we can't simply allow it?

navaneeth.suresh edited the summary of this revision. (Show Details)Apr 2 2019, 9:06 AM
navaneeth.suresh updated this revision to Diff 14616.
This revision was automatically updated to reflect the committed changes.

Thanks for queuing Yuya.