[PATCH 2 of 6 chg-test] run-tests: cast --with-hg option to bytes consistently at parseargs()

Yuya Nishihara yuya at tcha.org
Fri Feb 12 11:12:35 EST 2016


# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1454828405 -32400
#      Sun Feb 07 16:00:05 2016 +0900
# Node ID c875a2298a7e1af285f8acb60fdb66deb1732bc3
# Parent  8ffb546b8ae698d91f34db6a933c32883f702e66
run-tests: cast --with-hg option to bytes consistently at parseargs()

parseargs() sets bytes to options.with_hg if --local is specified, so do
the same for --with-hg.

diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -285,11 +285,12 @@ def parseargs(args, parser):
         options.pure = True
 
     if options.with_hg:
-        options.with_hg = os.path.realpath(os.path.expanduser(options.with_hg))
+        options.with_hg = os.path.realpath(
+            os.path.expanduser(_bytespath(options.with_hg)))
         if not (os.path.isfile(options.with_hg) and
                 os.access(options.with_hg, os.X_OK)):
             parser.error('--with-hg must specify an executable hg script')
-        if not os.path.basename(options.with_hg) == 'hg':
+        if not os.path.basename(options.with_hg) == b'hg':
             sys.stderr.write('warning: --with-hg should specify an hg script\n')
     if options.local:
         testdir = os.path.dirname(_bytespath(os.path.realpath(sys.argv[0])))
@@ -1925,12 +1926,6 @@ class TestRunner(object):
         if self.options.with_hg:
             self._installdir = None
             whg = self.options.with_hg
-            # If --with-hg is not specified, we have bytes already,
-            # but if it was specified in python3 we get a str, so we
-            # have to encode it back into a bytes.
-            if PYTHON3:
-                if not isinstance(whg, bytes):
-                    whg = _bytespath(whg)
             self._bindir = os.path.dirname(os.path.realpath(whg))
             assert isinstance(self._bindir, bytes)
             self._tmpbindir = os.path.join(self._hgtmp, b'install', b'bin')


More information about the Mercurial-devel mailing list