##// END OF EJS Templates
compat: use open() instead of file() everywhere
Alejandro Santos -
r9031:3b76321a default
parent child Browse files
Show More
@@ -38,8 +38,8 class convert_cvs(converter_source):
38 38 self.lastbranch = {}
39 39 self.parent = {}
40 40 self.socket = None
41 self.cvsroot = file(os.path.join(cvs, "Root")).read()[:-1]
42 self.cvsrepo = file(os.path.join(cvs, "Repository")).read()[:-1]
41 self.cvsroot = open(os.path.join(cvs, "Root")).read()[:-1]
42 self.cvsrepo = open(os.path.join(cvs, "Repository")).read()[:-1]
43 43 self.encoding = locale.getpreferredencoding()
44 44
45 45 self._connect()
@@ -130,7 +130,7 def createlog(ui, directory=None, root="
130 130
131 131 # Get the real directory in the repository
132 132 try:
133 prefix = file(os.path.join('CVS','Repository')).read().strip()
133 prefix = open(os.path.join('CVS','Repository')).read().strip()
134 134 if prefix == ".":
135 135 prefix = ""
136 136 directory = prefix
@@ -142,7 +142,7 def createlog(ui, directory=None, root="
142 142
143 143 # Use the Root file in the sandbox, if it exists
144 144 try:
145 root = file(os.path.join('CVS','Root')).read().strip()
145 root = open(os.path.join('CVS','Root')).read().strip()
146 146 except IOError:
147 147 pass
148 148
@@ -175,7 +175,7 def createlog(ui, directory=None, root="
175 175 if cache == 'update':
176 176 try:
177 177 ui.note(_('reading cvs log cache %s\n') % cachefile)
178 oldlog = pickle.load(file(cachefile))
178 oldlog = pickle.load(open(cachefile))
179 179 ui.note(_('cache has %d log entries\n') % len(oldlog))
180 180 except Exception, e:
181 181 ui.note(_('error reading cache: %r\n') % e)
@@ -445,7 +445,7 def createlog(ui, directory=None, root="
445 445
446 446 # write the new cachefile
447 447 ui.note(_('writing cvs log cache %s\n') % cachefile)
448 pickle.dump(log, file(cachefile, 'w'))
448 pickle.dump(log, open(cachefile, 'w'))
449 449 else:
450 450 log = oldlog
451 451
@@ -750,7 +750,7 def debugcomplete(ui, cmd='', **opts):
750 750 ui.write("%s\n" % "\n".join(sorted(cmdlist)))
751 751
752 752 def debugfsinfo(ui, path = "."):
753 file('.debugfsinfo', 'w').write('')
753 open('.debugfsinfo', 'w').write('')
754 754 ui.write('exec: %s\n' % (util.checkexec(path) and 'yes' or 'no'))
755 755 ui.write('symlink: %s\n' % (util.checklink(path) and 'yes' or 'no'))
756 756 ui.write('case-sensitive: %s\n' % (util.checkcase('.debugfsinfo')
@@ -983,7 +983,7 def debuginstall(ui):
983 983 if list(files) != [os.path.basename(fa)]:
984 984 ui.write(_(" unexpected patch output!\n"))
985 985 patchproblems += 1
986 a = file(fa).read()
986 a = open(fa).read()
987 987 if a != b:
988 988 ui.write(_(" patch test failed!\n"))
989 989 patchproblems += 1
@@ -69,7 +69,7 def staticfile(directory, fname, req):
69 69 os.stat(path)
70 70 ct = mimetypes.guess_type(path)[0] or "text/plain"
71 71 req.respond(HTTP_OK, ct, length = os.path.getsize(path))
72 return file(path, 'rb').read()
72 return open(path, 'rb').read()
73 73 except TypeError:
74 74 raise ErrorResponse(HTTP_SERVER_ERROR, 'illegal filename')
75 75 except OSError, err:
@@ -1139,7 +1139,7 def internalpatch(patchobj, ui, strip, c
1139 1139 raise util.Abort(_('Unsupported line endings type: %s') % eolmode)
1140 1140
1141 1141 try:
1142 fp = file(patchobj, 'rb')
1142 fp = open(patchobj, 'rb')
1143 1143 except TypeError:
1144 1144 fp = patchobj
1145 1145 if cwd:
@@ -9,7 +9,7 from i18n import _
9 9 import osutil
10 10 import os, sys, errno, stat, getpass, pwd, grp
11 11
12 posixfile = file
12 posixfile = open
13 13 nulldev = '/dev/null'
14 14 normpath = os.path.normpath
15 15 samestat = os.path.samestat
@@ -70,20 +70,20 def set_flags(f, l, x):
70 70 if l:
71 71 if not stat.S_ISLNK(s):
72 72 # switch file to link
73 data = file(f).read()
73 data = open(f).read()
74 74 os.unlink(f)
75 75 try:
76 76 os.symlink(data, f)
77 77 except:
78 78 # failed to make a link, rewrite file
79 file(f, "w").write(data)
79 open(f, "w").write(data)
80 80 # no chmod needed at this point
81 81 return
82 82 if stat.S_ISLNK(s):
83 83 # switch link to file
84 84 data = os.readlink(f)
85 85 os.unlink(f)
86 file(f, "w").write(data)
86 open(f, "w").write(data)
87 87 s = 0666 & ~umask # avoid restatting for chmod
88 88
89 89 sx = s & 0100
@@ -8,7 +8,7
8 8 import os
9 9 import stat as _stat
10 10
11 posixfile = file
11 posixfile = open
12 12
13 13 def _mode_to_kind(mode):
14 14 if _stat.S_ISREG(mode): return _stat.S_IFREG
@@ -143,7 +143,7 elif os.path.exists('.hg_archival.txt'):
143 143 break
144 144
145 145 if version:
146 f = file("mercurial/__version__.py", "w")
146 f = open("mercurial/__version__.py", "w")
147 147 f.write('# this file is autogenerated by setup.py\n')
148 148 f.write('version = "%s"\n' % version)
149 149 f.close()
@@ -4,7 +4,7 import os, sys, time, errno, signal
4 4
5 5 # Kill off any leftover daemon processes
6 6 try:
7 fp = file(os.environ['DAEMON_PIDS'])
7 fp = open(os.environ['DAEMON_PIDS'])
8 8 for line in fp:
9 9 try:
10 10 pid = int(line)
@@ -419,7 +419,7 def runone(options, test, skips, fails):
419 419 vlog("# Test", test)
420 420
421 421 # create a fresh hgrc
422 hgrc = file(HGRCPATH, 'w+')
422 hgrc = open(HGRCPATH, 'w+')
423 423 hgrc.write('[ui]\n')
424 424 hgrc.write('slash = True\n')
425 425 hgrc.write('[defaults]\n')
@@ -525,7 +525,7 def runone(options, test, skips, fails):
525 525
526 526 # Kill off any leftover daemon processes
527 527 try:
528 fp = file(DAEMON_PIDS)
528 fp = open(DAEMON_PIDS)
529 529 for line in fp:
530 530 try:
531 531 pid = int(line)
@@ -7,7 +7,7 repo = hg.repository(u, 'test1', create=
7 7 os.chdir('test1')
8 8
9 9 # create 'foo' with fixed time stamp
10 f = file('foo', 'w')
10 f = open('foo', 'w')
11 11 f.write('foo\n')
12 12 f.close()
13 13 os.utime('foo', (1000, 1000))
@@ -15,14 +15,14 testdispatch("init test1")
15 15 os.chdir('test1')
16 16
17 17 # create file 'foo', add and commit
18 f = file('foo', 'wb')
18 f = open('foo', 'wb')
19 19 f.write('foo\n')
20 20 f.close()
21 21 testdispatch("add foo")
22 22 testdispatch("commit -m commit1 -d 2000-01-01 foo")
23 23
24 24 # append to file 'foo' and commit
25 f = file('foo', 'ab')
25 f = open('foo', 'ab')
26 26 f.write('bar\n')
27 27 f.close()
28 28 testdispatch("commit -m commit2 -d 2000-01-02 foo")
@@ -10,7 +10,7 def commit(text, time):
10 10 repo.commit(text=text, date="%d 0" % time)
11 11
12 12 def addcommit(name, time):
13 f = file(name, 'w')
13 f = open(name, 'w')
14 14 f.write('%s\n' % name)
15 15 f.close()
16 16 repo.add([name])
General Comments 0
You need to be logged in to leave comments. Login now