diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -1620,6 +1620,7 @@ def locate(ui, repo, *pats, **opts): else: node = None + ret = 1 for src, abs, rel, exact in cmdutil.walk(repo, pats, opts, node=node, default='relglob'): if not node and repo.dirstate.state(abs) == '?': @@ -1628,6 +1629,9 @@ def locate(ui, repo, *pats, **opts): ui.write(os.path.join(repo.root, abs), end) else: ui.write(((pats and rel) or abs), end) + ret = 0 + + return ret def log(ui, repo, *pats, **opts): """show revision history of entire repository or files diff --git a/tests/test-locate b/tests/test-locate --- a/tests/test-locate +++ b/tests/test-locate @@ -10,8 +10,8 @@ mkdir t echo 0 > t/x hg ci -A -m m -d "1000000 0" touch nottracked -hg locate a -hg locate NONEXISTENT +hg locate a && echo locate succeeded || echo locate failed +hg locate NONEXISTENT && echo locate succeeded || echo locate failed hg locate hg rm a hg ci -m m -d "1000000 0" diff --git a/tests/test-locate.out b/tests/test-locate.out --- a/tests/test-locate.out +++ b/tests/test-locate.out @@ -3,6 +3,8 @@ adding b adding t.h adding t/x a +locate succeeded +locate failed a b t.h