[PATCH 3 of 5] version: always build list of extension versions

Yuya Nishihara yuya at tcha.org
Mon Aug 22 10:44:35 EDT 2016


# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1471330989 -32400
#      Tue Aug 16 16:03:09 2016 +0900
# Node ID 7849d926daff8e0da11fb095cca8ce63f9d331c3
# Parent  22b19113435d7e2d0dd0eb8a515d131f2552b8ac
version: always build list of extension versions

This patch just moves "if ui.verbose:" to the inner loop, as preparation
for formatter support.

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -7255,21 +7255,21 @@ def version_(ui):
     ))
 
     ui.note(_("\nEnabled extensions:\n\n"))
-    if ui.verbose:
-        # format names and versions into columns
-        names = []
-        vers = []
-        place = []
-        for name, module in extensions.extensions():
-            names.append(name)
-            vers.append(extensions.moduleversion(module))
-            if extensions.ismoduleinternal(module):
-                place.append(_("internal"))
-            else:
-                place.append(_("external"))
-        if names:
-            maxnamelen = max(len(n) for n in names)
-            for i, name in enumerate(names):
+    # format names and versions into columns
+    names = []
+    vers = []
+    place = []
+    for name, module in extensions.extensions():
+        names.append(name)
+        vers.append(extensions.moduleversion(module))
+        if extensions.ismoduleinternal(module):
+            place.append(_("internal"))
+        else:
+            place.append(_("external"))
+    if names:
+        maxnamelen = max(len(n) for n in names)
+        for i, name in enumerate(names):
+            if ui.verbose:
                 ui.write("  %-*s  %s  %s\n" %
                          (maxnamelen, name, place[i], vers[i]))
 
diff --git a/tests/test-extension.t b/tests/test-extension.t
--- a/tests/test-extension.t
+++ b/tests/test-extension.t
@@ -1236,6 +1236,9 @@ Test version number support in 'hg versi
   
     throw  external  1.twentythree
 
+  $ hg version -q --config extensions.throw=throw.py
+  Mercurial Distributed SCM (version *) (glob)
+
 Refuse to load extensions with minimum version requirements
 
   $ cat > minversion1.py << EOF


More information about the Mercurial-devel mailing list