Patchwork [4,of,6,py3,v2] revsetlang: add docstring with some tests to _quote

login
register
mail settings
Submitter Augie Fackler
Date March 23, 2017, 3:11 p.m.
Message ID <6158a45eb9f22ee651f2.1490281897@arthedain.pit.corp.google.com>
Download mbox | patch
Permalink /patch/19607/
State Accepted
Headers show

Comments

Augie Fackler - March 23, 2017, 3:11 p.m.
# HG changeset patch
# User Augie Fackler <augie@google.com>
# Date 1490280094 14400
#      Thu Mar 23 10:41:34 2017 -0400
# Node ID 6158a45eb9f22ee651f2677b420665788fcc72e2
# Parent  e0077b4e92e0d4d22afc6343c9c2182bc2912916
revsetlang: add docstring with some tests to _quote

Patch

diff --git a/mercurial/revsetlang.py b/mercurial/revsetlang.py
--- a/mercurial/revsetlang.py
+++ b/mercurial/revsetlang.py
@@ -574,6 +574,17 @@  def parse(spec, lookup=None):
     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):