diff --git a/hgext/churn.py b/hgext/churn.py --- a/hgext/churn.py +++ b/hgext/churn.py @@ -15,6 +15,7 @@ import os import time from mercurial.i18n import _ +from mercurial.pycompat import open from mercurial import ( cmdutil, encoding, diff --git a/hgext/convert/common.py b/hgext/convert/common.py --- a/hgext/convert/common.py +++ b/hgext/convert/common.py @@ -15,6 +15,7 @@ import shlex import subprocess from mercurial.i18n import _ +from mercurial.pycompat import open from mercurial import ( encoding, error, diff --git a/hgext/convert/convcmd.py b/hgext/convert/convcmd.py --- a/hgext/convert/convcmd.py +++ b/hgext/convert/convcmd.py @@ -11,6 +11,7 @@ import os import shutil from mercurial.i18n import _ +from mercurial.pycompat import open from mercurial import ( encoding, error, diff --git a/hgext/convert/cvs.py b/hgext/convert/cvs.py --- a/hgext/convert/cvs.py +++ b/hgext/convert/cvs.py @@ -12,6 +12,7 @@ import re import socket from mercurial.i18n import _ +from mercurial.pycompat import open from mercurial import ( encoding, error, diff --git a/hgext/convert/cvsps.py b/hgext/convert/cvsps.py --- a/hgext/convert/cvsps.py +++ b/hgext/convert/cvsps.py @@ -11,6 +11,7 @@ import os import re from mercurial.i18n import _ +from mercurial.pycompat import open from mercurial import ( encoding, error, diff --git a/hgext/convert/hg.py b/hgext/convert/hg.py --- a/hgext/convert/hg.py +++ b/hgext/convert/hg.py @@ -23,6 +23,7 @@ import re import time from mercurial.i18n import _ +from mercurial.pycompat import open from mercurial import ( bookmarks, context, diff --git a/hgext/convert/monotone.py b/hgext/convert/monotone.py --- a/hgext/convert/monotone.py +++ b/hgext/convert/monotone.py @@ -11,6 +11,7 @@ import os import re from mercurial.i18n import _ +from mercurial.pycompat import open from mercurial import ( error, pycompat, diff --git a/hgext/convert/subversion.py b/hgext/convert/subversion.py --- a/hgext/convert/subversion.py +++ b/hgext/convert/subversion.py @@ -8,6 +8,7 @@ import re import xml.dom.minidom from mercurial.i18n import _ +from mercurial.pycompat import open from mercurial import ( encoding, error, diff --git a/hgext/fastannotate/context.py b/hgext/fastannotate/context.py --- a/hgext/fastannotate/context.py +++ b/hgext/fastannotate/context.py @@ -13,6 +13,7 @@ import hashlib import os from mercurial.i18n import _ +from mercurial.pycompat import open from mercurial import ( error, linelog as linelogmod, diff --git a/hgext/fastannotate/protocol.py b/hgext/fastannotate/protocol.py --- a/hgext/fastannotate/protocol.py +++ b/hgext/fastannotate/protocol.py @@ -10,6 +10,7 @@ import contextlib import os from mercurial.i18n import _ +from mercurial.pycompat import open from mercurial import ( error, extensions, diff --git a/hgext/fastannotate/revmap.py b/hgext/fastannotate/revmap.py --- a/hgext/fastannotate/revmap.py +++ b/hgext/fastannotate/revmap.py @@ -13,6 +13,7 @@ import os import struct from mercurial.node import hex +from mercurial.pycompat import open from mercurial import ( error as hgerror, pycompat, diff --git a/hgext/fsmonitor/__init__.py b/hgext/fsmonitor/__init__.py --- a/hgext/fsmonitor/__init__.py +++ b/hgext/fsmonitor/__init__.py @@ -117,7 +117,7 @@ import weakref from mercurial.i18n import _ from mercurial.node import hex - +from mercurial.pycompat import open from mercurial import ( context, encoding, diff --git a/hgext/histedit.py b/hgext/histedit.py --- a/hgext/histedit.py +++ b/hgext/histedit.py @@ -206,6 +206,7 @@ import os import struct from mercurial.i18n import _ +from mercurial.pycompat import open from mercurial import ( bundle2, cmdutil, diff --git a/hgext/infinitepush/__init__.py b/hgext/infinitepush/__init__.py --- a/hgext/infinitepush/__init__.py +++ b/hgext/infinitepush/__init__.py @@ -103,6 +103,8 @@ from mercurial.node import ( from mercurial.i18n import _ +from mercurial.pycompat import open + from mercurial.utils import ( procutil, stringutil, diff --git a/hgext/infinitepush/store.py b/hgext/infinitepush/store.py --- a/hgext/infinitepush/store.py +++ b/hgext/infinitepush/store.py @@ -11,6 +11,7 @@ import os import subprocess import tempfile +from mercurial.pycompat import open from mercurial import ( node, pycompat, diff --git a/hgext/largefiles/lfutil.py b/hgext/largefiles/lfutil.py --- a/hgext/largefiles/lfutil.py +++ b/hgext/largefiles/lfutil.py @@ -16,6 +16,7 @@ import stat from mercurial.i18n import _ from mercurial.node import hex +from mercurial.pycompat import open from mercurial import ( dirstate, diff --git a/hgext/largefiles/localstore.py b/hgext/largefiles/localstore.py --- a/hgext/largefiles/localstore.py +++ b/hgext/largefiles/localstore.py @@ -10,6 +10,7 @@ from __future__ import absolute_import from mercurial.i18n import _ +from mercurial.pycompat import open from mercurial import util from . import ( diff --git a/hgext/largefiles/overrides.py b/hgext/largefiles/overrides.py --- a/hgext/largefiles/overrides.py +++ b/hgext/largefiles/overrides.py @@ -14,6 +14,8 @@ import os from mercurial.i18n import _ +from mercurial.pycompat import open + from mercurial.hgweb import webcommands from mercurial import ( diff --git a/hgext/largefiles/proto.py b/hgext/largefiles/proto.py --- a/hgext/largefiles/proto.py +++ b/hgext/largefiles/proto.py @@ -8,6 +8,7 @@ import os import re from mercurial.i18n import _ +from mercurial.pycompat import open from mercurial import ( error, diff --git a/hgext/mq.py b/hgext/mq.py --- a/hgext/mq.py +++ b/hgext/mq.py @@ -76,6 +76,7 @@ from mercurial.node import ( nullrev, short, ) +from mercurial.pycompat import open from mercurial import ( cmdutil, commands, diff --git a/hgext/patchbomb.py b/hgext/patchbomb.py --- a/hgext/patchbomb.py +++ b/hgext/patchbomb.py @@ -83,6 +83,7 @@ import os import socket from mercurial.i18n import _ +from mercurial.pycompat import open from mercurial import ( cmdutil, commands, diff --git a/hgext/rebase.py b/hgext/rebase.py --- a/hgext/rebase.py +++ b/hgext/rebase.py @@ -24,6 +24,7 @@ from mercurial.node import ( nullrev, short, ) +from mercurial.pycompat import open from mercurial import ( bookmarks, cmdutil, diff --git a/hgext/releasenotes.py b/hgext/releasenotes.py --- a/hgext/releasenotes.py +++ b/hgext/releasenotes.py @@ -18,6 +18,7 @@ import errno import re from mercurial.i18n import _ +from mercurial.pycompat import open from mercurial import ( config, error, diff --git a/hgext/relink.py b/hgext/relink.py --- a/hgext/relink.py +++ b/hgext/relink.py @@ -12,6 +12,7 @@ import os import stat from mercurial.i18n import _ +from mercurial.pycompat import open from mercurial import ( error, hg, diff --git a/hgext/remotefilelog/__init__.py b/hgext/remotefilelog/__init__.py --- a/hgext/remotefilelog/__init__.py +++ b/hgext/remotefilelog/__init__.py @@ -132,6 +132,7 @@ import traceback from mercurial.node import hex from mercurial.i18n import _ +from mercurial.pycompat import open from mercurial import ( changegroup, changelog, diff --git a/hgext/remotefilelog/basepack.py b/hgext/remotefilelog/basepack.py --- a/hgext/remotefilelog/basepack.py +++ b/hgext/remotefilelog/basepack.py @@ -9,6 +9,7 @@ import struct import time from mercurial.i18n import _ +from mercurial.pycompat import open from mercurial import ( node as nodemod, policy, diff --git a/hgext/remotefilelog/basestore.py b/hgext/remotefilelog/basestore.py --- a/hgext/remotefilelog/basestore.py +++ b/hgext/remotefilelog/basestore.py @@ -9,6 +9,7 @@ import time from mercurial.i18n import _ from mercurial.node import bin, hex +from mercurial.pycompat import open from mercurial import ( error, pycompat, diff --git a/hgext/remotefilelog/debugcommands.py b/hgext/remotefilelog/debugcommands.py --- a/hgext/remotefilelog/debugcommands.py +++ b/hgext/remotefilelog/debugcommands.py @@ -12,6 +12,7 @@ import zlib from mercurial.node import bin, hex, nullid, short from mercurial.i18n import _ +from mercurial.pycompat import open from mercurial import ( error, filelog, diff --git a/hgext/remotefilelog/remotefilelogserver.py b/hgext/remotefilelog/remotefilelogserver.py --- a/hgext/remotefilelog/remotefilelogserver.py +++ b/hgext/remotefilelog/remotefilelogserver.py @@ -14,6 +14,7 @@ import zlib from mercurial.i18n import _ from mercurial.node import bin, hex, nullid +from mercurial.pycompat import open from mercurial import ( changegroup, changelog, diff --git a/hgext/remotefilelog/shallowutil.py b/hgext/remotefilelog/shallowutil.py --- a/hgext/remotefilelog/shallowutil.py +++ b/hgext/remotefilelog/shallowutil.py @@ -15,6 +15,7 @@ import struct import tempfile from mercurial.i18n import _ +from mercurial.pycompat import open from mercurial import ( error, node, diff --git a/hgext/transplant.py b/hgext/transplant.py --- a/hgext/transplant.py +++ b/hgext/transplant.py @@ -18,6 +18,7 @@ from __future__ import absolute_import import os from mercurial.i18n import _ +from mercurial.pycompat import open from mercurial import ( bundlerepo, cmdutil, diff --git a/mercurial/__init__.py b/mercurial/__init__.py --- a/mercurial/__init__.py +++ b/mercurial/__init__.py @@ -172,7 +172,7 @@ if sys.version_info[0] >= 3: l = ( b'; from mercurial.pycompat import ' b'delattr, getattr, hasattr, setattr, ' - b'open, unicode\n' + b'unicode\n' ) for u in tokenize.tokenize(io.BytesIO(l).readline): if u.type in (tokenize.ENCODING, token.ENDMARKER): @@ -221,7 +221,7 @@ if sys.version_info[0] >= 3: # ``replacetoken`` or any mechanism that changes semantics of module # loading is changed. Otherwise cached bytecode may get loaded without # the new transformation mechanisms applied. - BYTECODEHEADER = b'HG\x00\x0c' + BYTECODEHEADER = b'HG\x00\x0d' class hgloader(importlib.machinery.SourceFileLoader): """Custom module loader that transforms source code. diff --git a/mercurial/archival.py b/mercurial/archival.py --- a/mercurial/archival.py +++ b/mercurial/archival.py @@ -17,6 +17,7 @@ import zlib from .i18n import _ from .node import nullrev +from .pycompat import open from . import ( error, diff --git a/mercurial/changegroup.py b/mercurial/changegroup.py --- a/mercurial/changegroup.py +++ b/mercurial/changegroup.py @@ -18,6 +18,7 @@ from .node import ( nullrev, short, ) +from .pycompat import open from . import ( error, diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py --- a/mercurial/cmdutil.py +++ b/mercurial/cmdutil.py @@ -19,6 +19,7 @@ from .node import ( nullrev, short, ) +from .pycompat import open from . import ( bookmarks, diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -22,6 +22,7 @@ from .node import ( wdirhex, wdirrev, ) +from .pycompat import open from . import ( archival, bookmarks, diff --git a/mercurial/context.py b/mercurial/context.py --- a/mercurial/context.py +++ b/mercurial/context.py @@ -23,6 +23,7 @@ from .node import ( wdirfilenodeids, wdirhex, ) +from .pycompat import open from . import ( copies, dagop, diff --git a/mercurial/crecord.py b/mercurial/crecord.py --- a/mercurial/crecord.py +++ b/mercurial/crecord.py @@ -16,6 +16,7 @@ import re import signal from .i18n import _ +from .pycompat import open from . import ( encoding, error, diff --git a/mercurial/debugcommands.py b/mercurial/debugcommands.py --- a/mercurial/debugcommands.py +++ b/mercurial/debugcommands.py @@ -32,6 +32,7 @@ from .node import ( nullrev, short, ) +from .pycompat import open from . import ( bundle2, changegroup, diff --git a/mercurial/extensions.py b/mercurial/extensions.py --- a/mercurial/extensions.py +++ b/mercurial/extensions.py @@ -18,6 +18,7 @@ from .i18n import ( _, gettext, ) +from .pycompat import open from . import ( cmdutil, diff --git a/mercurial/filemerge.py b/mercurial/filemerge.py --- a/mercurial/filemerge.py +++ b/mercurial/filemerge.py @@ -18,6 +18,7 @@ from .node import ( nullid, short, ) +from .pycompat import open from . import ( encoding, diff --git a/mercurial/hgweb/common.py b/mercurial/hgweb/common.py --- a/mercurial/hgweb/common.py +++ b/mercurial/hgweb/common.py @@ -14,6 +14,7 @@ import mimetypes import os import stat +from ..pycompat import open from .. import ( encoding, pycompat, diff --git a/mercurial/hgweb/server.py b/mercurial/hgweb/server.py --- a/mercurial/hgweb/server.py +++ b/mercurial/hgweb/server.py @@ -17,6 +17,7 @@ import traceback import wsgiref.validate from ..i18n import _ +from ..pycompat import open from .. import ( encoding, diff --git a/mercurial/httpconnection.py b/mercurial/httpconnection.py --- a/mercurial/httpconnection.py +++ b/mercurial/httpconnection.py @@ -13,6 +13,7 @@ from __future__ import absolute_import import os from .i18n import _ +from .pycompat import open from . import ( pycompat, util, diff --git a/mercurial/mail.py b/mercurial/mail.py --- a/mercurial/mail.py +++ b/mercurial/mail.py @@ -19,6 +19,7 @@ import socket import time from .i18n import _ +from .pycompat import open from . import ( encoding, error, diff --git a/mercurial/match.py b/mercurial/match.py --- a/mercurial/match.py +++ b/mercurial/match.py @@ -13,6 +13,7 @@ import os import re from .i18n import _ +from .pycompat import open from . import ( encoding, error, diff --git a/mercurial/patch.py b/mercurial/patch.py --- a/mercurial/patch.py +++ b/mercurial/patch.py @@ -24,6 +24,7 @@ from .node import ( hex, short, ) +from .pycompat import open from . import ( copies, diffhelper, diff --git a/mercurial/posix.py b/mercurial/posix.py --- a/mercurial/posix.py +++ b/mercurial/posix.py @@ -21,6 +21,7 @@ import tempfile import unicodedata from .i18n import _ +from .pycompat import open from . import ( encoding, error, diff --git a/mercurial/profiling.py b/mercurial/profiling.py --- a/mercurial/profiling.py +++ b/mercurial/profiling.py @@ -10,6 +10,7 @@ from __future__ import absolute_import, import contextlib from .i18n import _ +from .pycompat import open from . import ( encoding, error, diff --git a/mercurial/pycompat.py b/mercurial/pycompat.py --- a/mercurial/pycompat.py +++ b/mercurial/pycompat.py @@ -354,6 +354,7 @@ else: sysstr = identity strurl = identity bytesurl = identity + open = open # this can't be parsed on Python 3 exec(b'def raisewithtb(exc, tb):\n' b' raise exc, None, tb\n') diff --git a/mercurial/server.py b/mercurial/server.py --- a/mercurial/server.py +++ b/mercurial/server.py @@ -10,6 +10,7 @@ from __future__ import absolute_import import os from .i18n import _ +from .pycompat import open from . import ( chgserver, diff --git a/mercurial/shelve.py b/mercurial/shelve.py --- a/mercurial/shelve.py +++ b/mercurial/shelve.py @@ -28,6 +28,7 @@ import itertools import stat from .i18n import _ +from .pycompat import open from . import ( bookmarks, bundle2, diff --git a/mercurial/statprof.py b/mercurial/statprof.py --- a/mercurial/statprof.py +++ b/mercurial/statprof.py @@ -114,6 +114,7 @@ import sys import threading import time +from .pycompat import open from . import ( encoding, pycompat, diff --git a/mercurial/streamclone.py b/mercurial/streamclone.py --- a/mercurial/streamclone.py +++ b/mercurial/streamclone.py @@ -12,6 +12,7 @@ import os import struct from .i18n import _ +from .pycompat import open from .interfaces import repository from . import ( cacheutil, diff --git a/mercurial/subrepo.py b/mercurial/subrepo.py --- a/mercurial/subrepo.py +++ b/mercurial/subrepo.py @@ -19,6 +19,7 @@ import tarfile import xml.dom.minidom from .i18n import _ +from .pycompat import open from . import ( cmdutil, encoding, diff --git a/mercurial/ui.py b/mercurial/ui.py --- a/mercurial/ui.py +++ b/mercurial/ui.py @@ -22,6 +22,7 @@ import traceback from .i18n import _ from .node import hex +from .pycompat import open from . import ( color, diff --git a/mercurial/util.py b/mercurial/util.py --- a/mercurial/util.py +++ b/mercurial/util.py @@ -35,6 +35,7 @@ import traceback import warnings from .thirdparty import attr +from .pycompat import open from hgdemandimport import tracing from . import ( encoding, diff --git a/mercurial/utils/procutil.py b/mercurial/utils/procutil.py --- a/mercurial/utils/procutil.py +++ b/mercurial/utils/procutil.py @@ -20,6 +20,7 @@ import sys import time from ..i18n import _ +from ..pycompat import open from .. import ( encoding,