comparison mercurial/revsetlang.py @ 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
comparison
equal deleted inserted replaced
31609:7eac6fcf2ffa 31610:0b94c19b641c
572 572
573 def parse(spec, lookup=None): 573 def parse(spec, lookup=None):
574 return _parsewith(spec, lookup=lookup) 574 return _parsewith(spec, lookup=lookup)
575 575
576 def _quote(s): 576 def _quote(s):
577 r"""Quote a value in order to make it safe for the revset engine.
578
579 >>> _quote('asdf')
580 "'asdf'"
581 >>> _quote("asdf'\"")
582 '\'asdf\\\'"\''
583 >>> _quote('asdf\'')
584 '"asdf\'"'
585 >>> _quote(1)
586 "'1'"
587 """
577 return repr(str(s)) 588 return repr(str(s))
578 589
579 def formatspec(expr, *args): 590 def formatspec(expr, *args):
580 ''' 591 '''
581 This is a convenience function for using revsets internally, and 592 This is a convenience function for using revsets internally, and