changeset 27727:1a6fd929056f

paths: merge conditions that select visibility of fields Truth table (extracted from the original implementation): search quiet name path subopt ------ ----- ---- ---- ------ f f T T T f T T f f T f f T f T T f f f
author Yuya Nishihara <yuya@tcha.org>
date Sun, 13 Dec 2015 23:01:19 +0900
parents 7e9dc8bbebf6
children 294037159c64
files mercurial/commands.py
diffstat 1 files changed, 11 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/commands.py	Sun Dec 13 22:02:32 2015 +0900
+++ b/mercurial/commands.py	Sun Dec 13 23:01:19 2015 +0900
@@ -5403,16 +5403,19 @@
     else:
         pathitems = sorted(ui.paths.iteritems())
 
+    if ui.quiet:
+        namefmt = '%s\n'
+    else:
+        namefmt = '%s = '
+    showsubopts = not search and not ui.quiet
+
     for name, path in pathitems:
-        if search and not ui.quiet:
+        if not search:
+            ui.write(namefmt % name)
+        if not ui.quiet:
             ui.write("%s\n" % util.hidepassword(path.rawloc))
-        if search:
-            continue
-        if ui.quiet:
-            ui.write("%s\n" % name)
-        else:
-            ui.write("%s = %s\n" % (name, util.hidepassword(path.rawloc)))
-            for subopt, value in sorted(path.suboptions.items()):
+        for subopt, value in sorted(path.suboptions.items()):
+            if showsubopts:
                 ui.write('%s:%s = %s\n' % (name, subopt, value))
 
     if search and not pathitems: