changeset 28720:639e0f1e8ffa

parser: move parsererrordetail() function from revset module This will be used by common alias functions introduced by future patches.
author Yuya Nishihara <yuya@tcha.org>
date Mon, 29 Feb 2016 17:02:56 +0900
parents dd2cf90a3731
children ff3be5a325bc
files mercurial/parser.py mercurial/revset.py
diffstat 2 files changed, 12 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/parser.py	Fri Apr 01 21:18:24 2016 +0800
+++ b/mercurial/parser.py	Mon Feb 29 17:02:56 2016 +0900
@@ -220,3 +220,11 @@
     simplified.append(simplifyinfixops(x, targetnodes))
     simplified.append(op)
     return tuple(reversed(simplified))
+
+def parseerrordetail(inst):
+    """Compose error message from specified ParseError object
+    """
+    if len(inst.args) > 1:
+        return _('at %s: %s') % (inst.args[1], inst.args[0])
+    else:
+        return inst.args[0]
--- a/mercurial/revset.py	Fri Apr 01 21:18:24 2016 +0800
+++ b/mercurial/revset.py	Mon Feb 29 17:02:56 2016 +0900
@@ -300,14 +300,6 @@
         pos += 1
     yield ('end', None, pos)
 
-def parseerrordetail(inst):
-    """Compose error message from specified ParseError object
-    """
-    if len(inst.args) > 1:
-        return _('at %s: %s') % (inst.args[1], inst.args[0])
-    else:
-        return inst.args[0]
-
 # helpers
 
 def getstring(x, err):
@@ -2312,7 +2304,7 @@
 
         return (decl, None, None, _("invalid format"))
     except error.ParseError as inst:
-        return (decl, None, None, parseerrordetail(inst))
+        return (decl, None, None, parser.parseerrordetail(inst))
 
 def _relabelaliasargs(tree, args):
     if not isinstance(tree, tuple):
@@ -2349,7 +2341,7 @@
     >>> try:
     ...     _parsealiasdefn('$1 or $bar', args)
     ... except error.ParseError, inst:
-    ...     print parseerrordetail(inst)
+    ...     print parser.parseerrordetail(inst)
     '$' not for alias arguments
     >>> args = ['$1', '$10', 'foo']
     >>> print prettyformat(_parsealiasdefn('$10 or foobar', args))
@@ -2394,7 +2386,8 @@
             self.replacement = _parsealiasdefn(value, self.args)
         except error.ParseError as inst:
             self.error = _('failed to parse the definition of revset alias'
-                           ' "%s": %s') % (self.name, parseerrordetail(inst))
+                           ' "%s": %s') % (self.name,
+                                           parser.parseerrordetail(inst))
 
 def _getalias(aliases, tree):
     """If tree looks like an unexpanded alias, return it. Return None