revset: inline _getaliasarg() function
authorYuya Nishihara <yuya@tcha.org>
Sun, 14 Feb 2016 20:43:30 +0900
changeset 28691 a04baf9c063b
parent 28690 b56bf98c8afb
child 28692 6b3b958daf03
revset: inline _getaliasarg() function This function is now much simpler than before. Inlining small functions helps to extract a reusable alias processor.
mercurial/revset.py
--- a/mercurial/revset.py	Sun Feb 14 20:27:08 2016 +0900
+++ b/mercurial/revset.py	Sun Feb 14 20:43:30 2016 +0900
@@ -2261,12 +2261,6 @@
         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 @@
     """
     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):