Esempio n. 1
0
 def create_file(self, file_name, content, author, comment):
     """
     Creates a file in the SVN repository with the given
     name and content (text). Returns the committed revision
     """
     assert self.svn_repos is not None, "SVN repository not set..."
     # Get an SVN file system pointer
     fs_ptr = repos.fs(self.svn_repos)
     rev = fs.youngest_rev(fs_ptr)
     # Create and SVN transaction
     txn = fs.begin_txn(fs_ptr, rev)
     txn_root = fs.txn_root(txn)
     # Create a file in the root transaction
     fs.make_file(txn_root, file_name)
     stream = fs.apply_text(txn_root, file_name, None)
     core.svn_stream_write(stream, "%s\n" % content)
     core.svn_stream_close(stream)
     # Now set the properties svn:log and svn:author to
     # the newly created node (file)
     fs.change_txn_prop(txn, 'svn:author', author)
     fs.change_txn_prop(txn, 'svn:log', comment)
     # Commit the transaction
     fs.commit_txn(txn)
     # Add teh file to the list of created files
     self.files.append(file_name)
     # Returns therevision number
     return rev + 1
Esempio n. 2
0
    def save(self, req, text, comment):
        """
        Save the specified text into this document.
        """
        if not isinstance(self.node.repos, SubversionRepository):
            raise TracError("The '%s' repository is not supported" % type(self.node.repos))

        from svn import core as _core
        from svn import fs as _fs
        from svn import repos as _repos

        repos = self.node.repos.repos #.repos
        revnum = self.node._requested_rev
        author = req.authname
        message = 'Edited %s' % self.base[1:]
        if comment:
            message += ' (%s)' % comment

        pool = _core.Pool()
        fs_txn = _repos.fs_begin_txn_for_commit(repos, revnum, author, message, pool)
        fs_root = _fs.svn_fs_txn_root(fs_txn, pool)
        if hasattr(self.node, '_scoped_svn_path'):
            fs_path = self.node._scoped_svn_path
        else:
            fs_path = self.node._scoped_path_utf8
        stream = _fs.svn_fs_apply_text(fs_root, fs_path, None, pool)
        _core.svn_stream_write(stream, text)
        _core.svn_stream_close(stream) 
        return _repos.fs_commit_txn(repos, fs_txn, pool)
Esempio n. 3
0
 def create_file(self, file_name, content, author, comment):
     """
     Creates a file in the SVN repository with the given
     name and content (text). Returns the committed revision
     """
     assert self.svn_repos is not None, "SVN repository not set..."
     # Get an SVN file system pointer
     fs_ptr = repos.fs(self.svn_repos)
     rev = fs.youngest_rev(fs_ptr)
     # Create and SVN transaction
     txn = fs.begin_txn(fs_ptr, rev)
     txn_root = fs.txn_root(txn)
     # Create a file in the root transaction
     fs.make_file(txn_root, file_name)
     stream = fs.apply_text(txn_root, file_name, None)
     core.svn_stream_write(stream, "%s\n" % content)
     core.svn_stream_close(stream)
     # Now set the properties svn:log and svn:author to
     # the newly created node (file)
     fs.change_txn_prop(txn, 'svn:author', author)
     fs.change_txn_prop(txn, 'svn:log', comment)
     # Commit the transaction
     fs.commit_txn(txn)
     # Add teh file to the list of created files
     self.files.append(file_name)
     # Returns therevision number
     return rev + 1