Patchwork [2,of,3] debuginstall: add Python version to debuginstall output (issue4128)

login
register
mail settings
Submitter Chris Jerdonek
Date Dec. 28, 2013, 1:20 a.m.
Message ID <d302be444d44b4ebfee0.1388193601@stonewall.local>
Download mbox | patch
Permalink /patch/3238/
State Superseded
Headers show

Comments

Chris Jerdonek - Dec. 28, 2013, 1:20 a.m.
# HG changeset patch
# User Chris Jerdonek <chris.jerdonek@gmail.com>
# Date 1388192332 28800
#      Fri Dec 27 16:58:52 2013 -0800
# Node ID d302be444d44b4ebfee0bb772ed1988bae2e58e0
# Parent  3a91ff8b2a83bcfbad000f0140c9df67b0022522
debuginstall: add Python version to debuginstall output (issue4128)

This change adds the version of the Python being used by Mercurial (i.e.
the value of sys.version) to the output of "hg debuginstall".

Below is an example of what the output looks like after this change.
The first three lines are the new output lines:

    $ ./hg debuginstall
    displaying install info...
    sys.version: 2.7.6 (default, Nov 12 2013, 13:26:39)
    [GCC 4.2.1 Compatible Apple Clang 4.1 ((tags/Apple/clang-421.11.66))]

    checking encoding (UTF-8)...
    checking Python lib (/opt/local/Library/Frameworks/Python.framework/
      Versions/2.7/lib/python2.7)...
    checking installed modules (/Users/chris/dev/mercurial)...
    checking templates (/Users/chris/dev/mercurial/templates)...
    checking commit editor...
    checking username...
    no problems detected

Patch

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -9,6 +9,7 @@ 
 from lock import release
 from i18n import _
 import os, re, difflib, time, tempfile, errno
+import sys
 import hg, scmutil, util, revlog, copies, error, bookmarks
 import patch, help, encoding, templatekw, discovery
 import archival, changegroup, cmdutil, hbisect
@@ -2045,6 +2046,9 @@ 
         f.close()
         return name
 
+    ui.status(_("displaying install info...\n"))
+    ui.status(_("sys.version: %s\n\n") % sys.version)
+
     problems = 0
 
     # encoding
diff --git a/tests/test-debuginstall.py b/tests/test-debuginstall.py
--- a/tests/test-debuginstall.py
+++ b/tests/test-debuginstall.py
@@ -2,6 +2,7 @@ 
 import fnmatch
 import os
 import subprocess
+import sys
 import textwrap
 import unittest
 
@@ -46,7 +47,15 @@ 
         # We use a deque so we can call popleft() and compare lines without
         # keeping track of a list index.
         lines = collections.deque(lines)
-        self.checklines(lines, ["checking encoding (ascii)..."])
+        # Since sys.version can be a multi-line string, we need to dedent
+        # before doing the substitution.
+        expected = textwrap.dedent("""\
+        displaying install info...
+        sys.version: %s
+
+        checking encoding (ascii)...
+        """) % sys.version
+        self.checklines(lines, expected.splitlines())
         expected = tolines("""\
         checking Python lib (*lib*)...
         checking installed modules (*mercurial)...