tests: clean up many print statements to be print functions instead
Differential Revision: https://phab.mercurial-scm.org/D294
--- a/tests/test-commit-interactive-curses.t Thu Jun 15 13:32:32 2017 -0400
+++ b/tests/test-commit-interactive-curses.t Thu Jun 15 14:22:25 2017 -0400
@@ -345,7 +345,7 @@
> $PYTHON <<EOF
> from mercurial import hg, ui;\
> repo = hg.repository(ui.ui.load(), ".");\
- > print repo.ui.interface("chunkselector")
+ > print(repo.ui.interface("chunkselector"))
> EOF
> }
$ chunkselectorinterface
--- a/tests/test-commit-multiple.t Thu Jun 15 13:32:32 2017 -0400
+++ b/tests/test-commit-multiple.t Thu Jun 15 14:22:25 2017 -0400
@@ -90,7 +90,7 @@
> f.close()
>
> def printfiles(repo, rev):
- > print "revision %s files: %s" % (rev, repo[rev].files())
+ > print("revision %s files: %s" % (rev, repo[rev].files()))
>
> repo = hg.repository(ui.ui.load(), '.')
> assert len(repo) == 6, \
@@ -99,14 +99,14 @@
> replacebyte("bugfix", "u")
> sleep(2)
> try:
- > print "PRE: len(repo): %d" % len(repo)
+ > print("PRE: len(repo): %d" % len(repo))
> wlock = repo.wlock()
> lock = repo.lock()
> replacebyte("file1", "x")
> repo.commit(text="x", user="test", date=(0, 0))
> replacebyte("file1", "y")
> repo.commit(text="y", user="test", date=(0, 0))
- > print "POST: len(repo): %d" % len(repo)
+ > print("POST: len(repo): %d" % len(repo))
> finally:
> lock.release()
> wlock.release()
--- a/tests/test-contrib-check-code.t Thu Jun 15 13:32:32 2017 -0400
+++ b/tests/test-contrib-check-code.t Thu Jun 15 14:22:25 2017 -0400
@@ -213,32 +213,32 @@
[1]
$ cat > ./map-inside-gettext.py <<EOF
- > print _("map inside gettext %s" % v)
+ > print(_("map inside gettext %s" % v))
>
- > print _("concatenating " " by " " space %s" % v)
- > print _("concatenating " + " by " + " '+' %s" % v)
+ > print(_("concatenating " " by " " space %s" % v))
+ > print(_("concatenating " + " by " + " '+' %s" % v))
>
- > print _("mapping operation in different line %s"
- > % v)
+ > print(_("mapping operation in different line %s"
+ > % v))
>
- > print _(
- > "leading spaces inside of '(' %s" % v)
+ > print(_(
+ > "leading spaces inside of '(' %s" % v))
> EOF
$ "$check_code" ./map-inside-gettext.py
./map-inside-gettext.py:1:
- > print _("map inside gettext %s" % v)
+ > print(_("map inside gettext %s" % v))
don't use % inside _()
./map-inside-gettext.py:3:
- > print _("concatenating " " by " " space %s" % v)
+ > print(_("concatenating " " by " " space %s" % v))
don't use % inside _()
./map-inside-gettext.py:4:
- > print _("concatenating " + " by " + " '+' %s" % v)
+ > print(_("concatenating " + " by " + " '+' %s" % v))
don't use % inside _()
./map-inside-gettext.py:6:
- > print _("mapping operation in different line %s"
+ > print(_("mapping operation in different line %s"
don't use % inside _()
./map-inside-gettext.py:9:
- > print _(
+ > print(_(
don't use % inside _()
[1]
--- a/tests/test-convert-cvs.t Thu Jun 15 13:32:32 2017 -0400
+++ b/tests/test-convert-cvs.t Thu Jun 15 14:22:25 2017 -0400
@@ -12,10 +12,10 @@
$ echo "convert = " >> $HGRCPATH
$ cat > cvshooks.py <<EOF
> def cvslog(ui,repo,hooktype,log):
- > print "%s hook: %d entries"%(hooktype,len(log))
+ > print("%s hook: %d entries"%(hooktype,len(log)))
>
> def cvschangesets(ui,repo,hooktype,changesets):
- > print "%s hook: %d changesets"%(hooktype,len(changesets))
+ > print("%s hook: %d changesets"%(hooktype,len(changesets)))
> EOF
$ hookpath=`pwd`
$ cat <<EOF >> $HGRCPATH
--- a/tests/test-eol.t Thu Jun 15 13:32:32 2017 -0400
+++ b/tests/test-eol.t Thu Jun 15 14:22:25 2017 -0400
@@ -16,7 +16,7 @@
> except ImportError:
> pass
> (old, new) = sys.argv[1] == 'LF' and ('\n', '\r\n') or ('\r\n', '\n')
- > print "%% switching encoding from %r to %r" % (old, new)
+ > print("%% switching encoding from %r to %r" % (old, new))
> for path in sys.argv[2:]:
> data = file(path, 'rb').read()
> data = data.replace(old, new)
--- a/tests/test-extension.t Thu Jun 15 13:32:32 2017 -0400
+++ b/tests/test-extension.t Thu Jun 15 14:22:25 2017 -0400
@@ -75,13 +75,13 @@
$ cat > foo.py <<EOF
> import os
> name = os.path.basename(__file__).rsplit('.', 1)[0]
- > print "1) %s imported" % name
+ > print("1) %s imported" % name)
> def uisetup(ui):
- > print "2) %s uisetup" % name
+ > print("2) %s uisetup" % name)
> def extsetup():
- > print "3) %s extsetup" % name
+ > print("3) %s extsetup" % name)
> def reposetup(ui, repo):
- > print "4) %s reposetup" % name
+ > print("4) %s reposetup" % name)
>
> # custom predicate to check registration of functions at loading
> from mercurial import (
@@ -172,7 +172,7 @@
$ cat > loadabs.py <<EOF
> import mod.ambigabs as ambigabs
> def extsetup():
- > print 'ambigabs.s=%s' % ambigabs.s
+ > print('ambigabs.s=%s' % ambigabs.s)
> EOF
$ (PYTHONPATH=${PYTHONPATH}${PATHSEP}${TESTTMP}/libroot; hg --config extensions.loadabs=loadabs.py root)
ambigabs.s=libroot/ambig.py
@@ -186,7 +186,7 @@
$ cat > loadrel.py <<EOF
> import mod.ambigrel as ambigrel
> def extsetup():
- > print 'ambigrel.s=%s' % ambigrel.s
+ > print('ambigrel.s=%s' % ambigrel.s)
> EOF
$ (PYTHONPATH=${PYTHONPATH}${PATHSEP}${TESTTMP}/libroot; hg --config extensions.loadrel=loadrel.py root)
ambigrel.s=libroot/mod/ambig.py
--- a/tests/test-filebranch.t Thu Jun 15 13:32:32 2017 -0400
+++ b/tests/test-filebranch.t Thu Jun 15 14:22:25 2017 -0400
@@ -2,8 +2,9 @@
when we do a merge.
$ cat <<EOF > merge
+ > from __future__ import print_function
> import sys, os
- > print "merging for", os.path.basename(sys.argv[1])
+ > print("merging for", os.path.basename(sys.argv[1]))
> EOF
$ HGMERGE="$PYTHON ../merge"; export HGMERGE
--- a/tests/test-glog.t Thu Jun 15 13:32:32 2017 -0400
+++ b/tests/test-glog.t Thu Jun 15 14:22:25 2017 -0400
@@ -1633,7 +1633,7 @@
Test glob expansion of pats
$ expandglobs=`$PYTHON -c "import mercurial.util; \
- > print mercurial.util.expandglobs and 'true' or 'false'"`
+ > print(mercurial.util.expandglobs and 'true' or 'false')"`
$ if [ $expandglobs = "true" ]; then
> testlog 'a*';
> else
--- a/tests/test-hardlinks.t Thu Jun 15 13:32:32 2017 -0400
+++ b/tests/test-hardlinks.t Thu Jun 15 14:22:25 2017 -0400
@@ -1,11 +1,12 @@
#require hardlink
$ cat > nlinks.py <<EOF
+ > from __future__ import print_function
> import sys
> from mercurial import util
> for f in sorted(sys.stdin.readlines()):
> f = f[:-1]
- > print util.nlinks(f), f
+ > print(util.nlinks(f), f)
> EOF
$ nlinksdir()
--- a/tests/test-help.t Thu Jun 15 13:32:32 2017 -0400
+++ b/tests/test-help.t Thu Jun 15 14:22:25 2017 -0400
@@ -1709,7 +1709,7 @@
$ $PYTHON <<EOF | sh
> upper = "\x8bL\x98^"
- > print "hg --encoding cp932 help -e ambiguous.%s" % upper
+ > print("hg --encoding cp932 help -e ambiguous.%s" % upper)
> EOF
\x8bL\x98^ (esc)
----
@@ -1719,7 +1719,7 @@
$ $PYTHON <<EOF | sh
> lower = "\x8bl\x98^"
- > print "hg --encoding cp932 help -e ambiguous.%s" % lower
+ > print("hg --encoding cp932 help -e ambiguous.%s" % lower)
> EOF
\x8bl\x98^ (esc)
----
--- a/tests/test-hook.t Thu Jun 15 13:32:32 2017 -0400
+++ b/tests/test-hook.t Thu Jun 15 14:22:25 2017 -0400
@@ -409,6 +409,7 @@
$ cd "$TESTTMP/b"
$ cat > hooktests.py <<EOF
+ > from __future__ import print_function
> from mercurial import error
>
> uncallable = 0
@@ -418,9 +419,9 @@
> args.pop('repo', None)
> a = list(args.items())
> a.sort()
- > print 'hook args:'
+ > print('hook args:')
> for k, v in a:
- > print ' ', k, v
+ > print(' ', k, v)
>
> def passhook(**args):
> printargs(args)
@@ -445,7 +446,7 @@
> ui.note('verbose output from hook\n')
>
> def printtags(ui, repo, **args):
- > print sorted(repo.tags())
+ > print(sorted(repo.tags()))
>
> class container:
> unreachable = 1
@@ -630,7 +631,7 @@
$ cat > hookext.py <<EOF
> def autohook(**args):
- > print "Automatically installed hook"
+ > print("Automatically installed hook")
>
> def reposetup(ui, repo):
> repo.ui.setconfig("hooks", "commit.auto", autohook)
@@ -667,7 +668,7 @@
$ cd hooks
$ cat > testhooks.py <<EOF
> def testhook(**args):
- > print 'hook works'
+ > print('hook works')
> EOF
$ echo '[hooks]' > ../repo/.hg/hgrc
$ echo "pre-commit.test = python:`pwd`/testhooks.py:testhook" >> ../repo/.hg/hgrc
--- a/tests/test-inherit-mode.t Thu Jun 15 13:32:32 2017 -0400
+++ b/tests/test-inherit-mode.t Thu Jun 15 14:22:25 2017 -0400
@@ -25,13 +25,13 @@
> allnames.sort()
> for name in allnames:
> suffix = name in isdir and '/' or ''
- > print '%05o %s%s' % (os.lstat(name).st_mode & 07777, name, suffix)
+ > print('%05o %s%s' % (os.lstat(name).st_mode & 07777, name, suffix))
> EOF
$ cat >mode.py <<EOF
> import sys
> import os
- > print '%05o' % os.lstat(sys.argv[1]).st_mode
+ > print('%05o' % os.lstat(sys.argv[1]).st_mode)
> EOF
$ umask 077
--- a/tests/test-issue4074.t Thu Jun 15 13:32:32 2017 -0400
+++ b/tests/test-issue4074.t Thu Jun 15 14:22:25 2017 -0400
@@ -8,7 +8,7 @@
> print
> if random.randint(0, 100) >= 50:
> x += 1
- > print hex(x)
+ > print(hex(x))
> EOF
$ hg init a
--- a/tests/test-largefiles-cache.t Thu Jun 15 13:32:32 2017 -0400
+++ b/tests/test-largefiles-cache.t Thu Jun 15 14:22:25 2017 -0400
@@ -96,7 +96,7 @@
> #!$PYTHON
> import sys, os
> path = sys.argv[1]
- > print '%03o' % (os.lstat(path).st_mode & 0777)
+ > print('%03o' % (os.lstat(path).st_mode & 0777))
> EOF
$ chmod +x ls-l.py
--- a/tests/test-log.t Thu Jun 15 13:32:32 2017 -0400
+++ b/tests/test-log.t Thu Jun 15 14:22:25 2017 -0400
@@ -1793,7 +1793,7 @@
$ cd problematicencoding
$ $PYTHON > setup.sh <<EOF
- > print u'''
+ > print(u'''
> echo a > text
> hg add text
> hg --encoding utf-8 commit -u '\u30A2' -m none
@@ -1803,13 +1803,13 @@
> hg --encoding utf-8 commit -u none -m '\u30A2'
> echo d > text
> hg --encoding utf-8 commit -u none -m '\u30C2'
- > '''.encode('utf-8')
+ > '''.encode('utf-8'))
> EOF
$ sh < setup.sh
test in problematic encoding
$ $PYTHON > test.sh <<EOF
- > print u'''
+ > print(u'''
> hg --encoding cp932 log --template '{rev}\\n' -u '\u30A2'
> echo ====
> hg --encoding cp932 log --template '{rev}\\n' -u '\u30C2'
@@ -1817,7 +1817,7 @@
> hg --encoding cp932 log --template '{rev}\\n' -k '\u30A2'
> echo ====
> hg --encoding cp932 log --template '{rev}\\n' -k '\u30C2'
- > '''.encode('cp932')
+ > '''.encode('cp932'))
> EOF
$ sh < test.sh
0
--- a/tests/test-merge-symlinks.t Thu Jun 15 13:32:32 2017 -0400
+++ b/tests/test-merge-symlinks.t Thu Jun 15 14:22:25 2017 -0400
@@ -1,5 +1,6 @@
$ cat > echo.py <<EOF
> #!$PYTHON
+ > from __future__ import print_function
> import os, sys
> try:
> import msvcrt
@@ -9,7 +10,7 @@
> pass
>
> for k in ('HG_FILE', 'HG_MY_ISLINK', 'HG_OTHER_ISLINK', 'HG_BASE_ISLINK'):
- > print k, os.environ[k]
+ > print(k, os.environ[k])
> EOF
Create 2 heads containing the same file, once as
--- a/tests/test-merge1.t Thu Jun 15 13:32:32 2017 -0400
+++ b/tests/test-merge1.t Thu Jun 15 14:22:25 2017 -0400
@@ -1,4 +1,5 @@
$ cat <<EOF > merge
+ > from __future__ import print_function
> import sys, os
>
> try:
@@ -8,7 +9,7 @@
> except ImportError:
> pass
>
- > print "merging for", os.path.basename(sys.argv[1])
+ > print("merging for", os.path.basename(sys.argv[1]))
> EOF
$ HGMERGE="$PYTHON ../merge"; export HGMERGE
--- a/tests/test-merge6.t Thu Jun 15 13:32:32 2017 -0400
+++ b/tests/test-merge6.t Thu Jun 15 14:22:25 2017 -0400
@@ -1,6 +1,6 @@
$ cat <<EOF > merge
> import sys, os
- > print "merging for", os.path.basename(sys.argv[1])
+ > print("merging for", os.path.basename(sys.argv[1]))
> EOF
$ HGMERGE="$PYTHON ../merge"; export HGMERGE
--- a/tests/test-mq-eol.t Thu Jun 15 13:32:32 2017 -0400
+++ b/tests/test-mq-eol.t Thu Jun 15 14:22:25 2017 -0400
@@ -33,7 +33,7 @@
> for line in file(sys.argv[1], 'rb'):
> line = line.replace('\r', '<CR>')
> line = line.replace('\n', '<LF>')
- > print line
+ > print(line)
> EOF
$ hg init repo
--- a/tests/test-notify-changegroup.t Thu Jun 15 13:32:32 2017 -0400
+++ b/tests/test-notify-changegroup.t Thu Jun 15 14:22:25 2017 -0400
@@ -39,7 +39,7 @@
push
$ hg --traceback --cwd b push ../a 2>&1 |
- > $PYTHON -c 'import sys,re; print re.sub("\n\t", " ", sys.stdin.read()),'
+ > $PYTHON -c 'from __future__ import print_function ; import sys,re; print(re.sub("\n\t", " ", sys.stdin.read()), end="")'
pushing to ../a
searching for changes
adding changesets
@@ -92,7 +92,7 @@
unbundle with correct source
$ hg --config notify.sources=unbundle --cwd a unbundle ../test.hg 2>&1 |
- > $PYTHON -c 'import sys,re; print re.sub("\n\t", " ", sys.stdin.read()),'
+ > $PYTHON -c 'from __future__ import print_function ; import sys,re; print(re.sub("\n\t", " ", sys.stdin.read()), end="")'
adding changesets
adding manifests
adding file changes
@@ -167,7 +167,7 @@
push
$ hg --traceback --cwd b --config notify.fromauthor=True push ../a 2>&1 |
- > $PYTHON -c 'import sys,re; print re.sub("\n\t", " ", sys.stdin.read()),'
+ > $PYTHON -c 'from __future__ import print_function ; import sys,re; print(re.sub("\n\t", " ", sys.stdin.read()), end="")'
pushing to ../a
searching for changes
adding changesets