shelve: directly handle the abort process
authorBoris Feld <boris.feld@octobus.net>
Mon, 28 May 2018 18:15:21 +0200
changeset 38466 61e4cf1be5b2
parent 38465 8459e8d2f729
child 38467 f4776f8b98e0
shelve: directly handle the abort process Shelve is currently sub-contracting some of its work to the rebase extension. In order to make shelve more independent and flexible we would like shelve to handle the parent alignment directly. This change starts with the simplest bits, handling the abort process. It turns out we have all the necessary bits in the `shelvestate` file. So we do not need anything from the interrupted rebase. As a nice side effect, a test about missing `shelverebasestate` state file now behave better. Differential Revision: https://phab.mercurial-scm.org/D3688
hgext/shelve.py
tests/test-shelve.t
--- a/hgext/shelve.py	Mon May 28 20:51:20 2018 +0200
+++ b/hgext/shelve.py	Mon May 28 18:15:21 2018 +0200
@@ -621,14 +621,14 @@
         try:
             checkparents(repo, state)
 
-            repo.vfs.rename('unshelverebasestate', 'rebasestate')
-            try:
-                rebase.rebase(ui, repo, **{
-                    r'abort' : True
-                })
-            except Exception:
-                repo.vfs.rename('rebasestate', 'unshelverebasestate')
-                raise
+            merge.update(repo, state.pendingctx, False, True)
+            if (state.activebookmark
+                    and state.activebookmark in repo._bookmarks):
+                bookmarks.activate(repo, state.activebookmark)
+
+            if repo.vfs.exists('unshelverebasestate'):
+                repo.vfs.rename('unshelverebasestate', 'rebasestate')
+                rebase.clearstatus(repo)
 
             mergefiles(ui, repo, state.wctx, state.pendingctx)
             repair.strip(ui, repo, state.nodestoremove, backup=False,
--- a/tests/test-shelve.t	Mon May 28 20:51:20 2018 +0200
+++ b/tests/test-shelve.t	Mon May 28 18:15:21 2018 +0200
@@ -406,7 +406,6 @@
   R b/b
   ? a/a.orig
   $ hg unshelve -a
-  rebase aborted
   unshelve of 'default' aborted
   $ hg heads -q
   3:2e69b451d1ea
@@ -817,7 +816,6 @@
   g
   $ hg unshelve --abort -t false
   tool option will be ignored
-  rebase aborted
   unshelve of 'default' aborted
   $ hg st
   M a
@@ -861,7 +859,6 @@
   $ cat f.orig
   g
   $ hg unshelve --abort
-  rebase aborted
   unshelve of 'default' aborted
   $ hg st
   ? f.orig
@@ -1271,14 +1268,8 @@
   $ rm .hg/unshelverebasestate
   $ hg unshelve --abort
   unshelve of 'default' aborted
-  abort: $ENOENT$* (glob)
-  [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 406ad6fb39eb -r e22bdf25c863 -q
   $ hg up -r 0 -q
   $ echo '' > root
   $ hg shelve -q
@@ -1290,7 +1281,6 @@
   $ sed 's/ae8c668541e8/123456789012/' .hg/shelvedstate > ../corrupt-shelvedstate
   $ mv ../corrupt-shelvedstate .hg/histedit-state
   $ hg unshelve --abort 2>&1 | grep 'aborted'
-  rebase aborted
   unshelve of 'default-01' aborted
   $ hg summary
   parent: 0:ae8c668541e8 tip