Patchwork [1,of,7,V3,RFC] revset: narrow scope of "except ParseError" block in _parsealiasdecl()

login
register
mail settings
Submitter Yuya Nishihara
Date April 3, 2016, 9:48 a.m.
Message ID <e2db714a290c5ae731b5.1459676895@mimosa>
Download mbox | patch
Permalink /patch/14276/
State Accepted
Delegated to: Pierre-Yves David
Headers show

Comments

Yuya Nishihara - April 3, 2016, 9:48 a.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1456735419 -32400
#      Mon Feb 29 17:43:39 2016 +0900
# Node ID e2db714a290c5ae731b542011a33961bd631968a
# Parent  56101c3d7302aab803c2d72f6ffbe4ee0df79e49
revset: narrow scope of "except ParseError" block in _parsealiasdecl()

This helps to factor out a common function. "if True" will be removed soon.

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):