From patchwork Fri Jun 9 05:29:52 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: match: allow pats to be None From: via Mercurial-devel X-Patchwork-Id: 21269 Message-Id: <6f66d0e87e1fe4d444cc.1496986192@martinvonz.svl.corp.google.com> To: mercurial-devel@mercurial-scm.org Date: Thu, 08 Jun 2017 22:29:52 -0700 # HG changeset patch # User Martin von Zweigbergk # Date 1496985497 25200 # Thu Jun 08 22:18:17 2017 -0700 # Node ID 6f66d0e87e1fe4d444ccc4e2df4a2b3597a40afc # Parent 04c19c8082410049465e2cdc510e24801530c94b match: allow pats to be None match.match already interprets "!bool(patterns)" as matching everything (but includes and excludes still apply). We might as well allow None, which lets us simplify some callers a bit. I originally wrote this patch while trying to change match.match(patterns=[]) to mean to match no patterns. This patch is one step towards that goal. I'm not sure it'll be worth the effort to go all the way there, but I think this patch still makes sense on its own. diff --git a/mercurial/context.py b/mercurial/context.py --- a/mercurial/context.py +++ b/mercurial/context.py @@ -301,8 +301,6 @@ def match(self, pats=None, include=None, exclude=None, default='glob', listsubrepos=False, badfn=None): - if pats is None: - pats = [] r = self._repo return matchmod.match(r.root, r.getcwd(), pats, include, exclude, default, @@ -1701,8 +1699,6 @@ def match(self, pats=None, include=None, exclude=None, default='glob', listsubrepos=False, badfn=None): - if pats is None: - pats = [] r = self._repo # Only a case insensitive filesystem needs magic to translate user input diff --git a/mercurial/match.py b/mercurial/match.py --- a/mercurial/match.py +++ b/mercurial/match.py @@ -85,7 +85,7 @@ return False return True -def match(root, cwd, patterns, include=None, exclude=None, default='glob', +def match(root, cwd, patterns=None, include=None, exclude=None, default='glob', exact=False, auditor=None, ctx=None, listsubrepos=False, warn=None, badfn=None, icasefs=False): """build an object to match a set of file patterns