configwizard: invoke hg.exe on Windows (bug 1280815); r?smacleod draft
authorGregory Szorc <gps@mozilla.com>
Fri, 08 Jul 2016 10:44:12 -0700
changeset 8764 f46314270e2bf66b9060f197e2c66b8a138fbceb
parent 8759 c53c6a52af7463676e4d036d264ee3dee26395bf
push id985
push userbmo:gps@mozilla.com
push dateFri, 08 Jul 2016 17:45:14 +0000
reviewerssmacleod
bugs1280815
configwizard: invoke hg.exe on Windows (bug 1280815); r?smacleod Even if you run hg.exe, sys.argv[0] is reported as "hg." When you try to execute a "hg" process (a Python script with a shebang), this fails because it isn't a Windows executable. Work around this by invoking "hg.exe." MozReview-Commit-ID: 3DkhmUCX8u1
hgext/configwizard/__init__.py
--- a/hgext/configwizard/__init__.py
+++ b/hgext/configwizard/__init__.py
@@ -510,17 +510,25 @@ def _enableext(cw, name, value):
 def _promptvctextension(ui, cw, ext, msg):
     if ui.hasconfig('extensions', ext):
         return
 
     ext_path = _vctextpath(ext)
 
     # Verify the extension loads before prompting to enable it. This is
     # done out of paranoia.
-    result = subprocess.check_output([sys.argv[0],
+
+    # Even if we launch hg.exe, sys.argv[0] is "hg" on Windows. Since "hg" isn't
+    # a Windows application, we can't simply run it. So change to the ".exe"
+    # variant if necessary.
+    hg = sys.argv[0]
+    if sys.platform in ('win32', 'msys') and hg.endswith('hg'):
+        hg += '.exe'
+
+    result = subprocess.check_output([hg,
                                       '--config', 'extensions.testmodule=%s' % ext_path,
                                       '--config', 'ui.traceback=true'],
                                      stderr=subprocess.STDOUT)
     if 'Traceback' in result:
         return
 
     if uipromptchoice(ui, '%s (Yn) $$ &Yes $$ &No' % msg):
         return