match: remove files arg from repo.status and friends
authorMatt Mackall <mpm@selenic.com>
Mon, 12 May 2008 11:37:08 -0500
changeset 6603 41eb20cc1c02
parent 6602 a57a27b12965
child 6604 98b6e6f0e49b
match: remove files arg from repo.status and friends
hgext/extdiff.py
hgext/hgk.py
hgext/inotify/__init__.py
hgext/keyword.py
hgext/mq.py
hgext/purge.py
hgext/record.py
mercurial/cmdutil.py
mercurial/commands.py
mercurial/dirstate.py
mercurial/localrepo.py
mercurial/patch.py
tests/test-mq.out
--- a/hgext/extdiff.py	Mon May 12 11:37:08 2008 -0500
+++ b/hgext/extdiff.py	Mon May 12 11:37:08 2008 -0500
@@ -123,7 +123,7 @@
     node1, node2 = cmdutil.revpair(repo, opts['rev'])
     matcher = cmdutil.match(repo, pats, opts)
     modified, added, removed, deleted, unknown = repo.status(
-        node1, node2, matcher.files(), match=matcher)[:5]
+        node1, node2, matcher)[:5]
     if not (modified or added or removed):
         return 0
 
--- a/hgext/hgk.py	Mon May 12 11:37:08 2008 -0500
+++ b/hgext/hgk.py	Mon May 12 11:37:08 2008 -0500
@@ -56,7 +56,7 @@
         mmap = repo.changectx(node1).manifest()
         mmap2 = repo.changectx(node2).manifest()
         m = cmdutil.matchfiles(repo, files)
-        status = repo.status(node1, node2, files=m.files(), match=m)[:5]
+        status = repo.status(node1, node2, match=m)[:5]
         modified, added, removed, deleted, unknown = status
 
         empty = short(nullid)
--- a/hgext/inotify/__init__.py	Mon May 12 11:37:08 2008 -0500
+++ b/hgext/inotify/__init__.py	Mon May 12 11:37:08 2008 -0500
@@ -47,8 +47,9 @@
         # to recurse.
         inotifyserver = False
 
-        def status(self, files, match, list_ignored, list_clean,
+        def status(self, match, list_ignored, list_clean,
                    list_unknown=True):
+            files = match.files()
             try:
                 if not list_ignored and not self.inotifyserver:
                     result = client.query(ui, repo, files, match, False,
@@ -88,7 +89,7 @@
                             ui.print_exc()
 
             return super(inotifydirstate, self).status(
-                files, match or util.always, list_ignored, list_clean,
+                match, list_ignored, list_clean,
                 list_unknown)
 
     repo.dirstate.__class__ = inotifydirstate
--- a/hgext/keyword.py	Mon May 12 11:37:08 2008 -0500
+++ b/hgext/keyword.py	Mon May 12 11:37:08 2008 -0500
@@ -256,7 +256,7 @@
     Returns status of working directory.'''
     if kwt:
         matcher = cmdutil.match(repo, pats, opts)
-        return repo.status(files=matcher.files(), match=matcher, list_clean=True)
+        return repo.status(match=matcher, list_clean=True)
     if ui.configitems('keyword'):
         raise util.Abort(_('[keyword] patterns cannot match'))
     raise util.Abort(_('no [keyword] patterns configured'))
@@ -456,7 +456,7 @@
             return kwt.wread(filename, data)
 
         def commit(self, files=None, text='', user=None, date=None,
-                   match=util.always, force=False, force_editor=False,
+                   match=None, force=False, force_editor=False,
                    p1=None, p2=None, extra={}, empty_ok=False):
             wlock = lock = None
             _p1 = _p2 = None
--- a/hgext/mq.py	Mon May 12 11:37:08 2008 -0500
+++ b/hgext/mq.py	Mon May 12 11:37:08 2008 -0500
@@ -506,8 +506,10 @@
                     repo.dirstate.merge(f)
                 p1, p2 = repo.dirstate.parents()
                 repo.dirstate.setparents(p1, merge)
+
             files = patch.updatedir(self.ui, repo, files)
-            n = repo.commit(files, message, user, date, match=util.never,
+            match = cmdutil.matchfiles(repo, files or [])
+            n = repo.commit(files, message, user, date, match=match,
                             force=True)
 
             if n == None:
@@ -620,7 +622,7 @@
             raise util.Abort(_('patch "%s" already exists') % patch)
         if opts.get('include') or opts.get('exclude') or pats:
             match = cmdutil.match(repo, pats, opts)
-            m, a, r, d = repo.status(files=match.files(), match=match)[:4]
+            m, a, r, d = repo.status(match=match)[:4]
         else:
             m, a, r, d = self.check_localchanges(repo, force)
             match = cmdutil.match(repo, m + a + r)
@@ -1047,7 +1049,7 @@
                     match = cmdutil.matchfiles(repo, mm + aa + dd)
                 else:
                     match = cmdutil.matchall(repo)
-                m, a, r, d, u = repo.status(files=match.files(), match=match)[:5]
+                m, a, r, d, u = repo.status(match=match)[:5]
 
                 # we might end up with files that were added between
                 # tip and the dirstate parent, but then changed in the
--- a/hgext/purge.py	Mon May 12 11:37:08 2008 -0500
+++ b/hgext/purge.py	Mon May 12 11:37:08 2008 -0500
@@ -86,8 +86,7 @@
     files = []
     match = cmdutil.match(repo, dirs, opts)
     match.dir = directories.append
-    for src, f, st in repo.dirstate.statwalk(match.files(), match,
-                                             ignored=ignored):
+    for src, f, st in repo.dirstate.statwalk(match, ignored=ignored):
         if src == 'f' and f not in repo.dirstate:
             files.append(f)
 
--- a/hgext/record.py	Mon May 12 11:37:08 2008 -0500
+++ b/hgext/record.py	Mon May 12 11:37:08 2008 -0500
@@ -431,7 +431,7 @@
 
         if changes is None:
             match = cmdutil.matchfiles(repo, newfiles)
-            changes = repo.status(files=match.files(), match=match)[:5]
+            changes = repo.status(match=match)[:5]
         modified = dict.fromkeys(changes[0])
 
         # 2. backup changed files, so we can restore them in the end
--- a/mercurial/cmdutil.py	Mon May 12 11:37:08 2008 -0500
+++ b/mercurial/cmdutil.py	Mon May 12 11:37:08 2008 -0500
@@ -1153,7 +1153,7 @@
 
     m = match(repo, pats, opts)
     if pats:
-        status = repo.status(files=m.files(), match=m)
+        status = repo.status(match=m)
         modified, added, removed, deleted, unknown = status[:5]
         files = modified + added + removed
         slist = None
--- a/mercurial/commands.py	Mon May 12 11:37:08 2008 -0500
+++ b/mercurial/commands.py	Mon May 12 11:37:08 2008 -0500
@@ -2180,7 +2180,7 @@
         raise util.Abort(_('no files specified'))
 
     m = cmdutil.match(repo, pats, opts)
-    mardu = map(dict.fromkeys, repo.status(files=m.files(), match=m))[:5]
+    mardu = map(dict.fromkeys, repo.status(match=m))[:5]
     modified, added, removed, deleted, unknown = mardu
 
     remove, forget = [], []
@@ -2363,7 +2363,7 @@
                 names[abs] = m.rel(abs), m.exact(abs)
 
         m = cmdutil.matchfiles(repo, names)
-        changes = repo.status(files=m.files(), match=m)[:4]
+        changes = repo.status(match=m)[:4]
         modified, added, removed, deleted = map(dict.fromkeys, changes)
 
         # if f is a rename, also revert the source
@@ -2630,7 +2630,7 @@
     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, node2, matcher.files(), matcher,
+        n for n in repo.status(node1, node2, matcher,
                                list_ignored=opts['ignored']
                                             or all and not ui.quiet,
                                list_clean=opts['clean'] or all,
--- a/mercurial/dirstate.py	Mon May 12 11:37:08 2008 -0500
+++ b/mercurial/dirstate.py	Mon May 12 11:37:08 2008 -0500
@@ -418,10 +418,10 @@
 
     def walk(self, match):
         # filter out the src and stat
-        for src, f, st in self.statwalk(match.files(), match):
+        for src, f, st in self.statwalk(match):
             yield f
 
-    def statwalk(self, files, match, unknown=True, ignored=False):
+    def statwalk(self, match, unknown=True, ignored=False):
         '''
         walk recursively through the directory tree, finding all files
         matched by the match function
@@ -442,6 +442,7 @@
             badfn = match.bad
 
         # walk all files by default
+        files = match.files()
         if not files:
             files = ['.']
             dc = self._map.copy()
@@ -569,11 +570,10 @@
             if imatch(k):
                 yield 'm', k, None
 
-    def status(self, files, match, list_ignored, list_clean, list_unknown):
+    def status(self, match, list_ignored, list_clean, list_unknown):
         lookup, modified, added, unknown, ignored = [], [], [], [], []
         removed, deleted, clean = [], [], []
 
-        files = files or []
         _join = self._join
         lstat = os.lstat
         cmap = self._copymap
@@ -587,10 +587,10 @@
         dadd = deleted.append
         cadd = clean.append
 
-        for src, fn, st in self.statwalk(files, match, unknown=list_unknown,
+        for src, fn, st in self.statwalk(match, unknown=list_unknown,
                                          ignored=list_ignored):
             if fn not in dmap:
-                if (list_ignored or fn in files) and self._dirignore(fn):
+                if (list_ignored or match.exact(fn)) and self._dirignore(fn):
                     if list_ignored:
                         iadd(fn)
                 elif list_unknown:
--- a/mercurial/localrepo.py	Mon May 12 11:37:08 2008 -0500
+++ b/mercurial/localrepo.py	Mon May 12 11:37:08 2008 -0500
@@ -11,6 +11,7 @@
 import changelog, dirstate, filelog, manifest, context, weakref
 import lock, transaction, stat, errno, ui
 import os, revlog, time, util, extensions, hook, inspect
+import match as match_
 
 class localrepository(repo.repository):
     capabilities = util.set(('lookup', 'changegroupsubset'))
@@ -748,7 +749,7 @@
                            p1=p1, p2=p2, extra=extra, empty_ok=True)
 
     def commit(self, files=None, text="", user=None, date=None,
-               match=util.always, force=False, force_editor=False,
+               match=None, force=False, force_editor=False,
                p1=None, p2=None, extra={}, empty_ok=False):
         wlock = lock = tr = None
         valid = 0 # don't save the dirstate if this isn't set
@@ -964,7 +965,7 @@
             for fn in self.dirstate.walk(match):
                 yield fn
 
-    def status(self, node1=None, node2=None, files=[], match=util.always,
+    def status(self, node1=None, node2=None, match=None,
                list_ignored=False, list_clean=False, list_unknown=True):
         """return status of files between two nodes or node and working directory
 
@@ -984,6 +985,9 @@
                     del mf[fn]
             return mf
 
+        if not match:
+            match = match_.always(self.root, self.getcwd())
+
         modified, added, removed, deleted, unknown = [], [], [], [], []
         ignored, clean = [], []
 
@@ -1000,10 +1004,8 @@
         # are we comparing the working directory?
         if not node2:
             (lookup, modified, added, removed, deleted, unknown,
-             ignored, clean) = self.dirstate.status(files, match,
-                                                    list_ignored, list_clean,
-                                                    list_unknown)
-
+             ignored, clean) = self.dirstate.status(match, list_ignored,
+                                                    list_clean, list_unknown)
             # are we comparing working dir against its parent?
             if compareworking:
                 if lookup:
--- a/mercurial/patch.py	Mon May 12 11:37:08 2008 -0500
+++ b/mercurial/patch.py	Mon May 12 11:37:08 2008 -0500
@@ -1186,7 +1186,7 @@
     date1 = util.datestr(ctx1.date())
 
     if not changes:
-        changes = repo.status(node1, node2, files=match.files(), match=match)[:5]
+        changes = repo.status(node1, node2, match=match)[:5]
     modified, added, removed, deleted, unknown = changes
 
     if not modified and not added and not removed:
--- a/tests/test-mq.out	Mon May 12 11:37:08 2008 -0500
+++ b/tests/test-mq.out	Mon May 12 11:37:08 2008 -0500
@@ -96,6 +96,7 @@
 A somefile
 % qnew with uncommitted changes and missing file (issue 803)
 someotherfile: No such file or directory
+someotherfile: No such file or directory
 A somefile
 issue803.patch
 Patch queue now empty