Patchwork [4,of,5] revset: inline _getaliasarg() function

login
register
mail settings
Submitter Yuya Nishihara
Date March 29, 2016, 3:27 p.m.
Message ID <092c90f4dad4e4e58704.1459265269@mimosa>
Download mbox | patch
Permalink /patch/14142/
State Accepted
Headers show

Comments

Yuya Nishihara - March 29, 2016, 3:27 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1455450210 -32400
#      Sun Feb 14 20:43:30 2016 +0900
# Node ID 092c90f4dad4e4e5870499819d4c0a2f4646e8fd
# Parent  e89acb348d532903e002bf834609472f9a50bdfb
revset: inline _getaliasarg() function

This function is now much simpler than before. Inlining small functions helps
to extract a reusable alias processor.

Patch

diff --git a/mercurial/revset.py b/mercurial/revset.py
--- a/mercurial/revset.py
+++ b/mercurial/revset.py
@@ -2261,12 +2261,6 @@  def optimize(x, small):
         return w + wa, (op, x[1], ta)
     return 1, x
 
-def _getaliasarg(tree):
-    """If tree matches ('_aliasarg', X) return X, None otherwise"""
-    if tree[0] == '_aliasarg':
-        return tree[1]
-    return None
-
 # the set of valid characters for the initial letter of symbols in
 # alias declarations and definitions
 _aliassyminitletters = set(c for c in [chr(i) for i in xrange(256)]
@@ -2460,9 +2454,9 @@  def _expandargs(tree, args):
     """
     if not tree or not isinstance(tree, tuple):
         return tree
-    arg = _getaliasarg(tree)
-    if arg is not None:
-        return args[arg]
+    if tree[0] == '_aliasarg':
+        sym = tree[1]
+        return args[sym]
     return tuple(_expandargs(t, args) for t in tree)
 
 def _expandaliases(aliases, tree, expanding, cache):