[PATCH 2 of 2] fileset: don't suggest private or undocumented queries

Matt Harbison mharbison72 at gmail.com
Sat Jun 20 11:29:54 CDT 2015


# HG changeset patch
# User Matt Harbison <matt_harbison at yahoo.com>
# Date 1434812856 14400
#      Sat Jun 20 11:07:36 2015 -0400
# Node ID f40618068110937beebe1567447d19d7ccfb03df
# Parent  49a621c1776823f568a42cbe0e223c6b4418a36a
fileset: don't suggest private or undocumented queries

Unlike revsets, it looks like all of the filesets are documented, so there's
really nothing to test.  This is aimed more at parity with revsets and
future-proofing.

diff --git a/mercurial/fileset.py b/mercurial/fileset.py
--- a/mercurial/fileset.py
+++ b/mercurial/fileset.py
@@ -5,7 +5,7 @@
 # This software may be used and distributed according to the terms of the
 # GNU General Public License version 2 or any later version.
 
-import re
+import inspect, re, sys
 import parser, error, util, merge
 from i18n import _
 
@@ -189,7 +189,15 @@
 def func(mctx, a, b):
     if a[0] == 'symbol' and a[1] in symbols:
         return symbols[a[1]](mctx, b)
-    raise error.UnknownIdentifier(a[1], symbols.keys())
+
+    thismod = sys.modules[__name__]
+
+    def keep(obj):
+        return inspect.isfunction(obj) and obj.__doc__ is not None
+
+    public = [m[0] for m in inspect.getmembers(thismod, predicate=keep)]
+    syms = [s for s in symbols.keys() if s in public]
+    raise error.UnknownIdentifier(a[1], syms)
 
 def getlist(x):
     if not x:


More information about the Mercurial-devel mailing list