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

login
register
mail settings
Submitter Yuya Nishihara
Date April 1, 2016, 3:37 p.m.
Message ID <ae143c83b4c139422da8.1459525029@mimosa>
Download mbox | patch
Permalink /patch/14224/
State Superseded
Commit f8182ab688a5b86ca2a469ed345adb0bec1d9864
Headers show

Comments

Yuya Nishihara - April 1, 2016, 3:37 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@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.

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