shelve: fix broken backup of conflicting untracked file
authorMartin von Zweigbergk <martinvonz@google.com>
Mon, 04 Feb 2019 20:49:45 -0800
changeset 41596 630af04d4ae4
parent 41595 8785188d1915
child 41597 9e545c9a4dfe
shelve: fix broken backup of conflicting untracked file Differential Revision: https://phab.mercurial-scm.org/D5852
hgext/shelve.py
tests/test-shelve2.t
--- a/hgext/shelve.py	Mon Feb 04 20:46:33 2019 -0800
+++ b/hgext/shelve.py	Mon Feb 04 20:49:45 2019 -0800
@@ -679,7 +679,8 @@
         # revert will overwrite unknown files, so move them out of the way
         for file in repo.status(unknown=True).unknown:
             if file in files:
-                util.rename(file, scmutil.origpath(ui, repo, file))
+                util.rename(repo.wjoin(file),
+                            scmutil.backuppath(ui, repo, file))
         ui.pushbuffer(True)
         cmdutil.revert(ui, repo, shelvectx, repo.dirstate.parents(),
                        *pathtofiles(repo, files),
--- a/tests/test-shelve2.t	Mon Feb 04 20:46:33 2019 -0800
+++ b/tests/test-shelve2.t	Mon Feb 04 20:49:45 2019 -0800
@@ -139,21 +139,13 @@
   0 files updated, 0 files merged, 2 files removed, 0 files unresolved
   $ echo z > e
   $ mkdir dir
-BROKEN: should work the same as when not using --cwd
   $ hg unshelve --cwd dir
   unshelving change 'default'
-  abort: $ENOENT$
-  [255]
   $ rmdir dir
   $ cat e
+  e
+  $ cat e.orig
   z
-  $ test -f e.orig && cat e.orig
-  [1]
-restore broken state
-  $ touch d
-  $ echo e > e
-  $ hg add d e
-  $ hg shelve --delete default
 
 unshelve and conflicts with tracked and untracked files