diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py --- a/mercurial/cmdutil.py +++ b/mercurial/cmdutil.py @@ -127,15 +127,16 @@ def make_file(repo, pat, node=None, 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): diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -1602,9 +1602,8 @@ def locate(ui, repo, *pats, **opts): 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 @@ def locate(ui, repo, *pats, **opts): 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']: diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py --- a/mercurial/localrepo.py +++ b/mercurial/localrepo.py @@ -832,6 +832,9 @@ class localrepository(repo.repository): 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() diff --git a/mercurial/util.py b/mercurial/util.py --- a/mercurial/util.py +++ b/mercurial/util.py @@ -382,10 +382,11 @@ def matcher(canonroot, cwd='', names=[], 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 diff --git a/tests/test-backout.out b/tests/test-backout.out --- a/tests/test-backout.out +++ b/tests/test-backout.out @@ -28,7 +28,6 @@ reverting a 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 diff --git a/tests/test-git-import.out b/tests/test-git-import.out --- a/tests/test-git-import.out +++ b/tests/test-git-import.out @@ -31,7 +31,6 @@ a a % rename and modify applying patch from stdin -copy2: No such file or directory a a b @@ -40,7 +39,6 @@ a % 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 diff --git a/tests/test-locate.out b/tests/test-locate.out --- a/tests/test-locate.out +++ b/tests/test-locate.out @@ -3,18 +3,14 @@ adding b 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