[PATCH 3 of 6] revset: narrow scope of "except ParseError" block in _parsealiasdecl()

Yuya Nishihara yuya at tcha.org
Fri Apr 1 11:37:09 EDT 2016


# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1456735419 -32400
#      Mon Feb 29 17:43:39 2016 +0900
# Node ID ae143c83b4c139422da83eab3c9c3ffb5825a6e8
# Parent  2cad9bec8edb7d4a2cd9e317a942d9098e1eda82
revset: narrow scope of "except ParseError" block in _parsealiasdecl()

This helps to factor out a common function. "if True" will be removed by
the next patch.

diff --git a/mercurial/revset.py b/mercurial/revset.py
--- a/mercurial/revset.py
+++ b/mercurial/revset.py
@@ -2283,7 +2283,10 @@ def _parsealiasdecl(decl):
         if (pos != len(decl)):
             raise error.ParseError(_('invalid token'), pos)
         tree = parser.simplifyinfixops(tree, ('list',))
-
+    except error.ParseError as inst:
+        return (decl, None, None, parser.parseerrordetail(inst))
+
+    if True:  # XXX to be removed
         if tree[0] == 'symbol':
             # "name = ...." style
             name = tree[1]
@@ -2307,8 +2310,6 @@ def _parsealiasdecl(decl):
             return (name, tree[:2], args, None)
 
         return (decl, None, None, _("invalid format"))
-    except error.ParseError as inst:
-        return (decl, None, None, parser.parseerrordetail(inst))
 
 def _relabelaliasargs(tree, args):
     if not isinstance(tree, tuple):


More information about the Mercurial-devel mailing list