comparison 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
comparison
equal deleted inserted replaced
73:9c1b53abefcb 74:450d5d9d3b80
389 finally: 389 finally:
390 shutil.rmtree(tmpdir) 390 shutil.rmtree(tmpdir)
391 391
392 def get_file(self, path, revision): 392 def get_file(self, path, revision):
393 out = cStringIO.StringIO() 393 out = cStringIO.StringIO()
394 tmpdir = tempfile.mkdtemp('svnwrap_temp')
395 try: 394 try:
396 # hot tip: the swig bridge doesn't like StringIO for these bad boys 395 ra.get_file(self.ra, path, revision, out)
397 out_path = os.path.join(tmpdir, 'diffout') 396 except core.SubversionException, e:
398 out = open(out_path, 'w') 397 notfound = (core.SVN_ERR_FS_NOT_FOUND,
399 ra.get_file(self.ra, path,revision, out , None) 398 core.SVN_ERR_RA_DAV_PATH_NOT_FOUND)
400 out.close() 399 if e.apr_err in notfound: # File not found
401 x = open(out_path).read() 400 raise IOError()
402 return x 401 raise
403 finally: 402 data = out.getvalue()
404 shutil.rmtree(tmpdir) 403 return data
405 404
406 def proplist(self, path, revision, recurse=False): 405 def proplist(self, path, revision, recurse=False):
407 rev = core.svn_opt_revision_t() 406 rev = core.svn_opt_revision_t()
408 rev.kind = core.svn_opt_revision_number 407 rev.kind = core.svn_opt_revision_number
409 rev.value.number = revision 408 rev.value.number = revision