Show More
@@ -83,15 +83,26 b' if sys.version_info > (3, 5, 0):' | |||||
83 | xrange = range # we use xrange in one place, and we'd rather not use range |
|
83 | xrange = range # we use xrange in one place, and we'd rather not use range | |
84 | def _bytespath(p): |
|
84 | def _bytespath(p): | |
85 | return p.encode('utf-8') |
|
85 | return p.encode('utf-8') | |
|
86 | ||||
|
87 | def _strpath(p): | |||
|
88 | return p.decode('utf-8') | |||
|
89 | ||||
86 | elif sys.version_info >= (3, 0, 0): |
|
90 | elif sys.version_info >= (3, 0, 0): | |
87 | print('%s is only supported on Python 3.5+ and 2.6-2.7, not %s' % |
|
91 | print('%s is only supported on Python 3.5+ and 2.6-2.7, not %s' % | |
88 | (sys.argv[0], '.'.join(str(v) for v in sys.version_info[:3]))) |
|
92 | (sys.argv[0], '.'.join(str(v) for v in sys.version_info[:3]))) | |
89 | sys.exit(70) # EX_SOFTWARE from `man 3 sysexit` |
|
93 | sys.exit(70) # EX_SOFTWARE from `man 3 sysexit` | |
90 | else: |
|
94 | else: | |
91 | PYTHON3 = False |
|
95 | PYTHON3 = False | |
|
96 | ||||
|
97 | # In python 2.x, path operations are generally done using | |||
|
98 | # bytestrings by default, so we don't have to do any extra | |||
|
99 | # fiddling there. We define the wrapper functions anyway just to | |||
|
100 | # help keep code consistent between platforms. | |||
92 | def _bytespath(p): |
|
101 | def _bytespath(p): | |
93 | return p |
|
102 | return p | |
94 |
|
103 | |||
|
104 | _strpath = _bytespath | |||
|
105 | ||||
95 | def checkportisavailable(port): |
|
106 | def checkportisavailable(port): | |
96 | """return true if a port seems free to bind on localhost""" |
|
107 | """return true if a port seems free to bind on localhost""" | |
97 | try: |
|
108 | try: | |
@@ -443,7 +454,7 b' class Test(unittest.TestCase):' | |||||
443 | """ |
|
454 | """ | |
444 | self.path = path |
|
455 | self.path = path | |
445 | self.bname = os.path.basename(path) |
|
456 | self.bname = os.path.basename(path) | |
446 |
self.name = self.bname |
|
457 | self.name = _strpath(self.bname) | |
447 | self._testdir = os.path.dirname(path) |
|
458 | self._testdir = os.path.dirname(path) | |
448 | self.errpath = os.path.join(self._testdir, b'%s.err' % self.bname) |
|
459 | self.errpath = os.path.join(self._testdir, b'%s.err' % self.bname) | |
449 |
|
460 | |||
@@ -1734,8 +1745,8 b' class TestRunner(object):' | |||||
1734 | # in all lowercase, which causes troubles with paths (issue3490) |
|
1745 | # in all lowercase, which causes troubles with paths (issue3490) | |
1735 | d = osenvironb.get(b'TMP', None) |
|
1746 | d = osenvironb.get(b'TMP', None) | |
1736 | # FILE BUG: mkdtemp works only on unicode in Python 3 |
|
1747 | # FILE BUG: mkdtemp works only on unicode in Python 3 | |
1737 | tmpdir = tempfile.mkdtemp('', 'hgtests.', |
|
1748 | tmpdir = tempfile.mkdtemp('', 'hgtests.', d and _strpath(d)) | |
1738 | d and d.decode('utf-8')).encode('utf-8') |
|
1749 | tmpdir = _bytespath(tmpdir) | |
1739 |
|
1750 | |||
1740 | self._hgtmp = osenvironb[b'HGTMP'] = ( |
|
1751 | self._hgtmp = osenvironb[b'HGTMP'] = ( | |
1741 | os.path.realpath(tmpdir)) |
|
1752 | os.path.realpath(tmpdir)) | |
@@ -2126,7 +2137,7 b' class TestRunner(object):' | |||||
2126 | cmd = b'%s -c "import mercurial; print (mercurial.__path__[0])"' |
|
2137 | cmd = b'%s -c "import mercurial; print (mercurial.__path__[0])"' | |
2127 | cmd = cmd % PYTHON |
|
2138 | cmd = cmd % PYTHON | |
2128 | if PYTHON3: |
|
2139 | if PYTHON3: | |
2129 |
cmd = cmd |
|
2140 | cmd = _strpath(cmd) | |
2130 | pipe = os.popen(cmd) |
|
2141 | pipe = os.popen(cmd) | |
2131 | try: |
|
2142 | try: | |
2132 | self._hgpath = _bytespath(pipe.read().strip()) |
|
2143 | self._hgpath = _bytespath(pipe.read().strip()) |
General Comments 0
You need to be logged in to leave comments.
Login now