Patchwork [2,of,5] paths: reorder else clause for readability of subsequent patches

login
register
mail settings
Submitter Yuya Nishihara
Date Jan. 9, 2016, 9:45 a.m.
Message ID <d9f3d8bea3ea4d6e5015.1452332742@mimosa>
Download mbox | patch
Permalink /patch/12620/
State Superseded
Commit 64ee5866e1076b864ca91b215012bb2a438b99b7
Delegated to: Martin von Zweigbergk
Headers show

Comments

Yuya Nishihara - Jan. 9, 2016, 9:45 a.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1450011357 -32400
#      Sun Dec 13 21:55:57 2015 +0900
# Node ID d9f3d8bea3ea4d6e501577bc7e3f32c5788c7550
# Parent  16099841acaa4fa42dffa994b9ac9e16c89a43be
paths: reorder else clause for readability of subsequent patches

This prepares for porting to the formatter API. Future patches will use a
single loop to handle both search=None|pattern cases because formatter output
should be the same. "pathitems" will be switched instead.

Patch

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -5422,14 +5422,15 @@  def paths(ui, repo, search=None):
             ui.warn(_("not found!\n"))
         return 1
     else:
-        for name, path in sorted(ui.paths.iteritems()):
-            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()):
-                    ui.write('%s:%s = %s\n' % (name, subopt, value))
+        pathitems = sorted(ui.paths.iteritems())
+
+    for name, path in pathitems:
+        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()):
+                ui.write('%s:%s = %s\n' % (name, subopt, value))
 
 @command('phase',
     [('p', 'public', False, _('set changeset phase to public')),