# HG changeset patch # User Yuya Nishihara # Date 1528546404 -32400 # Node ID 76838305b9dd2ed2d0e9f4feb94ca68c39456b28 # Parent a3130208db1cff69cdd9133780963595fc6c5a9e match: add basic wrapper for boolean function This serves as a generic wrapper for fileset predicates. In future patches, a fileset expression will be mapped to a tree of matchers for a better support of match attributes such as visitdir(). For example, $ hg debugwalk -v 'set:contrib/** and binary()' * matcher: , m2=> ... diff -r a3130208db1c -r 76838305b9dd mercurial/match.py --- a/mercurial/match.py Sun Jun 10 17:19:31 2018 +0900 +++ b/mercurial/match.py Sat Jun 09 21:13:24 2018 +0900 @@ -375,6 +375,20 @@ def __repr__(self): return r'' +class predicatematcher(basematcher): + """A matcher adapter for a simple boolean function""" + + def __init__(self, root, cwd, predfn, predrepr=None, badfn=None): + super(predicatematcher, self).__init__(root, cwd, badfn) + self.matchfn = predfn + self._predrepr = predrepr + + @encoding.strmethod + def __repr__(self): + s = (stringutil.buildrepr(self._predrepr) + or pycompat.byterepr(self.matchfn)) + return '' % s + class patternmatcher(basematcher): def __init__(self, root, cwd, kindpats, ctx=None, listsubrepos=False,