##// END OF EJS Templates
py3: replace file() with open()...
Pulkit Goyal -
r36412:4bc98356 default
parent child Browse files
Show More
@@ -37,7 +37,7 b' class monotone_source(common.converter_s'
37 if not os.path.exists(os.path.join(path, '_MTN')):
37 if not os.path.exists(os.path.join(path, '_MTN')):
38 # Could be a monotone repository (SQLite db file)
38 # Could be a monotone repository (SQLite db file)
39 try:
39 try:
40 f = file(path, 'rb')
40 f = open(path, 'rb')
41 header = f.read(16)
41 header = f.read(16)
42 f.close()
42 f.close()
43 except IOError:
43 except IOError:
@@ -1440,7 +1440,7 b' def defineparents(repo, rev, destmap, st'
1440 def isagitpatch(repo, patchname):
1440 def isagitpatch(repo, patchname):
1441 'Return true if the given patch is in git format'
1441 'Return true if the given patch is in git format'
1442 mqpatch = os.path.join(repo.mq.path, patchname)
1442 mqpatch = os.path.join(repo.mq.path, patchname)
1443 for line in patch.linereader(file(mqpatch, 'rb')):
1443 for line in patch.linereader(open(mqpatch, 'rb')):
1444 if line.startswith('diff --git'):
1444 if line.startswith('diff --git'):
1445 return True
1445 return True
1446 return False
1446 return False
@@ -168,8 +168,8 b' def do_relink(src, dst, files, ui):'
168 source = os.path.join(src, f)
168 source = os.path.join(src, f)
169 tgt = os.path.join(dst, f)
169 tgt = os.path.join(dst, f)
170 # Binary mode, so that read() works correctly, especially on Windows
170 # Binary mode, so that read() works correctly, especially on Windows
171 sfp = file(source, 'rb')
171 sfp = open(source, 'rb')
172 dfp = file(tgt, 'rb')
172 dfp = open(tgt, 'rb')
173 sin = sfp.read(CHUNKLEN)
173 sin = sfp.read(CHUNKLEN)
174 while sin:
174 while sin:
175 din = dfp.read(CHUNKLEN)
175 din = dfp.read(CHUNKLEN)
@@ -333,7 +333,7 b' stop and restart'
333
333
334 Test the access/error files are opened in append mode
334 Test the access/error files are opened in append mode
335
335
336 $ $PYTHON -c "print len(file('access.log').readlines()), 'log lines written'"
336 $ $PYTHON -c "print len(open('access.log', 'rb').readlines()), 'log lines written'"
337 14 log lines written
337 14 log lines written
338
338
339 static file
339 static file
@@ -74,9 +74,9 b' Test --exact and patch header separators'
74 $ hg strip --no-backup .
74 $ hg strip --no-backup .
75 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
75 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
76 >>> import re
76 >>> import re
77 >>> p = file('../r1.patch', 'rb').read()
77 >>> p = open('../r1.patch', 'rb').read()
78 >>> p = re.sub(r'Parent\s+', 'Parent ', p)
78 >>> p = re.sub(r'Parent\s+', 'Parent ', p)
79 >>> file('../r1-ws.patch', 'wb').write(p)
79 >>> open('../r1-ws.patch', 'wb').write(p)
80 $ hg import --exact ../r1-ws.patch
80 $ hg import --exact ../r1-ws.patch
81 applying ../r1-ws.patch
81 applying ../r1-ws.patch
82
82
@@ -7,7 +7,7 b' Test applying context diffs'
7 > lasteol = sys.argv[2] == '1'
7 > lasteol = sys.argv[2] == '1'
8 > patterns = sys.argv[3:]
8 > patterns = sys.argv[3:]
9 >
9 >
10 > fp = file(path, 'wb')
10 > fp = open(path, 'wb')
11 > for i, pattern in enumerate(patterns):
11 > for i, pattern in enumerate(patterns):
12 > count = int(pattern[0:-1])
12 > count = int(pattern[0:-1])
13 > char = pattern[-1] + '\n'
13 > char = pattern[-1] + '\n'
@@ -19,7 +19,7 b' Test applying context diffs'
19 > EOF
19 > EOF
20 $ cat > cat.py <<EOF
20 $ cat > cat.py <<EOF
21 > import sys
21 > import sys
22 > sys.stdout.write(repr(file(sys.argv[1], 'rb').read()) + '\n')
22 > sys.stdout.write(repr(open(sys.argv[1], 'rb').read()) + '\n')
23 > EOF
23 > EOF
24
24
25 Initialize the test repository
25 Initialize the test repository
@@ -421,7 +421,7 b' long lines'
421 > test = False
421 > test = False
422 > mbox = mbox
422 > mbox = mbox
423 > EOF
423 > EOF
424 $ $PYTHON -c 'file("a/a", "ab").write("no" * 500 + "\xd1\x84" + "\n")'
424 $ $PYTHON -c 'open("a/a", "ab").write("no" * 500 + "\xd1\x84" + "\n")'
425 $ hg --cwd a commit -A -m "long line"
425 $ hg --cwd a commit -A -m "long line"
426 $ hg --traceback --cwd b pull ../a
426 $ hg --traceback --cwd b pull ../a
427 pulling from ../a
427 pulling from ../a
General Comments 0
You need to be logged in to leave comments. Login now