[PATCH 2 of 4] revset: remove showwarning option from expandaliases()

Yuya Nishihara yuya at tcha.org
Mon Sep 12 09:36:37 EDT 2016


# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1473342250 -32400
#      Thu Sep 08 22:44:10 2016 +0900
# Node ID 3212fdc92ea2f9754fc0ad79e1fd19e3968c9e1d
# Parent  95164dd92394e896eaf0632997ee1c187712c8de
revset: remove showwarning option from expandaliases()

Now all callers pass showwarning=ui.warn, so we no longer need the option to
suppress warnings.

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -3525,8 +3525,7 @@ def debugrevspec(ui, repo, expr, **opts)
     """
     stages = [
         ('parsed', lambda tree: tree),
-        ('expanded',
-         lambda tree: revset.expandaliases(ui, tree, showwarning=ui.warn)),
+        ('expanded', lambda tree: revset.expandaliases(ui, tree)),
         ('concatenated', revset.foldconcat),
         ('analyzed', revset.analyze),
         ('optimized', revset.optimize),
diff --git a/mercurial/revset.py b/mercurial/revset.py
--- a/mercurial/revset.py
+++ b/mercurial/revset.py
@@ -2556,15 +2556,14 @@ class _aliasrules(parser.basealiasrules)
         if tree[0] == 'func' and tree[1][0] == 'symbol':
             return tree[1][1], getlist(tree[2])
 
-def expandaliases(ui, tree, showwarning=None):
+def expandaliases(ui, tree):
     aliases = _aliasrules.buildmap(ui.configitems('revsetalias'))
     tree = _aliasrules.expand(aliases, tree)
-    if showwarning:
-        # warn about problematic (but not referred) aliases
-        for name, alias in sorted(aliases.iteritems()):
-            if alias.error and not alias.warned:
-                showwarning(_('warning: %s\n') % (alias.error))
-                alias.warned = True
+    # warn about problematic (but not referred) aliases
+    for name, alias in sorted(aliases.iteritems()):
+        if alias.error and not alias.warned:
+            ui.warn(_('warning: %s\n') % (alias.error))
+            alias.warned = True
     return tree
 
 def foldconcat(tree):
@@ -2617,7 +2616,7 @@ def matchany(ui, specs, repo=None):
         tree = ('or',) + tuple(parse(s, lookup) for s in specs)
 
     if ui:
-        tree = expandaliases(ui, tree, showwarning=ui.warn)
+        tree = expandaliases(ui, tree)
     tree = foldconcat(tree)
     tree = analyze(tree)
     tree = optimize(tree)


More information about the Mercurial-devel mailing list