changeset 9031:3b76321aa0de

compat: use open() instead of file() everywhere
author Alejandro Santos <alejolp@alejolp.com>
date Sun, 05 Jul 2009 11:01:30 +0200
parents 3f56055ff1d7
children 1fa80c5428b8
files hgext/convert/cvs.py hgext/convert/cvsps.py mercurial/commands.py mercurial/hgweb/common.py mercurial/patch.py mercurial/posix.py mercurial/pure/osutil.py setup.py tests/killdaemons.py tests/run-tests.py tests/test-context.py tests/test-dispatch.py tests/test-revlog-ancestry.py
diffstat 13 files changed, 23 insertions(+), 23 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/convert/cvs.py	Sun Jul 05 11:01:01 2009 +0200
+++ b/hgext/convert/cvs.py	Sun Jul 05 11:01:30 2009 +0200
@@ -38,8 +38,8 @@
         self.lastbranch = {}
         self.parent = {}
         self.socket = None
-        self.cvsroot = file(os.path.join(cvs, "Root")).read()[:-1]
-        self.cvsrepo = file(os.path.join(cvs, "Repository")).read()[:-1]
+        self.cvsroot = open(os.path.join(cvs, "Root")).read()[:-1]
+        self.cvsrepo = open(os.path.join(cvs, "Repository")).read()[:-1]
         self.encoding = locale.getpreferredencoding()
 
         self._connect()
--- a/hgext/convert/cvsps.py	Sun Jul 05 11:01:01 2009 +0200
+++ b/hgext/convert/cvsps.py	Sun Jul 05 11:01:30 2009 +0200
@@ -130,7 +130,7 @@
 
         # Get the real directory in the repository
         try:
-            prefix = file(os.path.join('CVS','Repository')).read().strip()
+            prefix = open(os.path.join('CVS','Repository')).read().strip()
             if prefix == ".":
                 prefix = ""
             directory = prefix
@@ -142,7 +142,7 @@
 
         # Use the Root file in the sandbox, if it exists
         try:
-            root = file(os.path.join('CVS','Root')).read().strip()
+            root = open(os.path.join('CVS','Root')).read().strip()
         except IOError:
             pass
 
@@ -175,7 +175,7 @@
     if cache == 'update':
         try:
             ui.note(_('reading cvs log cache %s\n') % cachefile)
-            oldlog = pickle.load(file(cachefile))
+            oldlog = pickle.load(open(cachefile))
             ui.note(_('cache has %d log entries\n') % len(oldlog))
         except Exception, e:
             ui.note(_('error reading cache: %r\n') % e)
@@ -445,7 +445,7 @@
 
             # write the new cachefile
             ui.note(_('writing cvs log cache %s\n') % cachefile)
-            pickle.dump(log, file(cachefile, 'w'))
+            pickle.dump(log, open(cachefile, 'w'))
         else:
             log = oldlog
 
--- a/mercurial/commands.py	Sun Jul 05 11:01:01 2009 +0200
+++ b/mercurial/commands.py	Sun Jul 05 11:01:30 2009 +0200
@@ -750,7 +750,7 @@
     ui.write("%s\n" % "\n".join(sorted(cmdlist)))
 
 def debugfsinfo(ui, path = "."):
-    file('.debugfsinfo', 'w').write('')
+    open('.debugfsinfo', 'w').write('')
     ui.write('exec: %s\n' % (util.checkexec(path) and 'yes' or 'no'))
     ui.write('symlink: %s\n' % (util.checklink(path) and 'yes' or 'no'))
     ui.write('case-sensitive: %s\n' % (util.checkcase('.debugfsinfo')
@@ -983,7 +983,7 @@
         if list(files) != [os.path.basename(fa)]:
             ui.write(_(" unexpected patch output!\n"))
             patchproblems += 1
-        a = file(fa).read()
+        a = open(fa).read()
         if a != b:
             ui.write(_(" patch test failed!\n"))
             patchproblems += 1
--- a/mercurial/hgweb/common.py	Sun Jul 05 11:01:01 2009 +0200
+++ b/mercurial/hgweb/common.py	Sun Jul 05 11:01:30 2009 +0200
@@ -69,7 +69,7 @@
         os.stat(path)
         ct = mimetypes.guess_type(path)[0] or "text/plain"
         req.respond(HTTP_OK, ct, length = os.path.getsize(path))
-        return file(path, 'rb').read()
+        return open(path, 'rb').read()
     except TypeError:
         raise ErrorResponse(HTTP_SERVER_ERROR, 'illegal filename')
     except OSError, err:
--- a/mercurial/patch.py	Sun Jul 05 11:01:01 2009 +0200
+++ b/mercurial/patch.py	Sun Jul 05 11:01:30 2009 +0200
@@ -1139,7 +1139,7 @@
         raise util.Abort(_('Unsupported line endings type: %s') % eolmode)
 
     try:
-        fp = file(patchobj, 'rb')
+        fp = open(patchobj, 'rb')
     except TypeError:
         fp = patchobj
     if cwd:
--- a/mercurial/posix.py	Sun Jul 05 11:01:01 2009 +0200
+++ b/mercurial/posix.py	Sun Jul 05 11:01:30 2009 +0200
@@ -9,7 +9,7 @@
 import osutil
 import os, sys, errno, stat, getpass, pwd, grp
 
-posixfile = file
+posixfile = open
 nulldev = '/dev/null'
 normpath = os.path.normpath
 samestat = os.path.samestat
@@ -70,20 +70,20 @@
     if l:
         if not stat.S_ISLNK(s):
             # switch file to link
-            data = file(f).read()
+            data = open(f).read()
             os.unlink(f)
             try:
                 os.symlink(data, f)
             except:
                 # failed to make a link, rewrite file
-                file(f, "w").write(data)
+                open(f, "w").write(data)
         # no chmod needed at this point
         return
     if stat.S_ISLNK(s):
         # switch link to file
         data = os.readlink(f)
         os.unlink(f)
-        file(f, "w").write(data)
+        open(f, "w").write(data)
         s = 0666 & ~umask # avoid restatting for chmod
 
     sx = s & 0100
--- a/mercurial/pure/osutil.py	Sun Jul 05 11:01:01 2009 +0200
+++ b/mercurial/pure/osutil.py	Sun Jul 05 11:01:30 2009 +0200
@@ -8,7 +8,7 @@
 import os
 import stat as _stat
 
-posixfile = file
+posixfile = open
 
 def _mode_to_kind(mode):
     if _stat.S_ISREG(mode): return _stat.S_IFREG
--- a/setup.py	Sun Jul 05 11:01:01 2009 +0200
+++ b/setup.py	Sun Jul 05 11:01:30 2009 +0200
@@ -143,7 +143,7 @@
             break
 
 if version:
-    f = file("mercurial/__version__.py", "w")
+    f = open("mercurial/__version__.py", "w")
     f.write('# this file is autogenerated by setup.py\n')
     f.write('version = "%s"\n' % version)
     f.close()
--- a/tests/killdaemons.py	Sun Jul 05 11:01:01 2009 +0200
+++ b/tests/killdaemons.py	Sun Jul 05 11:01:30 2009 +0200
@@ -4,7 +4,7 @@
 
 # Kill off any leftover daemon processes
 try:
-    fp = file(os.environ['DAEMON_PIDS'])
+    fp = open(os.environ['DAEMON_PIDS'])
     for line in fp:
         try:
             pid = int(line)
--- a/tests/run-tests.py	Sun Jul 05 11:01:01 2009 +0200
+++ b/tests/run-tests.py	Sun Jul 05 11:01:30 2009 +0200
@@ -419,7 +419,7 @@
     vlog("# Test", test)
 
     # create a fresh hgrc
-    hgrc = file(HGRCPATH, 'w+')
+    hgrc = open(HGRCPATH, 'w+')
     hgrc.write('[ui]\n')
     hgrc.write('slash = True\n')
     hgrc.write('[defaults]\n')
@@ -525,7 +525,7 @@
 
     # Kill off any leftover daemon processes
     try:
-        fp = file(DAEMON_PIDS)
+        fp = open(DAEMON_PIDS)
         for line in fp:
             try:
                 pid = int(line)
--- a/tests/test-context.py	Sun Jul 05 11:01:01 2009 +0200
+++ b/tests/test-context.py	Sun Jul 05 11:01:30 2009 +0200
@@ -7,7 +7,7 @@
 os.chdir('test1')
 
 # create 'foo' with fixed time stamp
-f = file('foo', 'w')
+f = open('foo', 'w')
 f.write('foo\n')
 f.close()
 os.utime('foo', (1000, 1000))
--- a/tests/test-dispatch.py	Sun Jul 05 11:01:01 2009 +0200
+++ b/tests/test-dispatch.py	Sun Jul 05 11:01:30 2009 +0200
@@ -15,14 +15,14 @@
 os.chdir('test1')
 
 # create file 'foo', add and commit
-f = file('foo', 'wb')
+f = open('foo', 'wb')
 f.write('foo\n')
 f.close()
 testdispatch("add foo")
 testdispatch("commit -m commit1 -d 2000-01-01 foo")
 
 # append to file 'foo' and commit
-f = file('foo', 'ab')
+f = open('foo', 'ab')
 f.write('bar\n')
 f.close()
 testdispatch("commit -m commit2 -d 2000-01-02 foo")
--- a/tests/test-revlog-ancestry.py	Sun Jul 05 11:01:01 2009 +0200
+++ b/tests/test-revlog-ancestry.py	Sun Jul 05 11:01:30 2009 +0200
@@ -10,7 +10,7 @@
     repo.commit(text=text, date="%d 0" % time)
 
 def addcommit(name, time):
-    f = file(name, 'w')
+    f = open(name, 'w')
     f.write('%s\n' % name)
     f.close()
     repo.add([name])