Creating a branch/tag through the PHP SVN API

Submitted by Jochus on Thu, 29/07/2010 - 00:15 | Posted in: Drupal


We are currently working on Drupal modules which are versioned in Subversion. We often make new releases and for every release, we also create tags in SVN. In Java, there's a tool called Maven which has a "release plugin". This plugin helps you releasing.

Drupal doesn't have this tool, so we are creating a "release management tool" which does the same for us. We simply specify the module we want to release. The stable version is introduced and the new version is proposed. Creating tags happens now automatically using the PHP SVN API. More details can be found here: http://php.net/manual/en/book.svn.php.

However, it took me some time to understand the API, as it's not very well documented. I even wasn't able to find a perfect example on the internet.

$svn_repos = svn_repos_open("##PATH_TO_REPO##");
$svn_fs = svn_repos_fs($svn_repos);
 
// init 'from' resource
$svn_fs_root = svn_fs_revision_root($svn_fs, svn_fs_youngest_rev($svn_fs));
 
// init 'to' resource
$svn_tx = svn_fs_begin_txn2($svn_fs, svn_fs_youngest_rev($svn_fs));
$svn_tx_root = svn_fs_txn_root($svn_tx);
 
// execute copy command
svn_fs_copy( $svn_fs_root,  "##FROM_PATH##",  $svn_tx_root, "##TO_PATH##");
 
// commit
svn_repos_fs_commit_txn($svn_tx);

Add new comment

The content of this field is kept private and will not be shown publicly.

Full HTML

  • Lines and paragraphs break automatically.
  • You can caption images (data-caption="Text"), but also videos, blockquotes, and so on.
  • Web page addresses and email addresses turn into links automatically.
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <bash>, <cpp>, <css>, <html5>, <java>, <javascript>, <php>, <sql>, <xml>. The supported tag styles are: <foo>, [foo].
CAPTCHA
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.