unshelve: store information about interactive mode in shelvedstate
authorNavaneeth Suresh <navaneeths1998@gmail.com>
Wed, 24 Jul 2019 00:44:12 +0530
changeset 42662 ee86ad6f50fe
parent 42658 d5cdce3d9164
child 42663 4b04244f2d5f
unshelve: store information about interactive mode in shelvedstate This is a follow-up patch to 5162753c4c14. This makes `unshelve` stores the information about interactive mode on conflicts. Differential Revision: https://phab.mercurial-scm.org/D6679
mercurial/shelve.py
tests/test-shelve.t
--- a/mercurial/shelve.py	Wed Jul 24 18:20:01 2019 +0530
+++ b/mercurial/shelve.py	Wed Jul 24 00:44:12 2019 +0530
@@ -177,6 +177,7 @@
     _nokeep = 'nokeep'
     # colon is essential to differentiate from a real bookmark name
     _noactivebook = ':no-active-bookmark'
+    _interactive = 'interactive'
 
     @classmethod
     def _verifyandtransform(cls, d):
@@ -247,6 +248,7 @@
             obj.activebookmark = ''
             if d.get('activebook', '') != cls._noactivebook:
                 obj.activebookmark = d.get('activebook', '')
+            obj.interactive = d.get('interactive') == cls._interactive
         except (error.RepoLookupError, KeyError) as err:
             raise error.CorruptedState(pycompat.bytestr(err))
 
@@ -254,7 +256,7 @@
 
     @classmethod
     def save(cls, repo, name, originalwctx, pendingctx, nodestoremove,
-             branchtorestore, keep=False, activebook=''):
+             branchtorestore, keep=False, activebook='', interactive=False):
         info = {
             "name": name,
             "originalwctx": nodemod.hex(originalwctx.node()),
@@ -267,6 +269,8 @@
             "keep": cls._keep if keep else cls._nokeep,
             "activebook": activebook or cls._noactivebook
         }
+        if interactive:
+            info['interactive'] = cls._interactive
         scmutil.simplekeyvaluefile(
             repo.vfs, cls._filename).write(info,
                                            firstline=("%d" % cls._version))
@@ -694,11 +698,12 @@
             if shfile.exists():
                 shfile.movetobackup()
         cleanupoldbackups(repo)
-def unshelvecontinue(ui, repo, state, opts, basename=None):
+def unshelvecontinue(ui, repo, state, opts):
     """subcommand to continue an in-progress unshelve"""
     # We're finishing off a merge. First parent is our original
     # parent, second is the temporary "fake" commit we're unshelving.
-    interactive = opts.get('interactive')
+    interactive = state.interactive
+    basename = state.name
     with repo.lock():
         checkparents(repo, state)
         ms = merge.mergestate.read(repo)
@@ -869,7 +874,8 @@
             nodestoremove = [repo.changelog.node(rev)
                              for rev in pycompat.xrange(oldtiprev, len(repo))]
             shelvedstate.save(repo, basename, pctx, tmpwctx, nodestoremove,
-                              branchtorestore, opts.get('keep'), activebookmark)
+                              branchtorestore, opts.get('keep'), activebookmark,
+                              interactive)
             raise error.InterventionRequired(
                 _("unresolved conflicts (see 'hg resolve', then "
                   "'hg unshelve --continue')"))
@@ -936,7 +942,7 @@
     if opts.get("name"):
         shelved.append(opts["name"])
 
-    if abortf or continuef and not interactive:
+    if abortf or continuef:
         if abortf and continuef:
             raise error.Abort(_('cannot use both abort and continue'))
         if shelved:
@@ -958,11 +964,8 @@
             raise error.Abort(_('no shelved changes to apply!'))
         basename = util.split(shelved[0][1])[1]
         ui.status(_("unshelving change '%s'\n") % basename)
-    elif shelved:
+    else:
         basename = shelved[0]
-    if continuef and interactive:
-        state = _loadshelvedstate(ui, repo, opts)
-        return unshelvecontinue(ui, repo, state, opts, basename)
 
     if not shelvedfile(repo, basename, patchextension).exists():
         raise error.Abort(_("shelved change '%s' not found") % basename)
--- a/tests/test-shelve.t	Wed Jul 24 18:20:01 2019 +0530
+++ b/tests/test-shelve.t	Wed Jul 24 00:44:12 2019 +0530
@@ -1351,13 +1351,12 @@
   A
   B
   C
-  $ hg unshelve --continue -i <<EOF
+  $ hg unshelve --continue <<EOF
   > y
   > y
   > y
   > y
   > EOF
-  unshelving change 'default-01'
   diff --git a/bar1 b/bar1
   1 hunks, 1 lines changed
   examine changes to 'bar1'?