示例#1
0
/* 
 * Example to remove a file/dir
 * as the call is the same for file or dir, we
 * only need to check it exists
 * 
 * uses php svn module:
 * http://php.net/manual/en/book.svn.php 
 */
$svn_path = "/var/lib/svn/repos/testrepo";
$path = "/test/myfile.txt";
//open the repo
$svn_repo = svn_repos_open($svn_path);
//get a fs handler
$repo_fs = svn_repos_fs($svn_repo);
//get latest revision
$latest_revision = svn_fs_youngest_rev($repo_fs);
//generate a transaction, with user and log message
$repo_txn = svn_repos_fs_begin_txn_for_commit($svn_repo, $latest_revision, 'user-repo-label', 'Creating paths');
//get the root respource to this transaction
$repo_root = svn_fs_txn_root($repo_txn);
//check if is either a file or dir, if we
//are interested in a single type, then
//remove any of the checking
if (svn_fs_is_file($repo_root, $path) || svn_fs_is_dir($repo_root, $path)) {
    //remove the object and do the commit
    svn_fs_delete($repo_root, $path);
    svn_repos_fs_commit_txn($repo_txn);
} else {
    //file not found, so abort transaction
    svn_fs_abort_txn($repo_txn);
}
示例#2
0
        }
        //finally create the dir after all parent's are done
        svn_fs_make_dir($repo_root, $dir);
    }
}
$svn_path = "/var/lib/svn/repos/testrepo";
$path = "/test/myfile.txt";
$data = "Lorem Ipsum, file generated with svn";
//open the repo
$svn_repo = svn_repos_open($svn_path);
//get a fs handler
$repo_fs = svn_repos_fs($svn_repo);
//get latest revision
$latest_revision = svn_fs_youngest_rev($repo_fs);
//generate a transaction, with user and log message
$repo_txn = svn_repos_fs_begin_txn_for_commit($svn_repo, $latest_revision, 'user-repo-label', 'Creating paths');
//get the root respource to this transaction
$repo_root = svn_fs_txn_root($repo_txn);
//check if exists, if not create the file
if (!svn_fs_is_file($repo_root, $path)) {
    makeSubdirs($repo_root, dirname($path));
    //this will create an empty file in svn
    svn_fs_make_file($repo_root, $path);
}
//get stream to write data
$fp = svn_fs_apply_text($repo_root, $path);
fwrite($fp, $data);
fclose($fp);
//important to close, if not the transaction will fail
//finally commit the transaction
svn_repos_fs_commit_txn($repo_txn);