Patchwork [3,of,3] py3: make files use absolute_import and print_function

login
register
mail settings
Submitter Pulkit Goyal
Date June 30, 2016, 9:47 a.m.
Message ID <3b93444153b718659c13.1467280040@pulkit-goyal>
Download mbox | patch
Permalink /patch/15679/
State Changes Requested
Headers show

Comments

Pulkit Goyal - June 30, 2016, 9:47 a.m.
# HG changeset patch
# User Pulkit Goyal <7895pulkit@gmail.com>
# Date 1467279903 -19800
#      Thu Jun 30 15:15:03 2016 +0530
# Node ID 3b93444153b718659c137963c261ad793c8c4366
# Parent  91320eb3d9ce90433ec843525e5563dbad5193e2
py3: make files use absolute_import and print_function

This patch includes addition of absolute_import and print_function to the
 files where they are missing. The modern importing conventions are followed.
Martijn Pieters - July 1, 2016, 1:47 p.m.
On 30 June 2016 at 10:47, Pulkit Goyal <7895pulkit@gmail.com> wrote:
> # HG changeset patch
> # User Pulkit Goyal <7895pulkit@gmail.com>
> # Date 1467279903 -19800
> #      Thu Jun 30 15:15:03 2016 +0530
> # Node ID 3b93444153b718659c137963c261ad793c8c4366
> # Parent  91320eb3d9ce90433ec843525e5563dbad5193e2
> py3: make files use absolute_import and print_function
>
> This patch includes addition of absolute_import and print_function to the
>  files where they are missing. The modern importing conventions are followed.
>

..8<.. snip ..8<..

> diff -r 91320eb3d9ce -r 3b93444153b7 setup.py
> --- a/setup.py  Tue Jun 28 17:03:21 2016 +0530
> +++ b/setup.py  Thu Jun 30 15:15:03 2016 +0530
> @@ -4,7 +4,52 @@
>  # 'python setup.py install', or
>  # 'python setup.py --help' for more options
>
> -import sys, platform
> +from __future__ import absolute_import
> +
> +import ctypes
> +import distutils
> +import distutils.command.build
> +import distutils.command.build_ext
> +import distutils.command.build_py
> +import distutils.command.build_scripts
> +import distutils.command.install_lib
> +import distutils.command.install_scripts
> +import distutils.core
> +import distutils.dist
> +import distutils.errors
> +import distutils.spawn
> +import distutils.sysconfig
> +import distutils.version
> +import os
> +import platform
> +import re
> +import shutil
> +import stat
> +import subprocess
> +import sys
> +import tempfile
> +import time
> +
> +log = distutils.log
> +file_util = distutils.file_util
> +Command = distutils.core.Command
> +Extension = distutils.core.Extension
> +Distribution = distutils.dist.Distribution
> +build = distutils.command.build.build
> +build_ext = distutils.command.build_ext.build_ext
> +build_py = distutils.command.build_py.build_py
> +build_scripts = distutils.command.build_scripts.build_scripts
> +install_lib = distutils.command.install_lib.install_lib
> +install_scripts = distutils.command.install_scripts.install_scripts
> +spawn = distutils.spawn.spawn
> +find_executable = distutils.spawn.find_executable
> +CCompilerError = distutils.errors.CCompilerError,
> +DistutilsError = distutils.errors.DistutilsError,
> +DistutilsExecError = distutils.errors.DistutilsExecError,
> +get_python_inc = distutils.sysconfig.get_python_inc
> +get_config_var = distutils.sysconfig.get_config_var
> +StrictVersion = distutils.version.StrictVersion
> +
>  if getattr(sys, 'version_info', (0, 0, 0)) < (2, 6, 0, 'final'):
>      raise SystemExit("Mercurial requires Python 2.6 or later.")
>
> @@ -57,33 +102,11 @@
>
>  ispypy = "PyPy" in sys.version
>
> -import ctypes
> -import os, stat, subprocess, time
> -import re
> -import shutil
> -import tempfile
> -from distutils import log
>  if 'FORCE_SETUPTOOLS' in os.environ:
> -    from setuptools import setup
> +    import setuptools
> +    setup = setuptools.setup
>  else:
> -    from distutils.core import setup
> -from distutils.core import Command, Extension
> -from distutils.dist import Distribution
> -from distutils.command.build import build
> -from distutils.command.build_ext import build_ext
> -from distutils.command.build_py import build_py
> -from distutils.command.build_scripts import build_scripts
> -from distutils.command.install_lib import install_lib
> -from distutils.command.install_scripts import install_scripts
> -from distutils.spawn import spawn, find_executable
> -from distutils import file_util
> -from distutils.errors import (
> -    CCompilerError,
> -    DistutilsError,
> -    DistutilsExecError,
> -)
> -from distutils.sysconfig import get_python_inc, get_config_var
> -from distutils.version import StrictVersion
> +    setup = distutils.core.setup
>
>  scripts = ['hg']
>  if os.name == 'nt':
> @@ -127,7 +150,7 @@
>      py2exe.Distribution # silence unused import warning
>      py2exeloaded = True
>      # import py2exe's patched Distribution class
> -    from distutils.core import Distribution
> +    Distribution = distutils.core.Distribution
>  except ImportError:
>      py2exeloaded = False
>
> @@ -565,7 +588,7 @@
>      ]
>
>  try:
> -    from distutils import cygwinccompiler
> +    import distutils.cygwinccompiler as cygwinccompiler
>
>      # the -mno-cygwin option has been deprecated for years
>      compiler = cygwinccompiler.Mingw32CCompiler
> diff -r 91320eb3d9ce -r 3b93444153b7 tests/heredoctest.py
> --- a/tests/heredoctest.py      Tue Jun 28 17:03:21 2016 +0530
> +++ b/tests/heredoctest.py      Thu Jun 30 15:15:03 2016 +0530
> @@ -1,4 +1,4 @@
> -from __future__ import absolute_import
> +from __future__ import absolute_import, print_function
>
>  import sys
>

setup.py is not subject to the Mercurial demandimport hack, so we
really don't need to force attribute access.

Also, note that loads of those imports were listed *after* the Python
version test for a reason; many of those modules can't be imported on
older Python versions, and now the version test will never be reached.
Please do leave that test in place *at the top*.

For the same reason, we can't use any `from __future__ import` syntax;
that too breaks on old Python versions.

On the whole, better leave setup.py alone here. It runs fine on Python
2 and 3 already.


..8<.. snip ..8<..

Patch

diff -r 91320eb3d9ce -r 3b93444153b7 hgext/highlight/__init__.py
--- a/hgext/highlight/__init__.py	Tue Jun 28 17:03:21 2016 +0530
+++ b/hgext/highlight/__init__.py	Thu Jun 30 15:15:03 2016 +0530
@@ -26,9 +26,21 @@ 
 match (even matches with a low confidence score) will be used.
 """
 
-import highlight
-from mercurial.hgweb import webcommands, webutil, common
-from mercurial import extensions, encoding, fileset
+from __future__ import absolute_import
+
+from . import highlight
+from mercurial.hgweb import (
+    common,
+    webcommands,
+    webutil,
+)
+
+from mercurial import (
+    encoding,
+    extensions,
+    fileset,
+)
+
 # Note for extension authors: ONLY specify testedwith = 'internal' for
 # extensions which SHIP WITH MERCURIAL. Non-mainline extensions should
 # be specifying the version(s) of Mercurial they are tested with, or
diff -r 91320eb3d9ce -r 3b93444153b7 hgext/highlight/highlight.py
--- a/hgext/highlight/highlight.py	Tue Jun 28 17:03:21 2016 +0530
+++ b/hgext/highlight/highlight.py	Thu Jun 30 15:15:03 2016 +0530
@@ -8,14 +8,27 @@ 
 # The original module was split in an interface and an implementation
 # file to defer pygments loading and speedup extension setup.
 
+from __future__ import absolute_import
+
+import pygments
+import pygments.formatters
+import pygments.lexers
+import pygments.util
+
 from mercurial import demandimport
 demandimport.ignore.extend(['pkgutil', 'pkg_resources', '__main__'])
-from mercurial import util, encoding
 
-from pygments import highlight
-from pygments.util import ClassNotFound
-from pygments.lexers import guess_lexer, guess_lexer_for_filename, TextLexer
-from pygments.formatters import HtmlFormatter
+from mercurial import (
+    encoding,
+    util,
+)
+
+highlight = pygments.highlight
+ClassNotFound = pygments.util.ClassNotFound
+guess_lexer = pygments.lexers.guess_lexer
+guess_lexer_for_filename = pygments.lexers.guess_lexer_for_filename
+TextLexer = pygments.lexers.TextLexer
+HtmlFormatter = pygments.formatters.HtmlFormatter
 
 SYNTAX_CSS = ('\n<link rel="stylesheet" href="{url}highlightcss" '
               'type="text/css" />')
diff -r 91320eb3d9ce -r 3b93444153b7 hgext/share.py
--- a/hgext/share.py	Tue Jun 28 17:03:21 2016 +0530
+++ b/hgext/share.py	Thu Jun 30 15:15:03 2016 +0530
@@ -37,10 +37,22 @@ 
     The default naming mode is "identity."
 '''
 
+from __future__ import absolute_import
+
+import errno
 from mercurial.i18n import _
-from mercurial import cmdutil, commands, hg, util, extensions, bookmarks, error
-from mercurial.hg import repository, parseurl
-import errno
+from mercurial import (
+    bookmarks,
+    cmdutil,
+    commands,
+    error,
+    extensions,
+    hg,
+    util,
+)
+
+repository = hg.repository
+parseurl = hg.parseurl
 
 cmdtable = {}
 command = cmdutil.command(cmdtable)
diff -r 91320eb3d9ce -r 3b93444153b7 hgext/win32text.py
--- a/hgext/win32text.py	Tue Jun 28 17:03:21 2016 +0530
+++ b/hgext/win32text.py	Thu Jun 30 15:15:03 2016 +0530
@@ -41,10 +41,16 @@ 
   # or pretxnchangegroup.cr = python:hgext.win32text.forbidcr
 '''
 
+from __future__ import absolute_import
+
+import re
 from mercurial.i18n import _
-from mercurial.node import short
-from mercurial import util
-import re
+from mercurial.node import (
+    short,
+)
+from mercurial import (
+    util,
+)
 
 # Note for extension authors: ONLY specify testedwith = 'internal' for
 # extensions which SHIP WITH MERCURIAL. Non-mainline extensions should
diff -r 91320eb3d9ce -r 3b93444153b7 i18n/polib.py
--- a/i18n/polib.py	Tue Jun 28 17:03:21 2016 +0530
+++ b/i18n/polib.py	Thu Jun 30 15:15:03 2016 +0530
@@ -13,6 +13,8 @@ 
 :func:`~polib.mofile` convenience functions.
 """
 
+from __future__ import absolute_import
+
 __author__    = 'David Jean Louis <izimobil@gmail.com>'
 __version__   = '0.6.4'
 __all__       = ['pofile', 'POFile', 'POEntry', 'mofile', 'MOFile', 'MOEntry',
diff -r 91320eb3d9ce -r 3b93444153b7 setup.py
--- a/setup.py	Tue Jun 28 17:03:21 2016 +0530
+++ b/setup.py	Thu Jun 30 15:15:03 2016 +0530
@@ -4,7 +4,52 @@ 
 # 'python setup.py install', or
 # 'python setup.py --help' for more options
 
-import sys, platform
+from __future__ import absolute_import
+
+import ctypes
+import distutils
+import distutils.command.build
+import distutils.command.build_ext
+import distutils.command.build_py
+import distutils.command.build_scripts
+import distutils.command.install_lib
+import distutils.command.install_scripts
+import distutils.core
+import distutils.dist
+import distutils.errors
+import distutils.spawn
+import distutils.sysconfig
+import distutils.version
+import os
+import platform
+import re
+import shutil
+import stat
+import subprocess
+import sys
+import tempfile
+import time
+
+log = distutils.log
+file_util = distutils.file_util
+Command = distutils.core.Command
+Extension = distutils.core.Extension
+Distribution = distutils.dist.Distribution
+build = distutils.command.build.build
+build_ext = distutils.command.build_ext.build_ext
+build_py = distutils.command.build_py.build_py
+build_scripts = distutils.command.build_scripts.build_scripts
+install_lib = distutils.command.install_lib.install_lib
+install_scripts = distutils.command.install_scripts.install_scripts
+spawn = distutils.spawn.spawn
+find_executable = distutils.spawn.find_executable
+CCompilerError = distutils.errors.CCompilerError,
+DistutilsError = distutils.errors.DistutilsError,
+DistutilsExecError = distutils.errors.DistutilsExecError,
+get_python_inc = distutils.sysconfig.get_python_inc
+get_config_var = distutils.sysconfig.get_config_var
+StrictVersion = distutils.version.StrictVersion
+
 if getattr(sys, 'version_info', (0, 0, 0)) < (2, 6, 0, 'final'):
     raise SystemExit("Mercurial requires Python 2.6 or later.")
 
@@ -57,33 +102,11 @@ 
 
 ispypy = "PyPy" in sys.version
 
-import ctypes
-import os, stat, subprocess, time
-import re
-import shutil
-import tempfile
-from distutils import log
 if 'FORCE_SETUPTOOLS' in os.environ:
-    from setuptools import setup
+    import setuptools
+    setup = setuptools.setup
 else:
-    from distutils.core import setup
-from distutils.core import Command, Extension
-from distutils.dist import Distribution
-from distutils.command.build import build
-from distutils.command.build_ext import build_ext
-from distutils.command.build_py import build_py
-from distutils.command.build_scripts import build_scripts
-from distutils.command.install_lib import install_lib
-from distutils.command.install_scripts import install_scripts
-from distutils.spawn import spawn, find_executable
-from distutils import file_util
-from distutils.errors import (
-    CCompilerError,
-    DistutilsError,
-    DistutilsExecError,
-)
-from distutils.sysconfig import get_python_inc, get_config_var
-from distutils.version import StrictVersion
+    setup = distutils.core.setup
 
 scripts = ['hg']
 if os.name == 'nt':
@@ -127,7 +150,7 @@ 
     py2exe.Distribution # silence unused import warning
     py2exeloaded = True
     # import py2exe's patched Distribution class
-    from distutils.core import Distribution
+    Distribution = distutils.core.Distribution
 except ImportError:
     py2exeloaded = False
 
@@ -565,7 +588,7 @@ 
     ]
 
 try:
-    from distutils import cygwinccompiler
+    import distutils.cygwinccompiler as cygwinccompiler
 
     # the -mno-cygwin option has been deprecated for years
     compiler = cygwinccompiler.Mingw32CCompiler
diff -r 91320eb3d9ce -r 3b93444153b7 tests/heredoctest.py
--- a/tests/heredoctest.py	Tue Jun 28 17:03:21 2016 +0530
+++ b/tests/heredoctest.py	Thu Jun 30 15:15:03 2016 +0530
@@ -1,4 +1,4 @@ 
-from __future__ import absolute_import
+from __future__ import absolute_import, print_function
 
 import sys
 
diff -r 91320eb3d9ce -r 3b93444153b7 tests/md5sum.py
--- a/tests/md5sum.py	Tue Jun 28 17:03:21 2016 +0530
+++ b/tests/md5sum.py	Thu Jun 30 15:15:03 2016 +0530
@@ -6,12 +6,17 @@ 
 # of the PYTHON SOFTWARE FOUNDATION LICENSE VERSION 2, which is
 # GPL-compatible.
 
-import sys, os
+from __future__ import absolute_import
+
+import os
+import sys
 
 try:
-    from hashlib import md5
+    import hashlib
+    md5 = hashlib.md5
 except ImportError:
-    from md5 import md5
+    import md5
+    md5 = md5.md5
 
 try:
     import msvcrt
diff -r 91320eb3d9ce -r 3b93444153b7 tests/readlink.py
--- a/tests/readlink.py	Tue Jun 28 17:03:21 2016 +0530
+++ b/tests/readlink.py	Thu Jun 30 15:15:03 2016 +0530
@@ -1,8 +1,10 @@ 
 #!/usr/bin/env python
 
-from __future__ import print_function
+from __future__ import absolute_import, print_function
 
-import errno, os, sys
+import errno
+import os
+import sys
 
 for f in sys.argv[1:]:
     try:
diff -r 91320eb3d9ce -r 3b93444153b7 tests/run-tests.py
--- a/tests/run-tests.py	Tue Jun 28 17:03:21 2016 +0530
+++ b/tests/run-tests.py	Thu Jun 30 15:15:03 2016 +0530
@@ -43,31 +43,31 @@ 
 # completes fairly quickly, includes both shell and Python scripts, and
 # includes some scripts that run daemon processes.)
 
-from __future__ import print_function
+from __future__ import absolute_import, print_function
 
-from distutils import version
 import difflib
+import distutils.version as version
 import errno
 import json
 import optparse
 import os
+import random
+import re
 import shutil
-import subprocess
 import signal
 import socket
+import subprocess
 import sys
 import tempfile
+import threading
 import time
-import random
-import re
-import threading
-import killdaemons as killmod
+import unittest
+import xml.dom.minidom as minidom
+
 try:
     import Queue as queue
 except ImportError:
     import queue
-from xml.dom import minidom
-import unittest
 
 if os.environ.get('RTUNICODEPEDANTRY', False):
     try:
@@ -475,6 +475,7 @@ 
         pass
 
 def killdaemons(pidfile):
+    import killdaemons as killmod
     return killmod.killdaemons(pidfile, tryhard=False, remove=True,
                                logfn=vlog)
 
@@ -2493,7 +2494,8 @@ 
 
     def _outputcoverage(self):
         """Produce code coverage output."""
-        from coverage import coverage
+        import coverage
+        coverage = coverage.coverage
 
         vlog('# Producing coverage report')
         # chdir is the easiest way to get short, relative paths in the
diff -r 91320eb3d9ce -r 3b93444153b7 tests/test-check-py3-compat.t
--- a/tests/test-check-py3-compat.t	Tue Jun 28 17:03:21 2016 +0530
+++ b/tests/test-check-py3-compat.t	Thu Jun 30 15:15:03 2016 +0530
@@ -8,17 +8,7 @@ 
   hgext/fsmonitor/pywatchman/__init__.py requires print_function
   hgext/fsmonitor/pywatchman/capabilities.py not using absolute_import
   hgext/fsmonitor/pywatchman/pybser.py not using absolute_import
-  hgext/highlight/__init__.py not using absolute_import
-  hgext/highlight/highlight.py not using absolute_import
-  hgext/share.py not using absolute_import
-  hgext/win32text.py not using absolute_import
   i18n/check-translation.py not using absolute_import
-  i18n/polib.py not using absolute_import
-  setup.py not using absolute_import
-  tests/heredoctest.py requires print_function
-  tests/md5sum.py not using absolute_import
-  tests/readlink.py not using absolute_import
-  tests/run-tests.py not using absolute_import
   tests/test-demandimport.py not using absolute_import
 
 #if py3exe
diff -r 91320eb3d9ce -r 3b93444153b7 tests/test-commandserver.t
--- a/tests/test-commandserver.t	Tue Jun 28 17:03:21 2016 +0530
+++ b/tests/test-commandserver.t	Thu Jun 30 15:15:03 2016 +0530
@@ -13,11 +13,12 @@ 
   $ hg init repo
   $ cd repo
 
+  >>> from __future__ import print_function
   >>> from hgclient import readchannel, runcommand, check
   >>> @check
   ... def hellomessage(server):
   ...     ch, data = readchannel(server)
-  ...     print '%c, %r' % (ch, data)
+  ...     print('%c, %r' % (ch, data))
   ...     # run an arbitrary command to make sure the next thing the server
   ...     # sends isn't part of the hello message
   ...     runcommand(server, ['id'])
@@ -99,7 +100,7 @@ 
   ...     server.stdin.close()
   ... 
   ...     # server exits with 1 if the pipe closed while reading the command
-  ...     print 'server exit code =', server.wait()
+  ...     print('server exit code =', server.wait())
   server exit code = 1
 
   >>> from hgclient import readchannel, runcommand, check, stringio
@@ -206,10 +207,11 @@ 
 #endif
 
   $ cat <<EOF > hook.py
+  > from __future__ import print_function
   > import sys
   > def hook(**args):
-  >     print 'hook talking'
-  >     print 'now try to read something: %r' % sys.stdin.read()
+  >     print('hook talking')
+  >     print('now try to read something: %r' % sys.stdin.read())
   > EOF
 
   >>> from hgclient import readchannel, runcommand, check, stringio
@@ -610,18 +612,19 @@ 
 
 run commandserver in commandserver, which is silly but should work:
 
+  >>> from __future__ import print_function
   >>> from hgclient import readchannel, runcommand, check, stringio
   >>> @check
   ... def nested(server):
-  ...     print '%c, %r' % readchannel(server)
+  ...     print('%c, %r' % readchannel(server))
   ...     class nestedserver(object):
   ...         stdin = stringio('getencoding\n')
   ...         stdout = stringio()
   ...     runcommand(server, ['serve', '--cmdserver', 'pipe'],
   ...                output=nestedserver.stdout, input=nestedserver.stdin)
   ...     nestedserver.stdout.seek(0)
-  ...     print '%c, %r' % readchannel(nestedserver)  # hello
-  ...     print '%c, %r' % readchannel(nestedserver)  # getencoding
+  ...     print('%c, %r' % readchannel(nestedserver))  # hello
+  ...     print('%c, %r' % readchannel(nestedserver))  # getencoding
   o, 'capabilities: getencoding runcommand\nencoding: *\npid: *' (glob)
   *** runcommand serve --cmdserver pipe
   o, 'capabilities: getencoding runcommand\nencoding: *\npid: *' (glob)
@@ -632,11 +635,12 @@ 
 
   $ cd ..
 
+  >>> from __future__ import print_function
   >>> from hgclient import readchannel, runcommand, check
   >>> @check
   ... def hellomessage(server):
   ...     ch, data = readchannel(server)
-  ...     print '%c, %r' % (ch, data)
+  ...     print('%c, %r' % (ch, data))
   ...     # run an arbitrary command to make sure the next thing the server
   ...     # sends isn't part of the hello message
   ...     runcommand(server, ['id'])
@@ -672,11 +676,12 @@ 
 
 #if unix-socket unix-permissions
 
+  >>> from __future__ import print_function
   >>> from hgclient import unixserver, readchannel, runcommand, check, stringio
   >>> server = unixserver('.hg/server.sock', '.hg/server.log')
   >>> def hellomessage(conn):
   ...     ch, data = readchannel(conn)
-  ...     print '%c, %r' % (ch, data)
+  ...     print('%c, %r' % (ch, data))
   ...     runcommand(conn, ['id'])
   >>> check(hellomessage, server.connect)
   o, 'capabilities: getencoding runcommand\nencoding: *\npid: *' (glob)
@@ -723,6 +728,7 @@ 
   > [cmdserver]
   > log = inexistent/path.log
   > EOF
+  >>> from __future__ import print_function
   >>> from hgclient import unixserver, readchannel, check
   >>> server = unixserver('.hg/server.sock', '.hg/server.log')
   >>> def earlycrash(conn):
@@ -730,7 +736,7 @@ 
   ...         try:
   ...             ch, data = readchannel(conn)
   ...             if not data.startswith('  '):
-  ...                 print '%c, %r' % (ch, data)
+  ...                 print('%c, %r' % (ch, data))
   ...         except EOFError:
   ...             break
   >>> check(earlycrash, server.connect)
diff -r 91320eb3d9ce -r 3b93444153b7 tests/test-generaldelta.t
--- a/tests/test-generaldelta.t	Tue Jun 28 17:03:21 2016 +0530
+++ b/tests/test-generaldelta.t	Thu Jun 30 15:15:03 2016 +0530
@@ -18,11 +18,12 @@ 
   > done
 
   $ cd ..
+  >>> from __future__ import print_function
   >>> import os
   >>> regsize = os.stat("repo/.hg/store/00manifest.i").st_size
   >>> gdsize = os.stat("gdrepo/.hg/store/00manifest.i").st_size
   >>> if regsize < gdsize:
-  ...     print 'generaldata increased size of manifest'
+  ...     print('generaldata increased size of manifest')
 
 Verify rev reordering doesnt create invalid bundles (issue4462)
 This requires a commit tree that when pulled will reorder manifest revs such
diff -r 91320eb3d9ce -r 3b93444153b7 tests/test-hgweb-commands.t
--- a/tests/test-hgweb-commands.t	Tue Jun 28 17:03:21 2016 +0530
+++ b/tests/test-hgweb-commands.t	Thu Jun 30 15:15:03 2016 +0530
@@ -2098,9 +2098,10 @@ 
 Graph json escape of multibyte character
 
   $ get-with-headers.py 127.0.0.1:$HGPORT 'graph/' > out
+  >>> from __future__ import print_function
   >>> for line in open("out"):
   ...     if line.startswith("var data ="):
-  ...         print line,
+  ...         print(line, end='')
   var data = [["061dd13ba3c3", [0, 1], [[0, 0, 1, -1, ""]], "\u80fd", "test", "1970-01-01", ["unstable", true], ["tip"], ["something"]], ["cad8025a2e87", [0, 1], [[0, 0, 1, 3, "FF0000"]], "branch commit with null character: \u0000", "test", "1970-01-01", ["unstable", false], [], []], ["1d22e65f027e", [0, 1], [[0, 0, 1, 3, ""]], "branch", "test", "1970-01-01", ["stable", true], [], []], ["a4f92ed23982", [0, 1], [[0, 0, 1, 3, ""]], "Added tag 1.0 for changeset 2ef0ac749a14", "test", "1970-01-01", ["default", true], [], []], ["2ef0ac749a14", [0, 1], [], "base", "test", "1970-01-01", ["default", false], ["1.0"], ["anotherthing"]]];
 
 capabilities
diff -r 91320eb3d9ce -r 3b93444153b7 tests/test-import.t
--- a/tests/test-import.t	Tue Jun 28 17:03:21 2016 +0530
+++ b/tests/test-import.t	Thu Jun 30 15:15:03 2016 +0530
@@ -53,7 +53,8 @@ 
 regardless of the commit message in the patch)
 
   $ cat > dummypatch.py <<EOF
-  > print 'patching file a'
+  > from __future__ import print_function
+  > print('patching file a')
   > file('a', 'wb').write('line2\n')
   > EOF
   $ hg clone -r0 a b
diff -r 91320eb3d9ce -r 3b93444153b7 tests/test-status.t
--- a/tests/test-status.t	Tue Jun 28 17:03:21 2016 +0530
+++ b/tests/test-status.t	Thu Jun 30 15:15:03 2016 +0530
@@ -203,8 +203,9 @@ 
   ]
 
   $ hg status -A -Tpickle > pickle
+  >>> from __future__ import print_function
   >>> import pickle
-  >>> print sorted((x['status'], x['path']) for x in pickle.load(open("pickle")))
+  >>> print(sorted((x['status'], x['path']) for x in pickle.load(open("pickle"))))
   [('!', 'deleted'), ('?', 'pickle'), ('?', 'unknown'), ('A', 'added'), ('A', 'copied'), ('C', '.hgignore'), ('C', 'modified'), ('I', 'ignored'), ('R', 'removed')]
   $ rm pickle
 
diff -r 91320eb3d9ce -r 3b93444153b7 tests/test-unified-test.t
--- a/tests/test-unified-test.t	Tue Jun 28 17:03:21 2016 +0530
+++ b/tests/test-unified-test.t	Thu Jun 30 15:15:03 2016 +0530
@@ -26,24 +26,25 @@ 
 
 Doctest commands:
 
-  >>> print 'foo'
+  >>> from __future__ import print_function
+  >>> print('foo')
   foo
   $ echo interleaved
   interleaved
   >>> for c in 'xyz':
-  ...     print c
+  ...     print(c)
   x
   y
   z
-  >>> print
+  >>> print()
   
   >>> foo = 'global name'
   >>> def func():
-  ...     print foo, 'should be visible in func()'
+  ...     print(foo, 'should be visible in func()')
   >>> func()
   global name should be visible in func()
-  >>> print '''multiline
-  ... string'''
+  >>> print('''multiline
+  ... string''')
   multiline
   string