changeset 31610:0b94c19b641c

revsetlang: add docstring with some tests to _quote
author Augie Fackler <augie@google.com>
date Thu, 23 Mar 2017 10:41:34 -0400
parents 7eac6fcf2ffa
children 0b3eb280564b
files mercurial/revsetlang.py
diffstat 1 files changed, 11 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- 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):