changeset 4196:1c69c73d85d9

locate: exit(1) if we didn't print any file
author Alexis S. L. Carvalho <alexis@cecm.usp.br>
date Sat, 10 Mar 2007 23:00:58 -0300
parents e8ee8fdeddb1
children 492d0d5b6976
files mercurial/commands.py tests/test-locate tests/test-locate.out
diffstat 3 files changed, 8 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/commands.py	Sat Mar 10 23:00:57 2007 -0300
+++ b/mercurial/commands.py	Sat Mar 10 23:00:58 2007 -0300
@@ -1620,6 +1620,7 @@
     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 @@
             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
--- a/tests/test-locate	Sat Mar 10 23:00:57 2007 -0300
+++ b/tests/test-locate	Sat Mar 10 23:00:58 2007 -0300
@@ -10,8 +10,8 @@
 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"
--- a/tests/test-locate.out	Sat Mar 10 23:00:57 2007 -0300
+++ b/tests/test-locate.out	Sat Mar 10 23:00:58 2007 -0300
@@ -3,6 +3,8 @@
 adding t.h
 adding t/x
 a
+locate succeeded
+locate failed
 a
 b
 t.h