changeset 4195:e8ee8fdeddb1

change locate to use relglobs by default This makes its default behaviour useful again (issue108), and changes it search the entire repository by default (instead of just the cwd), just like all other commands. It also hides issue204 by default, but you'll still see the same behaviour if you give it a relpath: pattern.
author Alexis S. L. Carvalho <alexis@cecm.usp.br>
date Sat, 10 Mar 2007 23:00:57 -0300
parents 8e947b0e53cc
children 1c69c73d85d9
files mercurial/cmdutil.py mercurial/commands.py mercurial/localrepo.py mercurial/util.py tests/test-backout.out tests/test-git-import.out tests/test-locate.out
diffstat 7 files changed, 15 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/cmdutil.py	Sat Mar 10 23:00:55 2007 -0300
+++ b/mercurial/cmdutil.py	Sat Mar 10 23:00:57 2007 -0300
@@ -127,15 +127,16 @@
                               pathname),
                 mode)
 
-def matchpats(repo, pats=[], opts={}, head='', globbed=False):
+def matchpats(repo, pats=[], opts={}, head='', globbed=False, default=None):
     cwd = repo.getcwd()
     return util.cmdmatcher(repo.root, cwd, pats or [], opts.get('include'),
-                           opts.get('exclude'), head, globbed=globbed)
+                           opts.get('exclude'), head, globbed=globbed,
+                           default=default)
 
 def walk(repo, pats=[], opts={}, node=None, head='', badmatch=None,
-         globbed=False):
+         globbed=False, default=None):
     files, matchfn, anypats = matchpats(repo, pats, opts, head,
-                                        globbed=globbed)
+                                        globbed=globbed, default=default)
     exact = dict.fromkeys(files)
     for src, fn in repo.walk(node=node, files=files, match=matchfn,
                              badmatch=badmatch):
--- a/mercurial/commands.py	Sat Mar 10 23:00:55 2007 -0300
+++ b/mercurial/commands.py	Sat Mar 10 23:00:57 2007 -0300
@@ -1602,9 +1602,8 @@
     Print all files under Mercurial control whose names match the
     given patterns.
 
-    This command searches the current directory and its
-    subdirectories.  To search an entire repository, move to the root
-    of the repository.
+    This command searches the entire repository by default.  To search
+    just the current directory and its subdirectories, use "--include .".
 
     If no patterns are given to match, this command prints all file
     names.
@@ -1622,7 +1621,7 @@
         node = None
 
     for src, abs, rel, exact in cmdutil.walk(repo, pats, opts, node=node,
-                                             head='(?:.*/|)'):
+                                             default='relglob'):
         if not node and repo.dirstate.state(abs) == '?':
             continue
         if opts['fullpath']:
--- a/mercurial/localrepo.py	Sat Mar 10 23:00:55 2007 -0300
+++ b/mercurial/localrepo.py	Sat Mar 10 23:00:57 2007 -0300
@@ -832,6 +832,9 @@
 
         if node:
             fdict = dict.fromkeys(files)
+            # for dirstate.walk, files=['.'] means "walk the whole tree".
+            # follow that here, too
+            fdict.pop('.', None)
             mdict = self.manifest.read(self.changelog.read(node)[0])
             mfiles = mdict.keys()
             mfiles.sort()
--- a/mercurial/util.py	Sat Mar 10 23:00:55 2007 -0300
+++ b/mercurial/util.py	Sat Mar 10 23:00:57 2007 -0300
@@ -382,10 +382,11 @@
     return _matcher(canonroot, cwd, names, inc, exc, head, 'glob', src)
 
 def cmdmatcher(canonroot, cwd='', names=[], inc=[], exc=[], head='',
-               src=None, globbed=False):
-    if not globbed:
+               src=None, globbed=False, default=None):
+    default = default or 'relpath'
+    if default == 'relpath' and not globbed:
         names = expand_glob(names)
-    return _matcher(canonroot, cwd, names, inc, exc, head, 'relpath', src)
+    return _matcher(canonroot, cwd, names, inc, exc, head, default, src)
 
 def _matcher(canonroot, cwd, names, inc, exc, head, dflt_pat, src):
     """build a function to match a set of file patterns
--- a/tests/test-backout.out	Sat Mar 10 23:00:55 2007 -0300
+++ b/tests/test-backout.out	Sat Mar 10 23:00:57 2007 -0300
@@ -28,7 +28,6 @@
 changeset 3:4cbb1e70196a backs out changeset 1:22bca4c721e5
 the backout changeset is a new head - do not forget to merge
 (use "backout --merge" if you want to auto-merge)
-b: No such file or directory
 adding a
 adding b
 adding c
--- a/tests/test-git-import.out	Sat Mar 10 23:00:55 2007 -0300
+++ b/tests/test-git-import.out	Sat Mar 10 23:00:57 2007 -0300
@@ -31,7 +31,6 @@
 a
 % rename and modify
 applying patch from stdin
-copy2: No such file or directory
 a
 a
 b
@@ -40,7 +39,6 @@
 % one file renamed multiple times
 applying patch from stdin
 9 rename2 rename3 rename3-2 / rename3 (rename2)rename3-2 (rename2)
-rename2: No such file or directory
 rename3
 rename3-2
 a
--- a/tests/test-locate.out	Sat Mar 10 23:00:55 2007 -0300
+++ b/tests/test-locate.out	Sat Mar 10 23:00:57 2007 -0300
@@ -3,18 +3,14 @@
 adding t.h
 adding t/x
 a
-NONEXISTENT: No such file or directory
 a
 b
 t.h
 t/x
-a: No such file or directory
-NONEXISTENT: No such file or directory
 b
 t.h
 t/x
 a
-NONEXISTENT: No such file in rev ce18e5bc5cd3
 a
 b
 t.h