From patchwork Thu Mar 23 15:11:38 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [5, of, 6, py3, v2] revsetlang: perform quoting using ui.escapestr instead of repr() From: Augie Fackler X-Patchwork-Id: 19609 Message-Id: <2190115dab97a551cd5a.1490281898@arthedain.pit.corp.google.com> To: mercurial-devel@mercurial-scm.org Date: Thu, 23 Mar 2017 11:11:38 -0400 # HG changeset patch # User Augie Fackler # Date 1490280410 14400 # Thu Mar 23 10:46:50 2017 -0400 # Node ID 2190115dab97a551cd5aac44a8a55e2df9fd6307 # Parent 6158a45eb9f22ee651f2677b420665788fcc72e2 revsetlang: perform quoting using ui.escapestr instead of repr() This changes one of the doctest results, but I'm pretty sure on inspection that it's an equivalent result. diff --git a/mercurial/revsetlang.py b/mercurial/revsetlang.py --- a/mercurial/revsetlang.py +++ b/mercurial/revsetlang.py @@ -15,6 +15,7 @@ from . import ( node, parser, pycompat, + util, ) elements = { @@ -581,11 +582,11 @@ def _quote(s): >>> _quote("asdf'\"") '\'asdf\\\'"\'' >>> _quote('asdf\'') - '"asdf\'"' + "'asdf\\''" >>> _quote(1) "'1'" """ - return repr(str(s)) + return "'%s'" % util.escapestr('%s' % s) def formatspec(expr, *args): '''