changeset 29839:110ed1868f86

version: factor out mapping of internal/external labels Prepares for formatter support, where translation should be disabled conditionally.
author Yuya Nishihara <yuya@tcha.org>
date Tue, 16 Aug 2016 16:09:12 +0900
parents 8540133f91a1
children 4435d4c951ec
files mercurial/commands.py tests/test-extension.t
diffstat 2 files changed, 7 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/commands.py	Tue Aug 16 16:03:09 2016 +0900
+++ b/mercurial/commands.py	Tue Aug 16 16:09:12 2016 +0900
@@ -7258,20 +7258,19 @@
     # format names and versions into columns
     names = []
     vers = []
-    place = []
+    isinternals = []
     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"))
+        isinternals.append(extensions.ismoduleinternal(module))
     if names:
         maxnamelen = max(len(n) for n in names)
+        places = [_("external"), _("internal")]
         for i, name in enumerate(names):
+            p = isinternals[i]
             if ui.verbose:
                 ui.write("  %-*s  %s  %s\n" %
-                         (maxnamelen, name, place[i], vers[i]))
+                         (maxnamelen, name, places[p], vers[i]))
 
 def loadcmdtable(ui, name, cmdtable):
     """Load command functions from specified cmdtable
--- a/tests/test-extension.t	Tue Aug 16 16:03:09 2016 +0900
+++ b/tests/test-extension.t	Tue Aug 16 16:09:12 2016 +0900
@@ -1224,7 +1224,7 @@
     throw  external  1.2.3
   $ echo 'getversion = lambda: "1.twentythree"' >> throw.py
   $ rm -f throw.pyc throw.pyo
-  $ hg version -v --config extensions.throw=throw.py
+  $ hg version -v --config extensions.throw=throw.py --config extensions.strip=
   Mercurial Distributed SCM (version *) (glob)
   (see https://mercurial-scm.org for more information)
   
@@ -1235,6 +1235,7 @@
   Enabled extensions:
   
     throw  external  1.twentythree
+    strip  internal  
 
   $ hg version -q --config extensions.throw=throw.py
   Mercurial Distributed SCM (version *) (glob)