# HG changeset patch # User Yuya Nishihara # Date 2018-06-09 12:13:24 # 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 --git a/mercurial/match.py b/mercurial/match.py --- a/mercurial/match.py +++ b/mercurial/match.py @@ -375,6 +375,20 @@ class nevermatcher(basematcher): 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,