##// END OF EJS Templates
match: change all users of util.matcher to match.match
Matt Mackall -
r8566:744d6322 default
parent child Browse files
Show More
@@ -46,7 +46,7 b''
46 # ** = user6
46 # ** = user6
47
47
48 from mercurial.i18n import _
48 from mercurial.i18n import _
49 from mercurial import util
49 from mercurial import util, match
50 import getpass
50 import getpass
51
51
52 def buildmatch(ui, repo, user, key):
52 def buildmatch(ui, repo, user, key):
@@ -60,8 +60,9 b' def buildmatch(ui, repo, user, key):'
60 ui.debug(_('acl: %s enabled, %d entries for user %s\n') %
60 ui.debug(_('acl: %s enabled, %d entries for user %s\n') %
61 (key, len(pats), user))
61 (key, len(pats), user))
62 if pats:
62 if pats:
63 return util.matcher(repo.root, names=pats)[1]
63 return match.match(repo.root, '', pats, [], [], 'glob')
64 return util.never
64 return match.never(repo.root, '')
65
65
66
66 def hook(ui, repo, hooktype, node=None, source=None, **kwargs):
67 def hook(ui, repo, hooktype, node=None, source=None, **kwargs):
67 if hooktype != 'pretxnchangegroup':
68 if hooktype != 'pretxnchangegroup':
@@ -81,7 +81,7 b" like CVS' $Log$, are not supported. A ke"
81 '''
81 '''
82
82
83 from mercurial import commands, cmdutil, dispatch, filelog, revlog, extensions
83 from mercurial import commands, cmdutil, dispatch, filelog, revlog, extensions
84 from mercurial import patch, localrepo, templater, templatefilters, util
84 from mercurial import patch, localrepo, templater, templatefilters, util, match
85 from mercurial.hgweb import webcommands
85 from mercurial.hgweb import webcommands
86 from mercurial.lock import release
86 from mercurial.lock import release
87 from mercurial.node import nullid, hex
87 from mercurial.node import nullid, hex
@@ -125,8 +125,8 b' class kwtemplater(object):'
125 def __init__(self, ui, repo):
125 def __init__(self, ui, repo):
126 self.ui = ui
126 self.ui = ui
127 self.repo = repo
127 self.repo = repo
128 self.matcher = util.matcher(repo.root,
128 self.matcher = match.match(repo.root, '', [],
129 inc=kwtools['inc'], exc=kwtools['exc'])[1]
129 kwtools['inc'], kwtools['exc'], 'glob')
130 self.restrict = kwtools['hgcmd'] in restricted.split()
130 self.restrict = kwtools['hgcmd'] in restricted.split()
131
131
132 kwmaps = self.ui.configitems('keywordmaps')
132 kwmaps = self.ui.configitems('keywordmaps')
@@ -7,7 +7,7 b''
7
7
8 from node import short
8 from node import short
9 from i18n import _
9 from i18n import _
10 import util, simplemerge
10 import util, simplemerge, match
11 import os, tempfile, re, filecmp
11 import os, tempfile, re, filecmp
12
12
13 def _toolstr(ui, tool, part, default=""):
13 def _toolstr(ui, tool, part, default=""):
@@ -55,7 +55,7 b' def _picktool(repo, ui, path, binary, sy'
55
55
56 # then patterns
56 # then patterns
57 for pat, tool in ui.configitems("merge-patterns"):
57 for pat, tool in ui.configitems("merge-patterns"):
58 mf = util.matcher(repo.root, "", [pat], [], [])[1]
58 mf = match.match(repo.root, '', [pat], [], [], 'glob')
59 if mf(path) and check(tool, pat, symlink, False):
59 if mf(path) and check(tool, pat, symlink, False):
60 toolpath = _findtool(ui, tool)
60 toolpath = _findtool(ui, tool)
61 return (tool, '"' + toolpath + '"')
61 return (tool, '"' + toolpath + '"')
@@ -6,7 +6,7 b''
6 # GNU General Public License version 2, incorporated herein by reference.
6 # GNU General Public License version 2, incorporated herein by reference.
7
7
8 from i18n import _
8 from i18n import _
9 import util
9 import util, match
10 import re
10 import re
11
11
12 _commentre = None
12 _commentre = None
@@ -80,12 +80,13 b' def ignore(root, files, warn):'
80 return util.never
80 return util.never
81
81
82 try:
82 try:
83 files, ignorefunc, anypats = (
83 ignorefunc = match.match(root, '', [], allpats, [], 'glob')
84 util.matcher(root, inc=allpats, src='.hgignore'))
85 except util.Abort:
84 except util.Abort:
86 # Re-raise an exception where the src is the right file
85 # Re-raise an exception where the src is the right file
87 for f, patlist in pats.iteritems():
86 for f, patlist in pats.iteritems():
88 files, ignorefunc, anypats = (
87 try:
89 util.matcher(root, inc=patlist, src=f))
88 match.match(root, '', [], patlist, [], 'glob')
89 except util.Abort, inst:
90 raise util.Abort('%s: %s' % (f, inst[0]))
90
91
91 return ignorefunc
92 return ignorefunc
@@ -528,7 +528,7 b' class localrepository(repo.repository):'
528 for pat, cmd in self.ui.configitems(filter):
528 for pat, cmd in self.ui.configitems(filter):
529 if cmd == '!':
529 if cmd == '!':
530 continue
530 continue
531 mf = util.matcher(self.root, "", [pat], [], [])[1]
531 mf = match_.match(self.root, '', [pat], [], [], 'glob')
532 fn = None
532 fn = None
533 params = cmd
533 params = cmd
534 for name, filterfn in self._datafilters.iteritems():
534 for name, filterfn in self._datafilters.iteritems():
@@ -50,5 +50,5 b' class exact(_match):'
50 class match(_match):
50 class match(_match):
51 def __init__(self, root, cwd, patterns, include, exclude, default):
51 def __init__(self, root, cwd, patterns, include, exclude, default):
52 f, mf, ap = util.matcher(root, cwd, patterns, include, exclude,
52 f, mf, ap = util.matcher(root, cwd, patterns, include, exclude,
53 None, default)
53 default)
54 _match.__init__(self, root, cwd, f, mf, ap)
54 _match.__init__(self, root, cwd, f, mf, ap)
@@ -342,7 +342,7 b' def canonpath(root, cwd, myname):'
342
342
343 raise Abort('%s not under root' % myname)
343 raise Abort('%s not under root' % myname)
344
344
345 def matcher(canonroot, cwd='', names=[], inc=[], exc=[], src=None, dflt_pat='glob'):
345 def matcher(canonroot, cwd='', names=[], inc=[], exc=[], dflt_pat='glob'):
346 """build a function to match a set of file patterns
346 """build a function to match a set of file patterns
347
347
348 arguments:
348 arguments:
@@ -352,7 +352,6 b" def matcher(canonroot, cwd='', names=[],"
352 inc - patterns to include
352 inc - patterns to include
353 exc - patterns to exclude
353 exc - patterns to exclude
354 dflt_pat - if a pattern in names has no explicit type, assume this one
354 dflt_pat - if a pattern in names has no explicit type, assume this one
355 src - where these patterns came from (e.g. .hgignore)
356
355
357 a pattern is one of:
356 a pattern is one of:
358 'glob:<glob>' - a glob relative to cwd
357 'glob:<glob>' - a glob relative to cwd
@@ -422,10 +421,6 b" def matcher(canonroot, cwd='', names=[],"
422 try:
421 try:
423 re.compile('(?:%s)' % regex(k, p, tail))
422 re.compile('(?:%s)' % regex(k, p, tail))
424 except re.error:
423 except re.error:
425 if src:
426 raise Abort("%s: invalid pattern (%s): %s" %
427 (src, k, p))
428 else:
429 raise Abort("invalid pattern (%s): %s" % (k, p))
424 raise Abort("invalid pattern (%s): %s" % (k, p))
430 raise Abort("invalid pattern")
425 raise Abort("invalid pattern")
431
426
General Comments 0
You need to be logged in to leave comments. Login now