Mercurial > public > mercurial-scm > hg-stable
diff mercurial/commands.py @ 14331:3b9a896af09c
paths: Add support for -q/--quiet
Suppresses output (resolved paths or "not found!") when searching a path,
similar to "grep -q".
Sample usage: hg paths -q foo || echo "there is no foo"
Just prints path names (instead of "name = result") when listing all path
definitions, like "hg bookmarks -q".
Sample usage: hg paths -q | while read i; do hg incoming "$i"; done
author | Thomas Arendsen Hein <thomas@intevation.de> |
---|---|
date | Mon, 16 May 2011 11:41:48 +0200 |
parents | 6078a99af433 |
children | bf93e78f2638 |
line wrap: on
line diff
--- a/mercurial/commands.py Mon May 16 11:14:06 2011 +0200 +++ b/mercurial/commands.py Mon May 16 11:41:48 2011 +0200 @@ -3591,6 +3591,9 @@ Show definition of symbolic path name NAME. If no name is given, show definition of all available names. + Option -q/--quiet suppresses all output when searching for NAME + and shows only the path names when listing all definitions. + Path names are defined in the [paths] section of your configuration file and in ``/etc/mercurial/hgrc``. If run inside a repository, ``.hg/hgrc`` is used, too. @@ -3613,13 +3616,17 @@ if search: for name, path in ui.configitems("paths"): if name == search: - ui.write("%s\n" % util.hidepassword(path)) + ui.status("%s\n" % util.hidepassword(path)) return - ui.warn(_("not found!\n")) + if not ui.quiet: + ui.warn(_("not found!\n")) return 1 else: for name, path in ui.configitems("paths"): - ui.write("%s = %s\n" % (name, util.hidepassword(path))) + if ui.quiet: + ui.write("%s\n" % name) + else: + ui.write("%s = %s\n" % (name, util.hidepassword(path))) def postincoming(ui, repo, modheads, optupdate, checkout): if modheads == 0: