Patchwork [3,of,6,py3,v2] revsetlang: move quoting function to not be a closure

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

Comments

Augie Fackler - March 23, 2017, 3:11 p.m.
# HG changeset patch
# User Augie Fackler <augie@google.com>
# Date 1489900459 14400
#      Sun Mar 19 01:14:19 2017 -0400
# Node ID e0077b4e92e0d4d22afc6343c9c2182bc2912916
# Parent  28e859b6032c8c5c1b3186a5356f0e344575eb6b
revsetlang: move quoting function to not be a closure

I'm about to change the implementation here and I'd like to add some
doctests, which means this needs to not be hidden inside another
function.

Patch

diff --git a/mercurial/revsetlang.py b/mercurial/revsetlang.py
--- a/mercurial/revsetlang.py
+++ b/mercurial/revsetlang.py
@@ -573,6 +573,9 @@  def foldconcat(tree):
 def parse(spec, lookup=None):
     return _parsewith(spec, lookup=lookup)
 
+def _quote(s):
+    return repr(str(s))
+
 def formatspec(expr, *args):
     '''
     This is a convenience function for using revsets internally, and
@@ -606,21 +609,18 @@  def formatspec(expr, *args):
     "root(_list('a\\x00b\\x00c\\x00d'))"
     '''
 
-    def quote(s):
-        return repr(str(s))
-
     def argtype(c, arg):
         if c == 'd':
             return '%d' % int(arg)
         elif c == 's':
-            return quote(arg)
+            return _quote(arg)
         elif c == 'r':
             parse(arg) # make sure syntax errors are confined
             return '(%s)' % arg
         elif c == 'n':
-            return quote(node.hex(arg))
+            return _quote(node.hex(arg))
         elif c == 'b':
-            return quote(arg.branch())
+            return _quote(arg.branch())
 
     def listexp(s, t):
         l = len(s)