changeset 48879:9987d14ad63f

py2: drop some more from __future__ statements These are no longer needed after dropping support for Python 2. Differential Revision: https://phab.mercurial-scm.org/D12258
author Gregory Szorc <gregory.szorc@gmail.com>
date Sun, 20 Feb 2022 15:35:09 -0700
parents 0583d7f0fdff
children 431084a68c4a
files contrib/import-checker.py tests/test-commandserver.t tests/test-convert-git.t tests/test-generaldelta.t tests/test-hgrc.t tests/test-hgweb.t tests/test-keyword.t tests/test-lfs-serve.t tests/test-notify-changegroup.t tests/test-pull-network.t tests/test-rename.t tests/test-status.t tests/test-subrepo-svn.t tests/test-template-functions.t tests/test-unified-test.t tests/test-upgrade-repo.t
diffstat 16 files changed, 9 insertions(+), 23 deletions(-) [+]
line wrap: on
line diff
--- a/contrib/import-checker.py	Sun Feb 20 15:31:33 2022 -0700
+++ b/contrib/import-checker.py	Sun Feb 20 15:35:09 2022 -0700
@@ -626,7 +626,6 @@
 
     All module names recorded in `imports` should be absolute one.
 
-    >>> from __future__ import print_function
     >>> imports = {'top.foo': ['top.bar', 'os.path', 'top.qux'],
     ...            'top.bar': ['top.baz', 'sys'],
     ...            'top.baz': ['top.foo'],
--- a/tests/test-commandserver.t	Sun Feb 20 15:31:33 2022 -0700
+++ b/tests/test-commandserver.t	Sun Feb 20 15:35:09 2022 -0700
@@ -23,7 +23,6 @@
   $ hg init repo
   $ cd repo
 
-  >>> from __future__ import absolute_import
   >>> import os
   >>> import sys
   >>> from hgclient import bprint, check, readchannel, runcommand
--- a/tests/test-convert-git.t	Sun Feb 20 15:31:33 2022 -0700
+++ b/tests/test-convert-git.t	Sun Feb 20 15:35:09 2022 -0700
@@ -435,7 +435,7 @@
   $ cd git-repo3-hg
   $ hg up -C
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
-  $ "$PYTHON" -c 'from __future__ import print_function; print(len(open("b", "rb").read()))'
+  $ "$PYTHON" -c 'print(len(open("b", "rb").read()))'
   4096
   $ cd ..
 
--- a/tests/test-generaldelta.t	Sun Feb 20 15:31:33 2022 -0700
+++ b/tests/test-generaldelta.t	Sun Feb 20 15:35:09 2022 -0700
@@ -25,7 +25,6 @@
   > 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
--- a/tests/test-hgrc.t	Sun Feb 20 15:31:33 2022 -0700
+++ b/tests/test-hgrc.t	Sun Feb 20 15:35:09 2022 -0700
@@ -71,7 +71,7 @@
   config error at $TESTTMP/hgrc:2: unexpected leading whitespace:   x = y
   [255]
 
-  $ "$PYTHON" -c "from __future__ import print_function; print('[foo]\nbar = a\n b\n c \n  de\n fg \nbaz = bif cb \n')" \
+  $ "$PYTHON" -c "print('[foo]\nbar = a\n b\n c \n  de\n fg \nbaz = bif cb \n')" \
   > > $HGRC
   $ hg showconfig foo
   foo.bar=a\nb\nc\nde\nfg
--- a/tests/test-hgweb.t	Sun Feb 20 15:31:33 2022 -0700
+++ b/tests/test-hgweb.t	Sun Feb 20 15:35:09 2022 -0700
@@ -329,7 +329,7 @@
 
 Test the access/error files are opened in append mode
 
-  $ "$PYTHON" -c "from __future__ import print_function; print(len(open('access.log', 'rb').readlines()), 'log lines written')"
+  $ "$PYTHON" -c "print(len(open('access.log', 'rb').readlines()), 'log lines written')"
   14 log lines written
 
 static file
--- a/tests/test-keyword.t	Sun Feb 20 15:31:33 2022 -0700
+++ b/tests/test-keyword.t	Sun Feb 20 15:35:09 2022 -0700
@@ -1412,7 +1412,6 @@
   $ grep -v '^promptecho ' < $HGRCPATH >> $HGRCPATH.new
   $ mv $HGRCPATH.new $HGRCPATH
 
-  >>> from __future__ import print_function
   >>> from hgclient import check, readchannel, runcommand
   >>> @check
   ... def check(server):
--- a/tests/test-lfs-serve.t	Sun Feb 20 15:31:33 2022 -0700
+++ b/tests/test-lfs-serve.t	Sun Feb 20 15:35:09 2022 -0700
@@ -107,7 +107,6 @@
 
   $ cd client
   $ echo 'non-lfs' > nonlfs.txt
-  >>> from __future__ import absolute_import
   >>> from hgclient import check, readchannel, runcommand
   >>> @check
   ... def diff(server):
@@ -240,7 +239,6 @@
 
   $ cd ../cmdserve_client3
 
-  >>> from __future__ import absolute_import
   >>> from hgclient import check, readchannel, runcommand
   >>> @check
   ... def addrequirement(server):
@@ -355,7 +353,6 @@
   $ mv $HGRCPATH $HGRCPATH.tmp
   $ cp $HGRCPATH.orig $HGRCPATH
 
-  >>> from __future__ import absolute_import
   >>> from hgclient import bprint, check, readchannel, runcommand, stdout
   >>> @check
   ... def checkflags(server):
@@ -404,7 +401,6 @@
   > lfs = !
   > EOF
 
-  >>> from __future__ import absolute_import, print_function
   >>> from hgclient import bprint, check, readchannel, runcommand, stdout
   >>> @check
   ... def checkflags2(server):
--- a/tests/test-notify-changegroup.t	Sun Feb 20 15:31:33 2022 -0700
+++ b/tests/test-notify-changegroup.t	Sun Feb 20 15:35:09 2022 -0700
@@ -40,7 +40,7 @@
 
   $ hg --traceback --cwd b push ../a 2>&1 |
   >     "$PYTHON" $TESTDIR/unwrap-message-id.py | \
-  >     "$PYTHON" -c 'from __future__ import print_function ; import sys,re; print(re.sub("\n\t", " ", sys.stdin.read()), end="")'
+  >     "$PYTHON" -c 'import sys,re; print(re.sub("\n\t", " ", sys.stdin.read()), end="")'
   pushing to ../a
   searching for changes
   adding changesets
@@ -95,7 +95,7 @@
 
   $ hg --config notify.sources=unbundle --cwd a unbundle ../test.hg 2>&1 |
   >     "$PYTHON" $TESTDIR/unwrap-message-id.py | \
-  >     "$PYTHON" -c 'from __future__ import print_function ; import sys,re; print(re.sub("\n\t", " ", sys.stdin.read()), end="")'
+  >     "$PYTHON" -c 'import sys,re; print(re.sub("\n\t", " ", sys.stdin.read()), end="")'
   adding changesets
   adding manifests
   adding file changes
@@ -172,7 +172,7 @@
 
   $ hg --traceback --cwd b --config notify.fromauthor=True push ../a 2>&1 |
   >     "$PYTHON" $TESTDIR/unwrap-message-id.py | \
-  >     "$PYTHON" -c 'from __future__ import print_function ; import sys,re; print(re.sub("\n\t", " ", sys.stdin.read()), end="")'
+  >     "$PYTHON" -c 'import sys,re; print(re.sub("\n\t", " ", sys.stdin.read()), end="")'
   pushing to ../a
   searching for changes
   adding changesets
--- a/tests/test-pull-network.t	Sun Feb 20 15:31:33 2022 -0700
+++ b/tests/test-pull-network.t	Sun Feb 20 15:35:09 2022 -0700
@@ -90,12 +90,12 @@
 It's tricky to make file:// URLs working on every platform with
 regular shell commands.
 
-  $ URL=`"$PYTHON" -c "from __future__ import print_function; import os; print('file://foobar' + ('/' + os.getcwd().replace(os.sep, '/')).replace('//', '/') + '/../test')"`
+  $ URL=`"$PYTHON" -c "import os; print('file://foobar' + ('/' + os.getcwd().replace(os.sep, '/')).replace('//', '/') + '/../test')"`
   $ hg pull -q "$URL"
   abort: file:// URLs can only refer to localhost
   [255]
 
-  $ URL=`"$PYTHON" -c "from __future__ import print_function; import os; print('file://localhost' + ('/' + os.getcwd().replace(os.sep, '/')).replace('//', '/') + '/../test')"`
+  $ URL=`"$PYTHON" -c "import os; print('file://localhost' + ('/' + os.getcwd().replace(os.sep, '/')).replace('//', '/') + '/../test')"`
   $ hg pull -q "$URL"
 
 SEC: check for unsafe ssh url
--- a/tests/test-rename.t	Sun Feb 20 15:31:33 2022 -0700
+++ b/tests/test-rename.t	Sun Feb 20 15:35:09 2022 -0700
@@ -682,7 +682,6 @@
 "hg cp" does not preserve the mtime, so it should be newer than the 2009
 timestamp.
   $ hg cp -q mtime mtime_cp
-  >>> from __future__ import print_function
   >>> import os
   >>> filename = "mtime_cp/f"
   >>> print(os.stat(filename).st_mtime < 1234567999)
@@ -691,7 +690,6 @@
 (modulo some fudge factor due to not every system supporting 1s-level
 precision).
   $ hg mv -q mtime mtime_mv
-  >>> from __future__ import print_function
   >>> import os
   >>> filename = "mtime_mv/f"
   >>> print(os.stat(filename).st_mtime < 1234567999)
--- a/tests/test-status.t	Sun Feb 20 15:31:33 2022 -0700
+++ b/tests/test-status.t	Sun Feb 20 15:35:09 2022 -0700
@@ -315,7 +315,6 @@
   ]
 
   $ hg status -A -Tpickle > pickle
-  >>> from __future__ import print_function
   >>> import pickle
   >>> from mercurial import util
   >>> data = sorted((x[b'status'].decode(), x[b'path'].decode()) for x in pickle.load(open("pickle", r"rb")))
--- a/tests/test-subrepo-svn.t	Sun Feb 20 15:31:33 2022 -0700
+++ b/tests/test-subrepo-svn.t	Sun Feb 20 15:35:09 2022 -0700
@@ -249,7 +249,7 @@
 
 verify subrepo is contained within the repo directory
 
-  $ "$PYTHON" -c "from __future__ import print_function; import os.path; print(os.path.exists('s'))"
+  $ "$PYTHON" -c "import os.path; print(os.path.exists('s'))"
   True
 
 update to nullrev (must delete the subrepo)
--- a/tests/test-template-functions.t	Sun Feb 20 15:31:33 2022 -0700
+++ b/tests/test-template-functions.t	Sun Feb 20 15:35:09 2022 -0700
@@ -192,7 +192,6 @@
   $ cd unstable-hash
   $ hg log --template '{date|age}\n' > /dev/null || exit 1
 
-  >>> from __future__ import absolute_import
   >>> import datetime
   >>> fp = open('a', 'wb')
   >>> n = datetime.datetime.now() + datetime.timedelta(366 * 7)
--- a/tests/test-unified-test.t	Sun Feb 20 15:31:33 2022 -0700
+++ b/tests/test-unified-test.t	Sun Feb 20 15:35:09 2022 -0700
@@ -26,7 +26,6 @@
 
 Doctest commands:
 
-  >>> from __future__ import print_function
   >>> print('foo')
   foo
   $ echo interleaved
--- a/tests/test-upgrade-repo.t	Sun Feb 20 15:31:33 2022 -0700
+++ b/tests/test-upgrade-repo.t	Sun Feb 20 15:35:09 2022 -0700
@@ -734,7 +734,6 @@
   $ touch FooBarDirectory.d/f1
   $ hg -q commit -A -m 'add f1'
   $ hg -q up -r 0
-  >>> from __future__ import absolute_import, print_function
   >>> import random
   >>> random.seed(0) # have a reproducible content
   >>> with open("f2", "wb") as f: