Patchwork [4,of,5] version: factor out mapping of internal/external labels

login
register
mail settings
Submitter Yuya Nishihara
Date Aug. 22, 2016, 2:44 p.m.
Message ID <f6e34ad8025ba31a7ef4.1471877076@mimosa>
Download mbox | patch
Permalink /patch/16382/
State Accepted
Headers show

Comments

Yuya Nishihara - Aug. 22, 2016, 2:44 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1471331352 -32400
#      Tue Aug 16 16:09:12 2016 +0900
# Node ID f6e34ad8025ba31a7ef463205c14a450c44baea6
# Parent  7849d926daff8e0da11fb095cca8ce63f9d331c3
version: factor out mapping of internal/external labels

Prepares for formatter support, where translation should be disabled
conditionally.

Patch

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -7258,20 +7258,19 @@  def version_(ui):
     # 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
diff --git a/tests/test-extension.t b/tests/test-extension.t
--- a/tests/test-extension.t
+++ b/tests/test-extension.t
@@ -1224,7 +1224,7 @@  Test version number support in 'hg versi
     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 @@  Test version number support in 'hg versi
   Enabled extensions:
   
     throw  external  1.twentythree
+    strip  internal  
 
   $ hg version -q --config extensions.throw=throw.py
   Mercurial Distributed SCM (version *) (glob)