Commit 2bd89520 authored by Gregory Szorc's avatar Gregory Szorc
Browse files

py3: manually import pycompat.open into files that need it

We want to eliminate the source transformer. Currently it inserts
a `from mercurial.pycompat import ...` at the top of files to alias
some builtins.

This commit replaces the implicit import of `open` with an explicit
import on files that need it and changes the source transformer to
no longer import `open`.

As part of this, we needed to store an explicit local for `open` in
the Python 2 code path in `pycompat` so the import works. (Builtins
that are automatically in scope cannot be imported.)

Differential Revision: https://phab.mercurial-scm.org/D7005
parent c2e284cee333
......@@ -15,6 +15,7 @@ import os
import time
from mercurial.i18n import _
from mercurial.pycompat import open
from mercurial import (
cmdutil,
encoding,
......
......@@ -15,6 +15,7 @@ import shlex
import subprocess
from mercurial.i18n import _
from mercurial.pycompat import open
from mercurial import (
encoding,
error,
......
......@@ -11,6 +11,7 @@ import os
import shutil
from mercurial.i18n import _
from mercurial.pycompat import open
from mercurial import (
encoding,
error,
......
......@@ -12,6 +12,7 @@ import re
import socket
from mercurial.i18n import _
from mercurial.pycompat import open
from mercurial import (
encoding,
error,
......
......@@ -11,6 +11,7 @@ import os
import re
from mercurial.i18n import _
from mercurial.pycompat import open
from mercurial import (
encoding,
error,
......
......@@ -23,6 +23,7 @@ import re
import time
from mercurial.i18n import _
from mercurial.pycompat import open
from mercurial import (
bookmarks,
context,
......
......@@ -11,6 +11,7 @@ import os
import re
from mercurial.i18n import _
from mercurial.pycompat import open
from mercurial import (
error,
pycompat,
......
......@@ -8,6 +8,7 @@ import re
import xml.dom.minidom
from mercurial.i18n import _
from mercurial.pycompat import open
from mercurial import (
encoding,
error,
......
......@@ -13,6 +13,7 @@ import hashlib
import os
from mercurial.i18n import _
from mercurial.pycompat import open
from mercurial import (
error,
linelog as linelogmod,
......
......@@ -10,6 +10,7 @@ import contextlib
import os
from mercurial.i18n import _
from mercurial.pycompat import open
from mercurial import (
error,
extensions,
......
......@@ -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,
......
......@@ -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,
......
......@@ -206,6 +206,7 @@ import os
import struct
from mercurial.i18n import _
from mercurial.pycompat import open
from mercurial import (
bundle2,
cmdutil,
......
......@@ -103,6 +103,8 @@ from mercurial.node import (
from mercurial.i18n import _
from mercurial.pycompat import open
from mercurial.utils import (
procutil,
stringutil,
......
......@@ -11,6 +11,7 @@ import os
import subprocess
import tempfile
from mercurial.pycompat import open
from mercurial import (
node,
pycompat,
......
......@@ -16,6 +16,7 @@ import stat
from mercurial.i18n import _
from mercurial.node import hex
from mercurial.pycompat import open
from mercurial import (
dirstate,
......
......@@ -10,6 +10,7 @@
from __future__ import absolute_import
from mercurial.i18n import _
from mercurial.pycompat import open
from mercurial import util
from . import (
......
......@@ -14,6 +14,8 @@ import os
from mercurial.i18n import _
from mercurial.pycompat import open
from mercurial.hgweb import webcommands
from mercurial import (
......
......@@ -8,6 +8,7 @@ import os
import re
from mercurial.i18n import _
from mercurial.pycompat import open
from mercurial import (
error,
......
......@@ -76,6 +76,7 @@ from mercurial.node import (
nullrev,
short,
)
from mercurial.pycompat import open
from mercurial import (
cmdutil,
commands,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment