navaneeth.suresh created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  This is a follow-up patch to 5162753c4c14 
<https://phab.mercurial-scm.org/rHG5162753c4c14c143e6be011b89d6567b5ef50d66>. 
This makes `unshelve`
  stores the information about interactive mode on conflicts.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D6679

AFFECTED FILES
  mercurial/shelve.py
  tests/test-shelve.t

CHANGE DETAILS

diff --git a/tests/test-shelve.t b/tests/test-shelve.t
--- a/tests/test-shelve.t
+++ b/tests/test-shelve.t
@@ -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'?
diff --git a/mercurial/shelve.py b/mercurial/shelve.py
--- a/mercurial/shelve.py
+++ b/mercurial/shelve.py
@@ -177,6 +177,8 @@
     _nokeep = 'nokeep'
     # colon is essential to differentiate from a real bookmark name
     _noactivebook = ':no-active-bookmark'
+    _shelvedinteractively = 'shelvedinteractively'
+    _notshelvedinteractively = 'notshelvedinteractively'
 
     @classmethod
     def _verifyandtransform(cls, d):
@@ -247,6 +249,8 @@
             obj.activebookmark = ''
             if d.get('activebook', '') != cls._noactivebook:
                 obj.activebookmark = d.get('activebook', '')
+            obj.shelvedinteractively = (d.get('shelvedinteractively')
+                                         == cls._shelvedinteractively)
         except (error.RepoLookupError, KeyError) as err:
             raise error.CorruptedState(pycompat.bytestr(err))
 
@@ -254,7 +258,7 @@
 
     @classmethod
     def save(cls, repo, name, originalwctx, pendingctx, nodestoremove,
-             branchtorestore, keep=False, activebook=''):
+             branchtorestore, keep=False, activebook='', 
shelvedinteractively=False):
         info = {
             "name": name,
             "originalwctx": nodemod.hex(originalwctx.node()),
@@ -265,7 +269,9 @@
                                       for n in nodestoremove]),
             "branchtorestore": branchtorestore,
             "keep": cls._keep if keep else cls._nokeep,
-            "activebook": activebook or cls._noactivebook
+            "activebook": activebook or cls._noactivebook,
+            "shelvedinteractively": (cls._shelvedinteractively
+                    if shelvedinteractively else cls._notshelvedinteractively)
         }
         scmutil.simplekeyvaluefile(
             repo.vfs, cls._filename).write(info,
@@ -698,7 +704,7 @@
     """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.shelvedinteractively
     with repo.lock():
         checkparents(repo, state)
         ms = merge.mergestate.read(repo)
@@ -833,7 +839,7 @@
     """Rebase restored commit from its original location to a destination"""
     # If the shelve is not immediately on top of the commit
     # we'll be merging with, rebase it to be on top.
-    interactive = opts.get('interactive')
+    interactive = opts.get('interactive', False)
     if tmpwctx.node() == shelvectx.p1().node() and not interactive:
         # We won't skip on interactive mode because, the user might want to
         # unshelve certain changes only.
@@ -854,7 +860,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,
+                              shelvedinteractively=interactive)
             raise error.InterventionRequired(
                 _("unresolved conflicts (see 'hg resolve', then "
                   "'hg unshelve --continue')"))
@@ -928,10 +935,21 @@
     if opts.get("name"):
         shelved.append(opts["name"])
 
-    if abortf or continuef and not interactive:
+    if len(shelved) > 1:
+        raise error.Abort(_('can only unshelve one change at a time'))
+    elif not shelved:
+        shelved = listshelves(repo)
+        if not shelved:
+            raise error.Abort(_('no shelved changes to apply!'))
+        basename = util.split(shelved[0][1])[1]
+        if not (abortf or continuef):
+            ui.status(_("unshelving change '%s'\n") % basename)
+    elif shelved:
+        basename = shelved[0]
+    if abortf or continuef:
         if abortf and continuef:
             raise error.Abort(_('cannot use both abort and continue'))
-        if shelved:
+        if opts.get("name"):
             raise error.Abort(_('cannot combine abort/continue with '
                                'naming a shelved change'))
         if abortf and opts.get('tool', False):
@@ -941,20 +959,7 @@
         if abortf:
             return unshelveabort(ui, repo, state)
         elif continuef:
-            return unshelvecontinue(ui, repo, state, opts)
-    elif len(shelved) > 1:
-        raise error.Abort(_('can only unshelve one change at a time'))
-    elif not shelved:
-        shelved = listshelves(repo)
-        if not shelved:
-            raise error.Abort(_('no shelved changes to apply!'))
-        basename = util.split(shelved[0][1])[1]
-        ui.status(_("unshelving change '%s'\n") % basename)
-    elif shelved:
-        basename = shelved[0]
-    if continuef and interactive:
-        state = _loadshelvedstate(ui, repo, opts)
-        return unshelvecontinue(ui, repo, state, opts, basename)
+            return unshelvecontinue(ui, repo, state, opts, basename)
 
     if not shelvedfile(repo, basename, patchextension).exists():
         raise error.Abort(_("shelved change '%s' not found") % basename)



To: navaneeth.suresh, #hg-reviewers
Cc: mercurial-devel
_______________________________________________
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Reply via email to