shelve: add tests to ensure illegal shelve names are avoided
We avoid '.' as the first letter of shelve name so that we don't create hidden
file. We also avoid slashes in name so that we don't form a new directory
--- a/tests/test-shelve.t Tue Dec 20 00:20:07 2016 +0530
+++ b/tests/test-shelve.t Thu Dec 22 23:27:32 2016 +0530
@@ -100,6 +100,46 @@
default.hg
default.patch
+checks to make sure we dont create a directory or
+hidden file while choosing a new shelve name
+
+when we are given a name
+
+ $ hg shelve -n foo/bar
+ abort: shelved change names may not contain slashes
+ [255]
+ $ hg shelve -n .baz
+ abort: shelved change names may not start with '.'
+ [255]
+ $ hg shelve -n foo\\bar
+ abort: shelved change names may not contain slashes
+ [255]
+
+when shelve has to choose itself
+
+ $ hg branch x/y -q
+ $ hg commit -q -m "Branch commit 0"
+ $ hg shelve
+ nothing changed
+ [1]
+ $ hg branch .x -q
+ $ hg commit -q -m "Branch commit 1"
+ $ hg shelve
+ abort: shelved change names may not start with '.'
+ [255]
+ $ hg branch x\\y -q
+ $ hg commit -q -m "Branch commit 2"
+ $ hg shelve
+ abort: shelved change names may not contain slashes
+ [255]
+
+cleaning the branches made for name checking tests
+
+ $ hg up default -q
+ $ hg strip 3 -q
+ $ hg strip 2 -q
+ $ hg strip 1 -q
+
create an mq patch - shelving should work fine with a patch applied
$ echo n > n
@@ -128,15 +168,6 @@
c
R b/b
-prevent some foot-shooting
-
- $ hg shelve -n foo/bar
- abort: shelved change names may not contain slashes
- [255]
- $ hg shelve -n .baz
- abort: shelved change names may not start with '.'
- [255]
-
the common case - no options or filenames
$ hg shelve