windows: add doctest for shellquote()
authorMatt Harbison <matt_harbison@yahoo.com>
Fri, 01 May 2015 20:17:00 -0400
changeset 24908 30b910fea244
parent 24907 9570587b6986
child 24909 d71492ca2fdd
windows: add doctest for shellquote() This is actual test coverage for issue4629. The test changes in eea3977e6fca were simply the addition of quotes to the output, not ensuring that strings with backslashes are quoted.
mercurial/windows.py
--- a/mercurial/windows.py	Sat Apr 25 21:42:07 2015 +0900
+++ b/mercurial/windows.py	Fri May 01 20:17:00 2015 -0400
@@ -162,6 +162,18 @@
 _quotere = None
 _needsshellquote = None
 def shellquote(s):
+    r"""
+    >>> shellquote(r'C:\Users\xyz')
+    '"C:\\Users\\xyz"'
+    >>> shellquote(r'C:\Users\xyz/mixed')
+    '"C:\\Users\\xyz/mixed"'
+    >>> # Would be safe not to quote too, since it is all double backslashes
+    >>> shellquote(r'C:\\Users\\xyz')
+    '"C:\\\\Users\\\\xyz"'
+    >>> # But this must be quoted
+    >>> shellquote(r'C:\\Users\\xyz/abc')
+    '"C:\\\\Users\\\\xyz/abc"'
+    """
     global _quotere
     if _quotere is None:
         _quotere = re.compile(r'(\\*)("|\\$)')