changeset 42733:d684449eef67

unshelve: forget unknown files after a partial unshelve This is a follow-up patch to 6957f7b93e03. This allows hg to forget unknown files after a partial unshelve. Differential Revision: https://phab.mercurial-scm.org/D6724
author Navaneeth Suresh <navaneeths1998@gmail.com>
date Tue, 13 Aug 2019 22:48:05 +0530
parents 6d61be152c55
children 7013c7ce987f
files mercurial/shelve.py tests/test-shelve.t
diffstat 2 files changed, 24 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/shelve.py	Thu Aug 08 01:59:43 2019 +0200
+++ b/mercurial/shelve.py	Tue Aug 13 22:48:05 2019 +0530
@@ -1005,8 +1005,8 @@
         restorebranch(ui, repo, branchtorestore)
         shelvedstate.clear(repo)
         _finishunshelve(repo, oldtiprev, tr, activebookmark)
+        _forgetunknownfiles(repo, shelvectx, addedbefore)
         if not ispartialunshelve:
-            _forgetunknownfiles(repo, shelvectx, addedbefore)
             unshelvecleanup(ui, repo, basename, opts)
     finally:
         if tr:
--- a/tests/test-shelve.t	Thu Aug 08 01:59:43 2019 +0200
+++ b/tests/test-shelve.t	Tue Aug 13 22:48:05 2019 +0530
@@ -1272,15 +1272,21 @@
   > B
   > C
   > EOF
-  $ hg shelve
+  $ echo > garbage
+  $ hg st
+  M foo
+  ? garbage
+  $ hg shelve --unknown
   shelved as default
-  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  1 files updated, 0 files merged, 1 files removed, 0 files unresolved
   $ cat foo
   B
   $ hg unshelve -i <<EOF
   > y
   > y
   > n
+  > y
+  > y
   > EOF
   unshelving change 'default'
   rebasing shelved changes
@@ -1292,15 +1298,28 @@
   @@ -1,1 +1,2 @@
   +A
    B
-  record change 1/2 to 'foo'?
+  record change 1/3 to 'foo'?
   (enter ? for help) [Ynesfdaq?] y
   
   @@ -1,1 +2,2 @@
    B
   +C
-  record change 2/2 to 'foo'?
+  record change 2/3 to 'foo'?
   (enter ? for help) [Ynesfdaq?] n
   
+  diff --git a/garbage b/garbage
+  new file mode 100644
+  examine changes to 'garbage'?
+  (enter ? for help) [Ynesfdaq?] y
+  
+  @@ -0,0 +1,1 @@
+  +
+  record change 3/3 to 'garbage'?
+  (enter ? for help) [Ynesfdaq?] y
+  
+  $ hg st
+  M foo
+  ? garbage
   $ cat foo
   A
   B