diff --git a/hgext/extdiff.py b/hgext/extdiff.py --- a/hgext/extdiff.py +++ b/hgext/extdiff.py @@ -121,9 +121,9 @@ def dodiff(ui, repo, diffcmd, diffopts, - just invoke the diff for a single file in the working dir ''' node1, node2 = cmdutil.revpair(repo, opts['rev']) - files, matchfn, anypats = cmdutil.matchpats(repo, pats, opts) + matcher = cmdutil.match(repo, pats, opts) modified, added, removed, deleted, unknown = repo.status( - node1, node2, files, match=matchfn)[:5] + node1, node2, matcher.files(), match=matcher)[:5] if not (modified or added or removed): return 0 diff --git a/hgext/keyword.py b/hgext/keyword.py --- a/hgext/keyword.py +++ b/hgext/keyword.py @@ -255,8 +255,8 @@ def _status(ui, repo, kwt, *pats, **opts '''Bails out if [keyword] configuration is not active. Returns status of working directory.''' if kwt: - files, match, anypats = cmdutil.matchpats(repo, pats, opts) - return repo.status(files=files, match=match, list_clean=True) + matcher = cmdutil.match(repo, pats, opts) + return repo.status(files=matcher.files(), match=matcher, list_clean=True) if ui.configitems('keyword'): raise util.Abort(_('[keyword] patterns cannot match')) raise util.Abort(_('no [keyword] patterns configured')) diff --git a/hgext/mq.py b/hgext/mq.py --- a/hgext/mq.py +++ b/hgext/mq.py @@ -320,9 +320,8 @@ class queue: def printdiff(self, repo, node1, node2=None, files=None, fp=None, changes=None, opts={}): - fns, matchfn, anypats = cmdutil.matchpats(repo, files, opts) - - patch.diff(repo, node1, node2, fns, match=matchfn, + m = cmdutil.match(repo, files, opts) + patch.diff(repo, node1, node2, m.files(), match=m, fp=fp, changes=changes, opts=self.diffopts()) def mergeone(self, repo, mergeq, head, patch, rev): @@ -621,11 +620,11 @@ class queue: if os.path.exists(self.join(patch)): raise util.Abort(_('patch "%s" already exists') % patch) if opts.get('include') or opts.get('exclude') or pats: - fns, match, anypats = cmdutil.matchpats(repo, pats, opts) - m, a, r, d = repo.status(files=fns, match=match)[:4] + match = cmdutil.match(repo, pats, opts) + m, a, r, d = repo.status(files=match.files(), match=match)[:4] else: m, a, r, d = self.check_localchanges(repo, force) - fns, match, anypats = cmdutil.matchpats(repo, m + a + r) + match = cmdutil.match(repo, m + a + r) commitfiles = m + a + r self.check_toppatch(repo) wlock = repo.wlock() @@ -1024,7 +1023,7 @@ class queue: if opts.get('git'): self.diffopts().git = True - fns, matchfn, anypats = cmdutil.matchpats(repo, pats, opts) + matchfn = cmdutil.match(repo, pats, opts) tip = repo.changelog.tip() if top == tip: # if the top of our patch queue is also the tip, there is an diff --git a/hgext/purge.py b/hgext/purge.py --- a/hgext/purge.py +++ b/hgext/purge.py @@ -85,8 +85,8 @@ def purge(ui, repo, *dirs, **opts): directories = [] files = [] missing = [] - roots, match, anypats = cmdutil.matchpats(repo, dirs, opts) - for src, f, st in repo.dirstate.statwalk(roots, match, + match = cmdutil.match(repo, dirs, opts) + for src, f, st in repo.dirstate.statwalk(match.files(), match, ignored=ignored, directories=True): if src == 'd': directories.append(f) diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py --- a/mercurial/cmdutil.py +++ b/mercurial/cmdutil.py @@ -235,10 +235,6 @@ def match(repo, pats=[], opts={}, globbe m.bad = badfn return m -def matchpats(repo, pats=[], opts={}, globbed=False, default='relpath'): - m = match(repo, pats, opts, globbed, default) - return m.files(), m, m.anypats() - def walk(repo, match, node=None): for src, fn in repo.walk(node, match): yield src, fn, match.rel(fn), match.exact(fn) @@ -1182,6 +1178,6 @@ def commit(ui, repo, commitfunc, pats, o else: files = [] try: - return commitfunc(ui, repo, files, message, match, opts) + return commitfunc(ui, repo, files, message, m, opts) except ValueError, inst: raise util.Abort(str(inst)) diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -959,9 +959,8 @@ def diff(ui, repo, *pats, **opts): """ node1, node2 = cmdutil.revpair(repo, opts['rev']) - fns, matchfn, anypats = cmdutil.matchpats(repo, pats, opts) - - patch.diff(repo, node1, node2, fns, match=matchfn, + m = cmdutil.match(repo, pats, opts) + patch.diff(repo, node1, node2, m.files(), match=m, opts=patch.diffopts(ui, opts)) def export(ui, repo, *changesets, **opts): @@ -1958,10 +1957,10 @@ def parents(ui, repo, file_=None, **opts ctx = repo.workingctx() if file_: - files, match, anypats = cmdutil.matchpats(repo, (file_,), opts) - if anypats or len(files) != 1: + m = cmdutil.match(repo, (file_,), opts) + if m.anypats() or len(m.files()) != 1: raise util.Abort(_('can only specify an explicit file name')) - file_ = files[0] + file_ = m.files()[0] filenodes = [] for cp in ctx.parents(): if not cp: @@ -2130,7 +2129,7 @@ def rawcommit(ui, repo, *pats, **opts): message = cmdutil.logmessage(opts) - files, match, anypats = cmdutil.matchpats(repo, pats, opts) + files = cmdutil.match(repo, pats, opts).files() if opts['files']: files += open(opts['files']).read().splitlines() @@ -2182,12 +2181,11 @@ def remove(ui, repo, *pats, **opts): if not pats and not after: raise util.Abort(_('no files specified')) - files, matchfn, anypats = cmdutil.matchpats(repo, pats, opts) - mardu = map(dict.fromkeys, repo.status(files=files, match=matchfn))[:5] + m = cmdutil.match(repo, pats, opts) + mardu = map(dict.fromkeys, repo.status(files=m.files(), match=m))[:5] modified, added, removed, deleted, unknown = mardu remove, forget = [], [] - m = cmdutil.match(repo, pats, opts) for src, abs, rel, exact in cmdutil.walk(repo, m): reason = None @@ -2634,11 +2632,10 @@ def status(ui, repo, *pats, **opts): all = opts['all'] node1, node2 = cmdutil.revpair(repo, opts.get('rev')) - files, matchfn, anypats = cmdutil.matchpats(repo, pats, opts) + matcher = cmdutil.match(repo, pats, opts) cwd = (pats and repo.getcwd()) or '' modified, added, removed, deleted, unknown, ignored, clean = [ - n for n in repo.status(node1=node1, node2=node2, files=files, - match=matchfn, + n for n in repo.status(node1, node2, matcher.files(), matcher, list_ignored=opts['ignored'] or all and not ui.quiet, list_clean=opts['clean'] or all,