Patchwork D6724: unshelve: forget unknown files after a partial unshelve

login
register
mail settings
Submitter phabricator
Date Aug. 13, 2019, 5:21 p.m.
Message ID <differential-rev-PHID-DREV-phxcd5zfw3hnrnyiaj5t-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/41254/
State Superseded
Headers show

Comments

phabricator - Aug. 13, 2019, 5:21 p.m.
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 6957f7b93e03 <https://phab.mercurial-scm.org/rHG6957f7b93e034d881e84d0029e952ce6ebbdf38a>. This allows hg to forget
  unknown files after a partial unshelve.

REPOSITORY
  rHG Mercurial

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

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

CHANGE DETAILS




To: navaneeth.suresh, #hg-reviewers
Cc: mercurial-devel
phabricator - Aug. 13, 2019, 8:32 p.m.
This revision is now accepted and ready to land.
pulkit added inline comments.
pulkit accepted this revision.

INLINE COMMENTS

> shelve.py:1009
>          if not ispartialunshelve:
> -            _forgetunknownfiles(repo, shelvectx, addedbefore)
>              unshelvecleanup(ui, repo, basename, opts)
>      finally:

Can you add a comment here about why we don't perform `unshelvecleanup()` in the case of partial unshelve?

REPOSITORY
  rHG Mercurial

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

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

To: navaneeth.suresh, #hg-reviewers, pulkit
Cc: pulkit, 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
@@ -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
diff --git a/mercurial/shelve.py b/mercurial/shelve.py
--- a/mercurial/shelve.py
+++ b/mercurial/shelve.py
@@ -1004,8 +1004,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: