changeset 6582:5acbdd3941c4

walk: remove remaining users of cmdutils.matchpats
author Matt Mackall <mpm@selenic.com>
date Mon, 12 May 2008 11:37:07 -0500
parents 1ae7cb678d24
children 3951e04ea989
files hgext/extdiff.py hgext/keyword.py hgext/mq.py hgext/purge.py mercurial/cmdutil.py mercurial/commands.py
diffstat 6 files changed, 23 insertions(+), 31 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/extdiff.py	Mon May 12 11:37:07 2008 -0500
+++ b/hgext/extdiff.py	Mon May 12 11:37:07 2008 -0500
@@ -121,9 +121,9 @@
     - 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
 
--- a/hgext/keyword.py	Mon May 12 11:37:07 2008 -0500
+++ b/hgext/keyword.py	Mon May 12 11:37:07 2008 -0500
@@ -255,8 +255,8 @@
     '''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'))
--- a/hgext/mq.py	Mon May 12 11:37:07 2008 -0500
+++ b/hgext/mq.py	Mon May 12 11:37:07 2008 -0500
@@ -320,9 +320,8 @@
 
     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 @@
         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 @@
 
             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
--- a/hgext/purge.py	Mon May 12 11:37:07 2008 -0500
+++ b/hgext/purge.py	Mon May 12 11:37:07 2008 -0500
@@ -85,8 +85,8 @@
     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)
--- a/mercurial/cmdutil.py	Mon May 12 11:37:07 2008 -0500
+++ b/mercurial/cmdutil.py	Mon May 12 11:37:07 2008 -0500
@@ -235,10 +235,6 @@
     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 @@
     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))
--- a/mercurial/commands.py	Mon May 12 11:37:07 2008 -0500
+++ b/mercurial/commands.py	Mon May 12 11:37:07 2008 -0500
@@ -959,9 +959,8 @@
     """
     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 @@
         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 @@
 
     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 @@
     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 @@
     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,