Patchwork D6694: unshelve: fix bug on a partial unshelve with --continue

login
register
mail settings
Submitter phabricator
Date July 25, 2019, 4:33 p.m.
Message ID <differential-rev-PHID-DREV-sr4gl6m5umuc3tqdkjw2-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/41071/
State Superseded
Headers show

Comments

phabricator - July 25, 2019, 4:33 p.m.
navaneeth.suresh created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  `unshelve --continue` after a partial unshelve was not working
  before. This patch makes that to work.

REPOSITORY
  rHG Mercurial

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

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

CHANGE DETAILS




To: navaneeth.suresh, #hg-reviewers
Cc: mercurial-devel
phabricator - Aug. 1, 2019, 6:32 p.m.
This revision now requires changes to proceed.
durin42 added a comment.
durin42 requested changes to this revision.


  needs rebased

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6694/new/

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

To: navaneeth.suresh, #hg-reviewers, durin42
Cc: durin42, mercurial-devel
phabricator - Aug. 6, 2019, 12:02 p.m.
pulkit added inline comments.

INLINE COMMENTS

> test-shelve.t:1436
> +  $ hg shelve --list
> +  default-01      (1s ago)    changes to: add A to bars
> +  default         (1s ago)    changes to: add B to foo

These timing needs to be globbed.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6694/new/

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

To: navaneeth.suresh, #hg-reviewers, durin42, pulkit
Cc: durin42, mercurial-devel
phabricator - Aug. 6, 2019, 1:10 p.m.
pulkit added a comment.


  This fails to apply on tip of default. Can you rebase and resend?

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6694/new/

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

To: navaneeth.suresh, #hg-reviewers, durin42, pulkit
Cc: durin42, mercurial-devel
phabricator - Aug. 6, 2019, 3:50 p.m.
pulkit added inline comments.

INLINE COMMENTS

> test-shelve.t:1430
> +-- now, --continue should abort as the last unshelve was successful even
> +-- though it was partially done. it can be completed without --continue.
> +  $ hg unshelve --continue

the above sentence is confusing and maybe incorrect too.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6694/new/

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

To: navaneeth.suresh, #hg-reviewers, durin42, pulkit
Cc: durin42, mercurial-devel
phabricator - Aug. 6, 2019, 4:04 p.m.
navaneeth.suresh added inline comments.

INLINE COMMENTS

> pulkit wrote in test-shelve.t:1430
> the above sentence is confusing and maybe incorrect too.

okay, maybe i should remove it. doing that right away.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6694/new/

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

To: navaneeth.suresh, #hg-reviewers, durin42, pulkit
Cc: durin42, mercurial-devel

Patch

diff --git a/tests/test-shelve.t b/tests/test-shelve.t
--- a/tests/test-shelve.t
+++ b/tests/test-shelve.t
@@ -1355,7 +1355,7 @@ 
   > y
   > y
   > y
-  > y
+  > n
   > EOF
   diff --git a/bar1 b/bar1
   1 hunks, 1 lines changed
@@ -1379,6 +1379,23 @@ 
   +B
    C
   record change 2/2 to 'bar2'?
+  (enter ? for help) [Ynesfdaq?] n
+  
+  unshelve of 'default-01' complete
+  $ hg unshelve --continue <<EOF
+  > y
+  > y
+  > EOF
+  diff --git a/bar1 b/bar1
+  1 hunks, 1 lines changed
+  examine changes to 'bar1'?
+  (enter ? for help) [Ynesfdaq?] y
+  
+  @@ -1,2 +1,3 @@
+   A
+  +B
+   C
+  record this change to 'bar1'?
   (enter ? for help) [Ynesfdaq?] y
   
   unshelve of 'default-01' complete
diff --git a/mercurial/shelve.py b/mercurial/shelve.py
--- a/mercurial/shelve.py
+++ b/mercurial/shelve.py
@@ -753,6 +753,15 @@ 
                             topic='shelve')
             shelvedstate.clear(repo)
             unshelvecleanup(ui, repo, state.name, opts)
+        else:
+            # This is tricky. The function call might seems to be not useful.
+            # But, we do update state.parents here. Otherwise, checkparents()
+            # will fail.
+            shelvedstate.save(repo, basename, shelvectx.p1(),
+                              state.pendingctx, state.nodestoremove,
+                              state.branchtorestore, state.keep,
+                              state.activebookmark,
+                              interactive)
         _restoreactivebookmark(repo, state.activebookmark)
         ui.status(_("unshelve of '%s' complete\n") % state.name)
 
@@ -812,6 +821,12 @@ 
     bool to know whether the shelve is partly done or completely done.
     """
     opts['message'] = shelvectx.description()
+    if not opts['message']:
+        # On doing a parial unshelve with --continue interactive, the commit
+        # description is empty. To avoid aborting on that, we set a commit
+        # message.
+        opts['message'] = ('changes to: %s' %
+                           shelvectx.p1().description().split('\n', 1)[0])
     opts['interactive-unshelve'] = True
     pats = []
     if not interactive: