Mercurial > public > mercurial-scm > hg
comparison 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 |
comparison
equal
deleted
inserted
replaced
14330:473d0aaf7655 | 14331:3b9a896af09c |
---|---|
3589 """show aliases for remote repositories | 3589 """show aliases for remote repositories |
3590 | 3590 |
3591 Show definition of symbolic path name NAME. If no name is given, | 3591 Show definition of symbolic path name NAME. If no name is given, |
3592 show definition of all available names. | 3592 show definition of all available names. |
3593 | 3593 |
3594 Option -q/--quiet suppresses all output when searching for NAME | |
3595 and shows only the path names when listing all definitions. | |
3596 | |
3594 Path names are defined in the [paths] section of your | 3597 Path names are defined in the [paths] section of your |
3595 configuration file and in ``/etc/mercurial/hgrc``. If run inside a | 3598 configuration file and in ``/etc/mercurial/hgrc``. If run inside a |
3596 repository, ``.hg/hgrc`` is used, too. | 3599 repository, ``.hg/hgrc`` is used, too. |
3597 | 3600 |
3598 The path names ``default`` and ``default-push`` have a special | 3601 The path names ``default`` and ``default-push`` have a special |
3611 Returns 0 on success. | 3614 Returns 0 on success. |
3612 """ | 3615 """ |
3613 if search: | 3616 if search: |
3614 for name, path in ui.configitems("paths"): | 3617 for name, path in ui.configitems("paths"): |
3615 if name == search: | 3618 if name == search: |
3616 ui.write("%s\n" % util.hidepassword(path)) | 3619 ui.status("%s\n" % util.hidepassword(path)) |
3617 return | 3620 return |
3618 ui.warn(_("not found!\n")) | 3621 if not ui.quiet: |
3622 ui.warn(_("not found!\n")) | |
3619 return 1 | 3623 return 1 |
3620 else: | 3624 else: |
3621 for name, path in ui.configitems("paths"): | 3625 for name, path in ui.configitems("paths"): |
3622 ui.write("%s = %s\n" % (name, util.hidepassword(path))) | 3626 if ui.quiet: |
3627 ui.write("%s\n" % name) | |
3628 else: | |
3629 ui.write("%s = %s\n" % (name, util.hidepassword(path))) | |
3623 | 3630 |
3624 def postincoming(ui, repo, modheads, optupdate, checkout): | 3631 def postincoming(ui, repo, modheads, optupdate, checkout): |
3625 if modheads == 0: | 3632 if modheads == 0: |
3626 return | 3633 return |
3627 if optupdate: | 3634 if optupdate: |