tests: add test showing crash when shelving ghosted rename target
authorMartin von Zweigbergk <martinvonz@google.com>
Wed, 29 Jan 2020 23:05:02 -0800
changeset 44209 ae4d729eb3c8
parent 44207 e960c30d7e50
child 44210 d0c3eead515a
tests: add test showing crash when shelving ghosted rename target When you `hg rename` a file and then delete the rename target, `hg shelve` will give you a traceback. Note that the shelve succeeds and the shelve is correct, it's just the update to the parent that fails (i.e. to the parent of the commit that was created for the shelve). This can be squashed into the next commit if the reviewer prefers. Differential Revision: https://phab.mercurial-scm.org/D8045
tests/test-shelve.t
--- a/tests/test-shelve.t	Tue Oct 22 16:04:34 2019 +0900
+++ b/tests/test-shelve.t	Wed Jan 29 23:05:02 2020 -0800
@@ -171,6 +171,8 @@
   $ hg mv b b.rename
   moving b/b to b.rename/b
   $ hg cp c c.copy
+  $ hg mv d ghost
+  $ rm ghost
   $ hg status -C
   M a/a
   A b.rename/b
@@ -178,12 +180,20 @@
   A c.copy
     c
   R b/b
+  R d
+  ! ghost
+    d
 
 the common case - no options or filenames
 
-  $ hg shelve
-  shelved as default-01
-  2 files updated, 0 files merged, 2 files removed, 0 files unresolved
+  $ hg shelve 2>&1 | grep KeyError
+  KeyError: 'No such manifest entry.' (no-pure !)
+      raise KeyError (pure !)
+  KeyError (pure !)
+# Get out of the broken state so later tests work
+  $ hg forget b.rename/b c.copy ghost
+  $ hg revert a/a b/b d
+  $ rm a/a.orig b.rename/b c.copy
   $ hg status -C
 
 ensure that our shelved changes exist
@@ -254,6 +264,7 @@
   A c.copy
     c
   R b/b
+  R d
   $ hg shelve -l
 
 (both of default.hg and default-1.hg should be still kept, because it
@@ -287,6 +298,7 @@
   A c.copy
     c
   R b/b
+  R d
   $ HGEDITOR=cat hg shelve -q -n wibble -m wat -e a
   wat
   
@@ -306,6 +318,7 @@
   A c.copy
     c
   R b/b
+  R d
   $ hg shelve -l --stat
   wibble          (*)    wat (glob)
    a/a |  1 +
@@ -323,6 +336,7 @@
   A c.copy
     c
   R b/b
+  R d
 
 ensure old shelve backups are being deleted automatically
 
@@ -363,6 +377,7 @@
   M b.rename/b
   M c.copy
   R b/b
+  R d
   ? a/a.orig
   # The repository is in an unfinished *unshelve* state.
   
@@ -381,10 +396,10 @@
 #if phasebased
   $ hg heads -q --template '{rev}\n'
   8
-  5
+  6
   $ hg parents -q --template '{rev}\n'
   8
-  5
+  6
 #endif
 
 #if stripbased
@@ -401,6 +416,7 @@
   M b.rename/b
   M c.copy
   R b/b
+  R d
   ? a/a.orig
   $ hg diff
   diff --git a/a/a b/a/a
@@ -412,13 +428,19 @@
    c
   +=======
   +a
-  +>>>>>>> working-copy: a68ec3400638 - shelve: changes to: [mq]: second.patch
+  +>>>>>>> working-copy: 203c9f771d2b - shelve: changes to: [mq]: second.patch
   diff --git a/b/b b/b.rename/b
   rename from b/b
   rename to b.rename/b
   diff --git a/c b/c.copy
   copy from c
   copy to c.copy
+  diff --git a/d b/d
+  deleted file mode 100644
+  --- a/d
+  +++ /dev/null
+  @@ -1,1 +0,0 @@
+  -d
   $ hg resolve -l
   U a/a
 
@@ -434,6 +456,7 @@
   M b.rename/b
   M c.copy
   R b/b
+  R d
   ? a/a.orig
   $ hg unshelve -a
   unshelve of 'default' aborted
@@ -512,6 +535,7 @@
     c
   A foo/foo
   R b/b
+  R d
   ? a/a.orig
 
 there should be no shelves left