diff --git a/hgext/convert/monotone.py b/hgext/convert/monotone.py --- a/hgext/convert/monotone.py +++ b/hgext/convert/monotone.py @@ -37,7 +37,7 @@ if not os.path.exists(os.path.join(path, '_MTN')): # Could be a monotone repository (SQLite db file) try: - f = file(path, 'rb') + f = open(path, 'rb') header = f.read(16) f.close() except IOError: diff --git a/hgext/rebase.py b/hgext/rebase.py --- a/hgext/rebase.py +++ b/hgext/rebase.py @@ -1440,7 +1440,7 @@ def isagitpatch(repo, patchname): 'Return true if the given patch is in git format' mqpatch = os.path.join(repo.mq.path, patchname) - for line in patch.linereader(file(mqpatch, 'rb')): + for line in patch.linereader(open(mqpatch, 'rb')): if line.startswith('diff --git'): return True return False diff --git a/hgext/relink.py b/hgext/relink.py --- a/hgext/relink.py +++ b/hgext/relink.py @@ -168,8 +168,8 @@ source = os.path.join(src, f) tgt = os.path.join(dst, f) # Binary mode, so that read() works correctly, especially on Windows - sfp = file(source, 'rb') - dfp = file(tgt, 'rb') + sfp = open(source, 'rb') + dfp = open(tgt, 'rb') sin = sfp.read(CHUNKLEN) while sin: din = dfp.read(CHUNKLEN) diff --git a/tests/test-hgweb.t b/tests/test-hgweb.t --- a/tests/test-hgweb.t +++ b/tests/test-hgweb.t @@ -333,7 +333,7 @@ Test the access/error files are opened in append mode - $ $PYTHON -c "print len(file('access.log').readlines()), 'log lines written'" + $ $PYTHON -c "print len(open('access.log', 'rb').readlines()), 'log lines written'" 14 log lines written static file diff --git a/tests/test-impexp-branch.t b/tests/test-impexp-branch.t --- a/tests/test-impexp-branch.t +++ b/tests/test-impexp-branch.t @@ -74,9 +74,9 @@ $ hg strip --no-backup . 1 files updated, 0 files merged, 0 files removed, 0 files unresolved >>> import re - >>> p = file('../r1.patch', 'rb').read() + >>> p = open('../r1.patch', 'rb').read() >>> p = re.sub(r'Parent\s+', 'Parent ', p) - >>> file('../r1-ws.patch', 'wb').write(p) + >>> open('../r1-ws.patch', 'wb').write(p) $ hg import --exact ../r1-ws.patch applying ../r1-ws.patch diff --git a/tests/test-import-context.t b/tests/test-import-context.t --- a/tests/test-import-context.t +++ b/tests/test-import-context.t @@ -7,7 +7,7 @@ > lasteol = sys.argv[2] == '1' > patterns = sys.argv[3:] > - > fp = file(path, 'wb') + > fp = open(path, 'wb') > for i, pattern in enumerate(patterns): > count = int(pattern[0:-1]) > char = pattern[-1] + '\n' @@ -19,7 +19,7 @@ > EOF $ cat > cat.py < import sys - > sys.stdout.write(repr(file(sys.argv[1], 'rb').read()) + '\n') + > sys.stdout.write(repr(open(sys.argv[1], 'rb').read()) + '\n') > EOF Initialize the test repository diff --git a/tests/test-notify.t b/tests/test-notify.t --- a/tests/test-notify.t +++ b/tests/test-notify.t @@ -421,7 +421,7 @@ > test = False > mbox = mbox > EOF - $ $PYTHON -c 'file("a/a", "ab").write("no" * 500 + "\xd1\x84" + "\n")' + $ $PYTHON -c 'open("a/a", "ab").write("no" * 500 + "\xd1\x84" + "\n")' $ hg --cwd a commit -A -m "long line" $ hg --traceback --cwd b pull ../a pulling from ../a