[PATCH 1 of 2] shelve: add tests to ensure illegal shelve names are avoided

Pulkit Goyal 7895pulkit at gmail.com
Thu Dec 22 13:51:44 EST 2016


# HG changeset patch
# User Pulkit Goyal <7895pulkit at gmail.com>
# Date 1482429452 -19800
#      Thu Dec 22 23:27:32 2016 +0530
# Node ID 04e469e02e98727d43175b621b675404a4aa0013
# Parent  681d2b64c89648c395c2af97062c94d1238c510d
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

diff -r 681d2b64c896 -r 04e469e02e98 tests/test-shelve.t
--- 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


More information about the Mercurial-devel mailing list