--- a/hgext/convert/filemap.py Sun Sep 03 15:47:17 2017 +0900
+++ b/hgext/convert/filemap.py Sun Sep 03 14:56:31 2017 +0900
@@ -3,7 +3,8 @@
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2 or any later version.
-from __future__ import absolute_import
+
+from __future__ import absolute_import, print_function
import posixpath
import shlex
@@ -18,7 +19,7 @@
def rpairs(path):
'''Yield tuples with path split at '/', starting with the full path.
No leading, trailing or double '/', please.
- >>> for x in rpairs(b'foo/bar/baz'): print x
+ >>> for x in rpairs(b'foo/bar/baz'): print(x)
('foo/bar/baz', '')
('foo/bar', 'baz')
('foo', 'bar/baz')
--- a/hgext/mq.py Sun Sep 03 15:47:17 2017 +0900
+++ b/hgext/mq.py Sun Sep 03 14:56:31 2017 +0900
@@ -62,7 +62,7 @@
in the strip extension.
'''
-from __future__ import absolute_import
+from __future__ import absolute_import, print_function
import errno
import os
@@ -155,7 +155,7 @@
def inserthgheader(lines, header, value):
"""Assuming lines contains a HG patch header, add a header line with value.
>>> try: inserthgheader([], b'# Date ', b'z')
- ... except ValueError, inst: print "oops"
+ ... except ValueError, inst: print("oops")
oops
>>> inserthgheader([b'# HG changeset patch'], b'# Date ', b'z')
['# HG changeset patch', '# Date z']
--- a/mercurial/dagparser.py Sun Sep 03 15:47:17 2017 +0900
+++ b/mercurial/dagparser.py Sun Sep 03 14:56:31 2017 +0900
@@ -155,8 +155,9 @@
Error:
+ >>> from . import pycompat
>>> try: list(parsedag(b'+1 bad'))
- ... except Exception, e: print(e)
+ ... except Exception, e: print(pycompat.sysstr(bytes(e)))
invalid character in dag description: bad...
'''
--- a/mercurial/encoding.py Sun Sep 03 15:47:17 2017 +0900
+++ b/mercurial/encoding.py Sun Sep 03 14:56:31 2017 +0900
@@ -5,7 +5,7 @@
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2 or any later version.
-from __future__ import absolute_import
+from __future__ import absolute_import, print_function
import io
import locale
@@ -248,60 +248,62 @@
'ellipsis' is always placed at trimmed side.
>>> from .node import bin
+ >>> def bprint(s):
+ ... print(pycompat.sysstr(s))
>>> ellipsis = b'+++'
>>> from . import encoding
>>> encoding.encoding = b'utf-8'
>>> t = b'1234567890'
- >>> print trim(t, 12, ellipsis=ellipsis)
+ >>> bprint(trim(t, 12, ellipsis=ellipsis))
1234567890
- >>> print trim(t, 10, ellipsis=ellipsis)
+ >>> bprint(trim(t, 10, ellipsis=ellipsis))
1234567890
- >>> print trim(t, 8, ellipsis=ellipsis)
+ >>> bprint(trim(t, 8, ellipsis=ellipsis))
12345+++
- >>> print trim(t, 8, ellipsis=ellipsis, leftside=True)
+ >>> bprint(trim(t, 8, ellipsis=ellipsis, leftside=True))
+++67890
- >>> print trim(t, 8)
+ >>> bprint(trim(t, 8))
12345678
- >>> print trim(t, 8, leftside=True)
+ >>> bprint(trim(t, 8, leftside=True))
34567890
- >>> print trim(t, 3, ellipsis=ellipsis)
+ >>> bprint(trim(t, 3, ellipsis=ellipsis))
+++
- >>> print trim(t, 1, ellipsis=ellipsis)
+ >>> bprint(trim(t, 1, ellipsis=ellipsis))
+
>>> u = u'\u3042\u3044\u3046\u3048\u304a' # 2 x 5 = 10 columns
>>> t = u.encode(pycompat.sysstr(encoding.encoding))
- >>> print trim(t, 12, ellipsis=ellipsis)
+ >>> bprint(trim(t, 12, ellipsis=ellipsis))
\xe3\x81\x82\xe3\x81\x84\xe3\x81\x86\xe3\x81\x88\xe3\x81\x8a
- >>> print trim(t, 10, ellipsis=ellipsis)
+ >>> bprint(trim(t, 10, ellipsis=ellipsis))
\xe3\x81\x82\xe3\x81\x84\xe3\x81\x86\xe3\x81\x88\xe3\x81\x8a
- >>> print trim(t, 8, ellipsis=ellipsis)
+ >>> bprint(trim(t, 8, ellipsis=ellipsis))
\xe3\x81\x82\xe3\x81\x84+++
- >>> print trim(t, 8, ellipsis=ellipsis, leftside=True)
+ >>> bprint(trim(t, 8, ellipsis=ellipsis, leftside=True))
+++\xe3\x81\x88\xe3\x81\x8a
- >>> print trim(t, 5)
+ >>> bprint(trim(t, 5))
\xe3\x81\x82\xe3\x81\x84
- >>> print trim(t, 5, leftside=True)
+ >>> bprint(trim(t, 5, leftside=True))
\xe3\x81\x88\xe3\x81\x8a
- >>> print trim(t, 4, ellipsis=ellipsis)
+ >>> bprint(trim(t, 4, ellipsis=ellipsis))
+++
- >>> print trim(t, 4, ellipsis=ellipsis, leftside=True)
+ >>> bprint(trim(t, 4, ellipsis=ellipsis, leftside=True))
+++
>>> t = bin(b'112233445566778899aa') # invalid byte sequence
- >>> print trim(t, 12, ellipsis=ellipsis)
+ >>> bprint(trim(t, 12, ellipsis=ellipsis))
\x11\x22\x33\x44\x55\x66\x77\x88\x99\xaa
- >>> print trim(t, 10, ellipsis=ellipsis)
+ >>> bprint(trim(t, 10, ellipsis=ellipsis))
\x11\x22\x33\x44\x55\x66\x77\x88\x99\xaa
- >>> print trim(t, 8, ellipsis=ellipsis)
+ >>> bprint(trim(t, 8, ellipsis=ellipsis))
\x11\x22\x33\x44\x55+++
- >>> print trim(t, 8, ellipsis=ellipsis, leftside=True)
+ >>> bprint(trim(t, 8, ellipsis=ellipsis, leftside=True))
+++\x66\x77\x88\x99\xaa
- >>> print trim(t, 8)
+ >>> bprint(trim(t, 8))
\x11\x22\x33\x44\x55\x66\x77\x88
- >>> print trim(t, 8, leftside=True)
+ >>> bprint(trim(t, 8, leftside=True))
\x33\x44\x55\x66\x77\x88\x99\xaa
- >>> print trim(t, 3, ellipsis=ellipsis)
+ >>> bprint(trim(t, 3, ellipsis=ellipsis))
+++
- >>> print trim(t, 1, ellipsis=ellipsis)
+ >>> bprint(trim(t, 1, ellipsis=ellipsis))
+
"""
try:
--- a/mercurial/match.py Sun Sep 03 15:47:17 2017 +0900
+++ b/mercurial/match.py Sun Sep 03 14:56:31 2017 +0900
@@ -5,7 +5,7 @@
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2 or any later version.
-from __future__ import absolute_import
+from __future__ import absolute_import, print_function
import copy
import os
@@ -580,6 +580,7 @@
The paths are remapped to remove/insert the path as needed:
+ >>> from . import pycompat
>>> m1 = match(b'root', b'', [b'a.txt', b'sub/b.txt'])
>>> m2 = subdirmatcher(b'sub', m1)
>>> bool(m2(b'a.txt'))
@@ -597,7 +598,7 @@
>>> util.pconvert(m2.rel(b'b.txt'))
'sub/b.txt'
>>> def bad(f, msg):
- ... print b"%s: %s" % (f, msg)
+ ... print(pycompat.sysstr(b"%s: %s" % (f, msg)))
>>> m1.bad = bad
>>> m2.bad(b'x.txt', b'No such file')
sub/x.txt: No such file
@@ -703,21 +704,24 @@
def _globre(pat):
r'''Convert an extended glob string to a regexp string.
- >>> print _globre(br'?')
+ >>> from . import pycompat
+ >>> def bprint(s):
+ ... print(pycompat.sysstr(s))
+ >>> bprint(_globre(br'?'))
.
- >>> print _globre(br'*')
+ >>> bprint(_globre(br'*'))
[^/]*
- >>> print _globre(br'**')
+ >>> bprint(_globre(br'**'))
.*
- >>> print _globre(br'**/a')
+ >>> bprint(_globre(br'**/a'))
(?:.*/)?a
- >>> print _globre(br'a/**/b')
+ >>> bprint(_globre(br'a/**/b'))
a\/(?:.*/)?b
- >>> print _globre(br'[a*?!^][^b][!c]')
+ >>> bprint(_globre(br'[a*?!^][^b][!c]'))
[a*?!^][\^b][^c]
- >>> print _globre(br'{a,b}')
+ >>> bprint(_globre(br'{a,b}'))
(?:a|b)
- >>> print _globre(br'.\*\?')
+ >>> bprint(_globre(br'.\*\?'))
\.\*\?
'''
i, n = 0, len(pat)
--- a/mercurial/parser.py Sun Sep 03 15:47:17 2017 +0900
+++ b/mercurial/parser.py Sun Sep 03 14:56:31 2017 +0900
@@ -16,7 +16,7 @@
# an action is a tree node name, a tree label, and an optional match
# __call__(program) parses program into a labeled tree
-from __future__ import absolute_import
+from __future__ import absolute_import, print_function
from .i18n import _
from . import (
@@ -220,8 +220,10 @@
def simplifyinfixops(tree, targetnodes):
"""Flatten chained infix operations to reduce usage of Python stack
+ >>> from . import pycompat
>>> def f(tree):
- ... print prettyformat(simplifyinfixops(tree, (b'or',)), (b'symbol',))
+ ... s = prettyformat(simplifyinfixops(tree, (b'or',)), (b'symbol',))
+ ... print(pycompat.sysstr(s))
>>> f((b'or',
... (b'or',
... (b'symbol', b'1'),
@@ -555,6 +557,7 @@
``args`` is a list of alias argument names, or None if the alias
is declared as a symbol.
+ >>> from . import pycompat
>>> parsemap = {
... b'$1 or foo': (b'or', (b'symbol', b'$1'), (b'symbol', b'foo')),
... b'$1 or $bar':
@@ -569,7 +572,8 @@
... _trygetfunc = staticmethod(lambda x: None)
>>> builddefn = aliasrules._builddefn
>>> def pprint(tree):
- ... print prettyformat(tree, (b'_aliasarg', b'string', b'symbol'))
+ ... s = prettyformat(tree, (b'_aliasarg', b'string', b'symbol'))
+ ... print(pycompat.sysstr(s))
>>> args = [b'$1', b'$2', b'foo']
>>> pprint(builddefn(b'$1 or foo', args))
(or
@@ -578,7 +582,7 @@
>>> try:
... builddefn(b'$1 or $bar', args)
... except error.ParseError as inst:
- ... print parseerrordetail(inst)
+ ... print(pycompat.sysstr(parseerrordetail(inst)))
invalid symbol '$bar'
>>> args = [b'$1', b'$10', b'foo']
>>> pprint(builddefn(b'$10 or baz', args))
--- a/mercurial/patch.py Sun Sep 03 15:47:17 2017 +0900
+++ b/mercurial/patch.py Sun Sep 03 14:56:31 2017 +0900
@@ -6,7 +6,7 @@
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2 or any later version.
-from __future__ import absolute_import
+from __future__ import absolute_import, print_function
import collections
import copy
@@ -1505,7 +1505,7 @@
... c.write(fp)
>>> fp.seek(0)
>>> reversedpatch = fp.read()
- >>> print reversedpatch
+ >>> print(pycompat.sysstr(reversedpatch))
diff --git a/folder1/g b/folder1/g
--- a/folder1/g
+++ b/folder1/g
@@ -1562,7 +1562,7 @@
... header.write(out)
... for hunk in header.hunks:
... hunk.write(out)
- >>> print(out.getvalue())
+ >>> print(pycompat.sysstr(out.getvalue()))
diff --git a/folder1/g b/folder1/g
--- a/folder1/g
+++ b/folder1/g
--- a/mercurial/templater.py Sun Sep 03 15:47:17 2017 +0900
+++ b/mercurial/templater.py Sun Sep 03 14:56:31 2017 +0900
@@ -5,7 +5,7 @@
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2 or any later version.
-from __future__ import absolute_import
+from __future__ import absolute_import, print_function
import os
import re
@@ -192,7 +192,7 @@
"""Expand list of templates to node tuple
>>> def f(tree):
- ... print prettyformat(_unnesttemplatelist(tree))
+ ... print(pycompat.sysstr(prettyformat(_unnesttemplatelist(tree))))
>>> f((b'template', []))
(string '')
>>> f((b'template', [(b'string', b'foo')]))
--- a/mercurial/util.py Sun Sep 03 15:47:17 2017 +0900
+++ b/mercurial/util.py Sun Sep 03 14:56:31 2017 +0900
@@ -13,7 +13,7 @@
hide platform-specific details from the core.
"""
-from __future__ import absolute_import
+from __future__ import absolute_import, print_function
import abc
import bz2
@@ -2836,9 +2836,9 @@
'file:///tmp/foo/bar'
>>> bytes(url(b'file:///c:/tmp/foo/bar'))
'file:///c:/tmp/foo/bar'
- >>> print url(br'bundle:foo\bar')
+ >>> print(url(br'bundle:foo\bar'))
bundle:foo\bar
- >>> print url(br'file:///D:\data\hg')
+ >>> print(url(br'file:///D:\data\hg'))
file:///D:\data\hg
"""
if self._localpath: