mercurial/commands.py
changeset 27726 7e9dc8bbebf6
parent 27725 64ee5866e107
child 27727 1a6fd929056f
--- a/mercurial/commands.py	Sun Dec 13 21:55:57 2015 +0900
+++ b/mercurial/commands.py	Sun Dec 13 22:02:32 2015 +0900
@@ -5398,18 +5398,16 @@
     Returns 0 on success.
     """
     if search:
-        for name, path in sorted(ui.paths.iteritems()):
-            if name == search:
-                if not ui.quiet:
-                    ui.write("%s\n" % util.hidepassword(path.rawloc))
-                return
-        if not ui.quiet:
-            ui.warn(_("not found!\n"))
-        return 1
+        pathitems = [(name, path) for name, path in ui.paths.iteritems()
+                     if name == search]
     else:
         pathitems = sorted(ui.paths.iteritems())
 
     for name, path in pathitems:
+        if search and not ui.quiet:
+            ui.write("%s\n" % util.hidepassword(path.rawloc))
+        if search:
+            continue
         if ui.quiet:
             ui.write("%s\n" % name)
         else:
@@ -5417,6 +5415,13 @@
             for subopt, value in sorted(path.suboptions.items()):
                 ui.write('%s:%s = %s\n' % (name, subopt, value))
 
+    if search and not pathitems:
+        if not ui.quiet:
+            ui.warn(_("not found!\n"))
+        return 1
+    else:
+        return 0
+
 @command('phase',
     [('p', 'public', False, _('set changeset phase to public')),
      ('d', 'draft', False, _('set changeset phase to draft')),