Page MenuHomePhabricator

unshelve: add --unresolved flag to unshelve mergestate with unresolved files
Needs ReviewPublic

Authored by navaneeth.suresh on Aug 17 2019, 4:39 PM.

Details

Reviewers
None
Group Reviewers
hg-reviewers
Summary

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 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.

$ hg unshelve --unresolved will abort when:

  1. The working directory is dirty.
  2. If there is an ongoing merge.
  3. If the working directory is not at either p1 or p2.

(p1, p2 are the parents of the unresolved shelve changeset)

Diff Detail

Repository
rHG Mercurial
Lint
Lint Skipped
Unit
Unit Tests Skipped

Event Timeline

pulkit added a subscriber: pulkit.Aug 19 2019, 11:10 AM
pulkit added inline comments.
mercurial/shelve.py
754

we should write both the versions, _writerecords() should be used.

mercurial/shelve.py
754

i had tried to support it earlier. but, it throws the following error. i think it's okay to use the latest format only since, we haven't stored any mergestate using the previous format. the repo won't get corrupted.

+  Traceback (most recent call last):
+    File "/tmp/hgtests.TEheee/install/bin/hg", line 43, in <module>
+      dispatch.run()
+    File "/tmp/hgtests.TEheee/install/lib/python/mercurial/dispatch.py", line 99, in run
+      status = dispatch(req)
+    File "/tmp/hgtests.TEheee/install/lib/python/mercurial/dispatch.py", line 225, in dispatch
+      ret = _runcatch(req) or 0
+    File "/tmp/hgtests.TEheee/install/lib/python/mercurial/dispatch.py", line 376, in _runcatch
+      return _callcatch(ui, _runcatchfunc)
+    File "/tmp/hgtests.TEheee/install/lib/python/mercurial/dispatch.py", line 384, in _callcatch
+      return scmutil.callcatch(ui, func)
+    File "/tmp/hgtests.TEheee/install/lib/python/mercurial/scmutil.py", line 167, in callcatch
+      return func()
+    File "/tmp/hgtests.TEheee/install/lib/python/mercurial/dispatch.py", line 367, in _runcatchfunc
+      return _dispatch(req)
+    File "/tmp/hgtests.TEheee/install/lib/python/mercurial/dispatch.py", line 1021, in _dispatch
+      cmdpats, cmdoptions)
+    File "/tmp/hgtests.TEheee/install/lib/python/mercurial/dispatch.py", line 756, in runcommand
+      ret = _runcommand(ui, options, cmd, d)
+    File "/tmp/hgtests.TEheee/install/lib/python/mercurial/dispatch.py", line 1030, in _runcommand
+      return cmdfunc()
+    File "/tmp/hgtests.TEheee/install/lib/python/mercurial/dispatch.py", line 1018, in <lambda>
+      d = lambda: util.checksignature(func)(ui, *args, **strcmdopt)
+    File "/tmp/hgtests.TEheee/install/lib/python/mercurial/util.py", line 1682, in check
+      return func(*args, **kwargs)
+    File "/tmp/hgtests.TEheee/install/lib/python/mercurial/commands.py", line 6229, in unshelve
+      return shelvemod.dounshelve(ui, repo, *shelved, **opts)
+    File "/tmp/hgtests.TEheee/install/lib/python/mercurial/shelve.py", line 1090, in dounshelve
+      restoreunresolvedshelve(ui, repo, shelvectx, basename)
+    File "/tmp/hgtests.TEheee/install/lib/python/mercurial/shelve.py", line 754, in restoreunresolvedshelve
+      ms._writerecords(_decodemergerecords(records))
+    File "/tmp/hgtests.TEheee/install/lib/python/mercurial/merge.py", line 452, in _writerecords
+      self._writerecordsv1(records)
+    File "/tmp/hgtests.TEheee/install/lib/python/mercurial/merge.py", line 460, in _writerecordsv1
+      assert lrecords[0] == RECORD_LOCAL
+  AssertionError
+  [1]
pulkit added inline comments.Sun, Aug 25, 10:25 AM
mercurial/shelve.py
754

Then we are somehow parsing or building the records in not correct way.

pulkit added inline comments.Thu, Sep 12, 1:47 AM
mercurial/shelve.py
754

Did you manage to find why that error comes up?