Show More
@@ -323,7 +323,7 b' def rename(src, dst):' | |||||
323 | os.remove(src) |
|
323 | os.remove(src) | |
324 |
|
324 | |||
325 | _unified_diff = difflib.unified_diff |
|
325 | _unified_diff = difflib.unified_diff | |
326 | if sys.version_info[0] > 2: |
|
326 | if PYTHON3: | |
327 | import functools |
|
327 | import functools | |
328 | _unified_diff = functools.partial(difflib.diff_bytes, difflib.unified_diff) |
|
328 | _unified_diff = functools.partial(difflib.diff_bytes, difflib.unified_diff) | |
329 |
|
329 | |||
@@ -831,7 +831,7 b' checkcodeglobpats = [' | |||||
831 | ] |
|
831 | ] | |
832 |
|
832 | |||
833 | bchr = chr |
|
833 | bchr = chr | |
834 | if sys.version_info[0] == 3: |
|
834 | if PYTHON3: | |
835 | bchr = lambda x: bytes([x]) |
|
835 | bchr = lambda x: bytes([x]) | |
836 |
|
836 | |||
837 | class TTest(Test): |
|
837 | class TTest(Test): | |
@@ -1118,7 +1118,7 b' class TTest(Test):' | |||||
1118 | return True |
|
1118 | return True | |
1119 | if el: |
|
1119 | if el: | |
1120 | if el.endswith(b" (esc)\n"): |
|
1120 | if el.endswith(b" (esc)\n"): | |
1121 | if sys.version_info[0] == 3: |
|
1121 | if PYTHON3: | |
1122 | el = el[:-7].decode('unicode_escape') + '\n' |
|
1122 | el = el[:-7].decode('unicode_escape') + '\n' | |
1123 | el = el.encode('utf-8') |
|
1123 | el = el.encode('utf-8') | |
1124 | else: |
|
1124 | else: | |
@@ -1278,7 +1278,7 b' class TestResult(unittest._TextTestResul' | |||||
1278 | pass |
|
1278 | pass | |
1279 | elif self._options.view: |
|
1279 | elif self._options.view: | |
1280 | v = self._options.view |
|
1280 | v = self._options.view | |
1281 | if sys.version_info[0] == 3: |
|
1281 | if PYTHON3: | |
1282 | v = v.encode('utf-8') |
|
1282 | v = v.encode('utf-8') | |
1283 | os.system(b"%s %s %s" % |
|
1283 | os.system(b"%s %s %s" % | |
1284 | (v, test.refpath, test.errpath)) |
|
1284 | (v, test.refpath, test.errpath)) | |
@@ -1292,7 +1292,7 b' class TestResult(unittest._TextTestResul' | |||||
1292 | else: |
|
1292 | else: | |
1293 | self.stream.write('\n') |
|
1293 | self.stream.write('\n') | |
1294 | for line in lines: |
|
1294 | for line in lines: | |
1295 |
if |
|
1295 | if PYTHON3: | |
1296 | self.stream.flush() |
|
1296 | self.stream.flush() | |
1297 | self.stream.buffer.write(line) |
|
1297 | self.stream.buffer.write(line) | |
1298 | self.stream.buffer.flush() |
|
1298 | self.stream.buffer.flush() | |
@@ -1736,7 +1736,7 b' class TestRunner(object):' | |||||
1736 | # If --with-hg is not specified, we have bytes already, |
|
1736 | # If --with-hg is not specified, we have bytes already, | |
1737 | # but if it was specified in python3 we get a str, so we |
|
1737 | # but if it was specified in python3 we get a str, so we | |
1738 | # have to encode it back into a bytes. |
|
1738 | # have to encode it back into a bytes. | |
1739 | if sys.version_info[0] == 3: |
|
1739 | if PYTHON3: | |
1740 | if not isinstance(whg, bytes): |
|
1740 | if not isinstance(whg, bytes): | |
1741 | whg = whg.encode('utf-8') |
|
1741 | whg = whg.encode('utf-8') | |
1742 | self._bindir = os.path.dirname(os.path.realpath(whg)) |
|
1742 | self._bindir = os.path.dirname(os.path.realpath(whg)) | |
@@ -1762,7 +1762,7 b' class TestRunner(object):' | |||||
1762 |
|
1762 | |||
1763 | fileb = __file__.encode('utf-8') |
|
1763 | fileb = __file__.encode('utf-8') | |
1764 | runtestdir = os.path.abspath(os.path.dirname(fileb)) |
|
1764 | runtestdir = os.path.abspath(os.path.dirname(fileb)) | |
1765 | if sys.version_info[0] == 3: |
|
1765 | if PYTHON3: | |
1766 | sepb = os.pathsep.encode('utf-8') |
|
1766 | sepb = os.pathsep.encode('utf-8') | |
1767 | else: |
|
1767 | else: | |
1768 | sepb = os.pathsep |
|
1768 | sepb = os.pathsep | |
@@ -1848,7 +1848,7 b' class TestRunner(object):' | |||||
1848 | failed = False |
|
1848 | failed = False | |
1849 | warned = False |
|
1849 | warned = False | |
1850 | kws = self.options.keywords |
|
1850 | kws = self.options.keywords | |
1851 |
if kws is not None and |
|
1851 | if kws is not None and PYTHON3: | |
1852 | kws = kws.encode('utf-8') |
|
1852 | kws = kws.encode('utf-8') | |
1853 |
|
1853 | |||
1854 | suite = TestSuite(self._testdir, |
|
1854 | suite = TestSuite(self._testdir, | |
@@ -1995,7 +1995,7 b' class TestRunner(object):' | |||||
1995 | # Run installer in hg root |
|
1995 | # Run installer in hg root | |
1996 | script = os.path.realpath(sys.argv[0]) |
|
1996 | script = os.path.realpath(sys.argv[0]) | |
1997 | exe = sys.executable |
|
1997 | exe = sys.executable | |
1998 | if sys.version_info[0] == 3: |
|
1998 | if PYTHON3: | |
1999 | py3 = b'--c2to3' |
|
1999 | py3 = b'--c2to3' | |
2000 | compiler = compiler.encode('utf-8') |
|
2000 | compiler = compiler.encode('utf-8') | |
2001 | script = script.encode('utf-8') |
|
2001 | script = script.encode('utf-8') | |
@@ -2039,7 +2039,7 b' class TestRunner(object):' | |||||
2039 | else: |
|
2039 | else: | |
2040 | f = open(installerrs, 'rb') |
|
2040 | f = open(installerrs, 'rb') | |
2041 | for line in f: |
|
2041 | for line in f: | |
2042 | if sys.version_info[0] > 2: |
|
2042 | if PYTHON3: | |
2043 | sys.stdout.buffer.write(line) |
|
2043 | sys.stdout.buffer.write(line) | |
2044 | else: |
|
2044 | else: | |
2045 | sys.stdout.write(line) |
|
2045 | sys.stdout.write(line) | |
@@ -2115,12 +2115,12 b' class TestRunner(object):' | |||||
2115 |
|
2115 | |||
2116 | cmd = b'%s -c "import mercurial; print (mercurial.__path__[0])"' |
|
2116 | cmd = b'%s -c "import mercurial; print (mercurial.__path__[0])"' | |
2117 | cmd = cmd % PYTHON |
|
2117 | cmd = cmd % PYTHON | |
2118 | if sys.version_info[0] > 2: |
|
2118 | if PYTHON3: | |
2119 | cmd = cmd.decode('utf-8') |
|
2119 | cmd = cmd.decode('utf-8') | |
2120 | pipe = os.popen(cmd) |
|
2120 | pipe = os.popen(cmd) | |
2121 | try: |
|
2121 | try: | |
2122 | self._hgpath = pipe.read().strip() |
|
2122 | self._hgpath = pipe.read().strip() | |
2123 | if sys.version_info[0] == 3: |
|
2123 | if PYTHON3: | |
2124 | self._hgpath = self._hgpath.encode('utf-8') |
|
2124 | self._hgpath = self._hgpath.encode('utf-8') | |
2125 | finally: |
|
2125 | finally: | |
2126 | pipe.close() |
|
2126 | pipe.close() | |
@@ -2157,7 +2157,7 b' class TestRunner(object):' | |||||
2157 |
|
2157 | |||
2158 | def _findprogram(self, program): |
|
2158 | def _findprogram(self, program): | |
2159 | """Search PATH for a executable program""" |
|
2159 | """Search PATH for a executable program""" | |
2160 | if sys.version_info[0] > 2: |
|
2160 | if PYTHON3: | |
2161 | dpb = os.defpath.encode('utf-8') |
|
2161 | dpb = os.defpath.encode('utf-8') | |
2162 | sepb = os.pathsep.encode('utf-8') |
|
2162 | sepb = os.pathsep.encode('utf-8') | |
2163 | else: |
|
2163 | else: |
General Comments 0
You need to be logged in to leave comments.
Login now