changeset 8566:744d6322b05b

match: change all users of util.matcher to match.match
author Matt Mackall <mpm@selenic.com>
date Sun, 24 May 2009 02:56:14 -0500
parents 268d16b2ec25
children fea40a677d43
files hgext/acl.py hgext/keyword.py mercurial/filemerge.py mercurial/ignore.py mercurial/localrepo.py mercurial/match.py mercurial/util.py
diffstat 7 files changed, 19 insertions(+), 22 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/acl.py	Sat May 23 17:04:41 2009 +0200
+++ b/hgext/acl.py	Sun May 24 02:56:14 2009 -0500
@@ -46,7 +46,7 @@
 #   ** = user6
 
 from mercurial.i18n import _
-from mercurial import util
+from mercurial import util, match
 import getpass
 
 def buildmatch(ui, repo, user, key):
@@ -60,8 +60,9 @@
     ui.debug(_('acl: %s enabled, %d entries for user %s\n') %
              (key, len(pats), user))
     if pats:
-        return util.matcher(repo.root, names=pats)[1]
-    return util.never
+        return match.match(repo.root, '', pats, [], [], 'glob')
+    return match.never(repo.root, '')
+
 
 def hook(ui, repo, hooktype, node=None, source=None, **kwargs):
     if hooktype != 'pretxnchangegroup':
--- a/hgext/keyword.py	Sat May 23 17:04:41 2009 +0200
+++ b/hgext/keyword.py	Sun May 24 02:56:14 2009 -0500
@@ -81,7 +81,7 @@
 '''
 
 from mercurial import commands, cmdutil, dispatch, filelog, revlog, extensions
-from mercurial import patch, localrepo, templater, templatefilters, util
+from mercurial import patch, localrepo, templater, templatefilters, util, match
 from mercurial.hgweb import webcommands
 from mercurial.lock import release
 from mercurial.node import nullid, hex
@@ -125,8 +125,8 @@
     def __init__(self, ui, repo):
         self.ui = ui
         self.repo = repo
-        self.matcher = util.matcher(repo.root,
-                                    inc=kwtools['inc'], exc=kwtools['exc'])[1]
+        self.matcher = match.match(repo.root, '', [],
+                                   kwtools['inc'], kwtools['exc'], 'glob')
         self.restrict = kwtools['hgcmd'] in restricted.split()
 
         kwmaps = self.ui.configitems('keywordmaps')
--- a/mercurial/filemerge.py	Sat May 23 17:04:41 2009 +0200
+++ b/mercurial/filemerge.py	Sun May 24 02:56:14 2009 -0500
@@ -7,7 +7,7 @@
 
 from node import short
 from i18n import _
-import util, simplemerge
+import util, simplemerge, match
 import os, tempfile, re, filecmp
 
 def _toolstr(ui, tool, part, default=""):
@@ -55,7 +55,7 @@
 
     # then patterns
     for pat, tool in ui.configitems("merge-patterns"):
-        mf = util.matcher(repo.root, "", [pat], [], [])[1]
+        mf = match.match(repo.root, '', [pat], [], [], 'glob')
         if mf(path) and check(tool, pat, symlink, False):
                 toolpath = _findtool(ui, tool)
                 return (tool, '"' + toolpath + '"')
--- a/mercurial/ignore.py	Sat May 23 17:04:41 2009 +0200
+++ b/mercurial/ignore.py	Sun May 24 02:56:14 2009 -0500
@@ -6,7 +6,7 @@
 # GNU General Public License version 2, incorporated herein by reference.
 
 from i18n import _
-import util
+import util, match
 import re
 
 _commentre = None
@@ -80,12 +80,13 @@
         return util.never
 
     try:
-        files, ignorefunc, anypats = (
-            util.matcher(root, inc=allpats, src='.hgignore'))
+        ignorefunc = match.match(root, '', [], allpats, [], 'glob')
     except util.Abort:
         # Re-raise an exception where the src is the right file
         for f, patlist in pats.iteritems():
-            files, ignorefunc, anypats = (
-                util.matcher(root, inc=patlist, src=f))
+            try:
+                match.match(root, '', [], patlist, [], 'glob')
+            except util.Abort, inst:
+                raise util.Abort('%s: %s' % (f, inst[0]))
 
     return ignorefunc
--- a/mercurial/localrepo.py	Sat May 23 17:04:41 2009 +0200
+++ b/mercurial/localrepo.py	Sun May 24 02:56:14 2009 -0500
@@ -528,7 +528,7 @@
             for pat, cmd in self.ui.configitems(filter):
                 if cmd == '!':
                     continue
-                mf = util.matcher(self.root, "", [pat], [], [])[1]
+                mf = match_.match(self.root, '', [pat], [], [], 'glob')
                 fn = None
                 params = cmd
                 for name, filterfn in self._datafilters.iteritems():
--- a/mercurial/match.py	Sat May 23 17:04:41 2009 +0200
+++ b/mercurial/match.py	Sun May 24 02:56:14 2009 -0500
@@ -50,5 +50,5 @@
 class match(_match):
     def __init__(self, root, cwd, patterns, include, exclude, default):
         f, mf, ap = util.matcher(root, cwd, patterns, include, exclude,
-                                 None, default)
+                                 default)
         _match.__init__(self, root, cwd, f, mf, ap)
--- a/mercurial/util.py	Sat May 23 17:04:41 2009 +0200
+++ b/mercurial/util.py	Sun May 24 02:56:14 2009 -0500
@@ -342,7 +342,7 @@
 
         raise Abort('%s not under root' % myname)
 
-def matcher(canonroot, cwd='', names=[], inc=[], exc=[], src=None, dflt_pat='glob'):
+def matcher(canonroot, cwd='', names=[], inc=[], exc=[], dflt_pat='glob'):
     """build a function to match a set of file patterns
 
     arguments:
@@ -352,7 +352,6 @@
     inc - patterns to include
     exc - patterns to exclude
     dflt_pat - if a pattern in names has no explicit type, assume this one
-    src - where these patterns came from (e.g. .hgignore)
 
     a pattern is one of:
     'glob:<glob>' - a glob relative to cwd
@@ -422,11 +421,7 @@
                 try:
                     re.compile('(?:%s)' % regex(k, p, tail))
                 except re.error:
-                    if src:
-                        raise Abort("%s: invalid pattern (%s): %s" %
-                                    (src, k, p))
-                    else:
-                        raise Abort("invalid pattern (%s): %s" % (k, p))
+                    raise Abort("invalid pattern (%s): %s" % (k, p))
             raise Abort("invalid pattern")
 
     def globprefix(pat):