Patchwork [04,of,25,RFC] shelve: directly handle the abort process

login
register
mail settings
Submitter Boris Feld
Date June 7, 2018, 2:11 p.m.
Message ID <d71e05a796d4a445136a.1528380663@Laptop-Boris.lan>
Download mbox | patch
Permalink /patch/31998/
State New
Headers show

Comments

Boris Feld - June 7, 2018, 2:11 p.m.
# HG changeset patch
# User Boris Feld <boris.feld@octobus.net>
# Date 1527524121 -7200
#      Mon May 28 18:15:21 2018 +0200
# Node ID d71e05a796d4a445136a9f62b6a57ab359fd1dee
# Parent  17031851e658c75dd019baecad04d122497eb697
# EXP-Topic graftshelve
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r d71e05a796d4
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

Patch

diff --git a/hgext/shelve.py b/hgext/shelve.py
--- a/hgext/shelve.py
+++ b/hgext/shelve.py
@@ -621,14 +621,14 @@  def unshelveabort(ui, repo, state, opts)
         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,
diff --git a/tests/test-shelve.t b/tests/test-shelve.t
--- a/tests/test-shelve.t
+++ b/tests/test-shelve.t
@@ -406,7 +406,6 @@  abort the unshelve and be happy
   R b/b
   ? a/a.orig
   $ hg unshelve -a
-  rebase aborted
   unshelve of 'default' aborted
   $ hg heads -q
   3:2e69b451d1ea
@@ -817,7 +816,6 @@  unshelve and conflicts with tracked and 
   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 @@  unshelve and conflicts with tracked and 
   $ cat f.orig
   g
   $ hg unshelve --abort
-  rebase aborted
   unshelve of 'default' aborted
   $ hg st
   ? f.orig
@@ -1271,14 +1268,8 @@  Wreak havoc on the unshelve process
   $ 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 @@  Try again but with a corrupted shelve st
   $ 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