diff svnwrap/svn_swig_wrapper.py @ 74:450d5d9d3b80

SubversionRepo: do not use temporary file in get_file() Existing code says swig bindings do not support StringIO objects as output for svn.ra.get_file(). This issue was never reported in the convert extension.
author Patrick Mezard <pmezard@gmail.com>
date Sun, 09 Nov 2008 18:08:35 -0600
parents 49b7cbe4c8e3
children cca31b6b1318
line wrap: on
line diff
--- a/svnwrap/svn_swig_wrapper.py
+++ b/svnwrap/svn_swig_wrapper.py
@@ -391,17 +391,16 @@ class SubversionRepo(object):
 
     def get_file(self, path, revision):
         out = cStringIO.StringIO()
-        tmpdir = tempfile.mkdtemp('svnwrap_temp')
         try:
-            # hot tip: the swig bridge doesn't like StringIO for these bad boys
-            out_path = os.path.join(tmpdir, 'diffout')
-            out = open(out_path, 'w')
-            ra.get_file(self.ra, path,revision, out , None)
-            out.close()
-            x = open(out_path).read()
-            return x
-        finally:
-            shutil.rmtree(tmpdir)
+            ra.get_file(self.ra, path, revision, out)
+        except core.SubversionException, e:
+            notfound = (core.SVN_ERR_FS_NOT_FOUND,
+                        core.SVN_ERR_RA_DAV_PATH_NOT_FOUND)
+            if e.apr_err in notfound: # File not found
+                raise IOError()
+            raise
+        data = out.getvalue()
+        return data
 
     def proplist(self, path, revision, recurse=False):
         rev = core.svn_opt_revision_t()