revsetlang: add docstring with some tests to _quote
authorAugie Fackler <augie@google.com>
Thu, 23 Mar 2017 10:41:34 -0400
changeset 31605 0b94c19b641c
parent 31604 7eac6fcf2ffa
child 31606 0b3eb280564b
revsetlang: add docstring with some tests to _quote
mercurial/revsetlang.py
--- a/mercurial/revsetlang.py	Sun Mar 19 01:14:19 2017 -0400
+++ b/mercurial/revsetlang.py	Thu Mar 23 10:41:34 2017 -0400
@@ -574,6 +574,17 @@
     return _parsewith(spec, lookup=lookup)
 
 def _quote(s):
+    r"""Quote a value in order to make it safe for the revset engine.
+
+    >>> _quote('asdf')
+    "'asdf'"
+    >>> _quote("asdf'\"")
+    '\'asdf\\\'"\''
+    >>> _quote('asdf\'')
+    '"asdf\'"'
+    >>> _quote(1)
+    "'1'"
+    """
     return repr(str(s))
 
 def formatspec(expr, *args):