def test_get_file(self): # Test getting the properties of a file fs_revnum = fs.youngest_rev(self.fs) rev, properties = ra.get_file(self.ra_ctx, "trunk/README2.txt", core.SVN_INVALID_REVNUM, None) self.assertEqual(rev, fs_revnum) self.assertEqual(properties["svn:mime-type"], "text/plain") # Test getting the contents of a file filestream = StringIO() rev, properties = ra.get_file(self.ra_ctx, "trunk/README2.txt", fs_revnum, filestream) self.assertEqual("A test.\n", filestream.getvalue())
def get_file(self, path, revision): """Return content and mode of file at given path and revision. "link " prefix is dropped from symlink content. Mode is 'x' if file is executable, 'l' if a symlink, the empty string otherwise. If the file does not exist at this revision, raise IOError. """ assert not path.startswith('/') mode = '' try: out = cStringIO.StringIO() info = ra.get_file(self.ra, path, revision, out) data = out.getvalue() out.close() if isinstance(info, list): info = info[-1] mode = ("svn:executable" in info) and 'x' or '' mode = ("svn:special" in info) and 'l' or mode except SubversionException, e: notfound = (core.SVN_ERR_FS_NOT_FOUND, core.SVN_ERR_RA_DAV_PATH_NOT_FOUND) if e.args[1] in notfound: # File not found raise IOError(errno.ENOENT, e.args[0]) raise
def get_file(self, path, revision): """Return content and mode of file at given path and revision. "link " prefix is dropped from symlink content. Mode is 'x' if file is executable, 'l' if a symlink, the empty string otherwise. If the file does not exist at this revision, raise IOError. """ assert not path.startswith('/') mode = '' try: out = common.SimpleStringIO() info = ra.get_file(self.ra, path, revision, out) data = out.getvalue() out.close() if isinstance(info, list): info = info[-1] mode = ("svn:executable" in info) and 'x' or '' mode = ("svn:special" in info) and 'l' or mode except SubversionException, e: notfound = (core.SVN_ERR_FS_NOT_FOUND, core.SVN_ERR_RA_DAV_PATH_NOT_FOUND) if e.args[1] in notfound: # File not found raise IOError(errno.ENOENT, e.args[0]) raise