comparison svnwrap/svn_swig_wrapper.py @ 76:6c62bd201785

SubversionRepo: make get_file() return the file mode It is cheap to get it, and it will be useful to fetch revisions.
author Patrick Mezard <pmezard@gmail.com>
date Sun, 09 Nov 2008 18:08:35 -0600
parents cca31b6b1318
children ed3dd5bf45da
comparison
equal deleted inserted replaced
75:cca31b6b1318 76:6c62bd201785
388 return diff 388 return diff
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 """Return content and mode of file at given path and revision.
394
395 Content is raw svn content, symlinks content is still prefixed
396 by 'link '. Mode is 'x' if file is executable, 'l' if a symlink,
397 the empty string otherwise. If the file does not exist at this
398 revision, raise IOError.
399 """
400 mode = ''
393 out = cStringIO.StringIO() 401 out = cStringIO.StringIO()
394 try: 402 try:
395 ra.get_file(self.ra, path, revision, out) 403 info = ra.get_file(self.ra, path, revision, out)
404 if isinstance(info, list):
405 info = info[-1]
406 mode = ("svn:executable" in info) and 'x' or ''
407 mode = ("svn:special" in info) and 'l' or mode
396 except core.SubversionException, e: 408 except core.SubversionException, e:
397 notfound = (core.SVN_ERR_FS_NOT_FOUND, 409 notfound = (core.SVN_ERR_FS_NOT_FOUND,
398 core.SVN_ERR_RA_DAV_PATH_NOT_FOUND) 410 core.SVN_ERR_RA_DAV_PATH_NOT_FOUND)
399 if e.apr_err in notfound: # File not found 411 if e.apr_err in notfound: # File not found
400 raise IOError() 412 raise IOError()
401 raise 413 raise
402 data = out.getvalue() 414 data = out.getvalue()
403 return data 415 return data, mode
404 416
405 def proplist(self, path, revision, recurse=False): 417 def proplist(self, path, revision, recurse=False):
406 if path[-1] == '/': 418 if path[-1] == '/':
407 path = path[:-1] 419 path = path[:-1]
408 if path[0] == '/': 420 if path[0] == '/':