You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by Jochen Hebbrecht <jo...@pipa.be> on 2010/07/28 08:13:51 UTC

How to create a branch/tag using the SVN API?

Hi,

I'm currently trying to create a branch/tag through the SVN API - PHP.

This is my code:

<?php
// CLIENT INFO
echo svn_client_version();

// CREATING BRANCH/TAG $svn_repos = svn_repos_open("##PATH_TO_REPO##"); 
$svn_fs = svn_repos_fs($svn_repos); $svn_tx = svn_fs_begin_txn2($svn_fs, 
svn_fs_youngest_rev($svn_fs)); $svn_tx_root = svn_fs_txn_root($svn_tx); 
svn_fs_copy( $svn_tx_root, "/FOO", $svn_tx_root, "/BAR"); 
svn_repos_fs_commit_txn($svn_tx);

?>

But then I'm getting this error:

[Tue Jul 27 14:50:30 2010] [error] [client 127.0.0.1] PHP Warning: 
svn_fs_copy(): svn error(s) occured\n200007 (Trying to use an 
unsupported feature) Copy from mutable tree not currently supported\n in 
/var/www/pipa/testsvn.php on line 10

Any idea's what I'm doing wrong here?

Jochen

Re: How to create a branch/tag using the SVN API?

Posted by Jochen Hebbrecht <jo...@pipa.be>.
On 07/28/2010 02:52 PM, C. Michael Pilato wrote:
> Yes, you're trying to use a mutable tree (one based on a txn_root) as the
> source of a copy, which is disallowed.  For the *source* root, you need to
> use svn_fs_revision_root().  (Keep doing as you are above, though, for the
> copy target root.)
>    

Michael,

Thanks !!! Now it works! :-)

If somebody else is interested, this is the code!

-----------------
// init rep
$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);
-----------------

Jochen

Re: How to create a branch/tag using the SVN API?

Posted by "C. Michael Pilato" <cm...@collab.net>.
On 07/28/2010 04:13 AM, Jochen Hebbrecht wrote:
> Hi,
> 
> I'm currently trying to create a branch/tag through the SVN API - PHP.
> 
> This is my code:
> 
> <?php
> // CLIENT INFO
> echo svn_client_version();
> 
> // CREATING BRANCH/TAG $svn_repos = svn_repos_open("##PATH_TO_REPO##");
> $svn_fs = svn_repos_fs($svn_repos); $svn_tx = svn_fs_begin_txn2($svn_fs,
> svn_fs_youngest_rev($svn_fs)); $svn_tx_root = svn_fs_txn_root($svn_tx);
> svn_fs_copy( $svn_tx_root, "/FOO", $svn_tx_root, "/BAR");
> svn_repos_fs_commit_txn($svn_tx);
> 
> ?>
> 
> But then I'm getting this error:
> 
> [Tue Jul 27 14:50:30 2010] [error] [client 127.0.0.1] PHP Warning:
> svn_fs_copy(): svn error(s) occured\n200007 (Trying to use an
> unsupported feature) Copy from mutable tree not currently supported\n in
> /var/www/pipa/testsvn.php on line 10
> 
> Any idea's what I'm doing wrong here?

Yes, you're trying to use a mutable tree (one based on a txn_root) as the
source of a copy, which is disallowed.  For the *source* root, you need to
use svn_fs_revision_root().  (Keep doing as you are above, though, for the
copy target root.)

-- 
C. Michael Pilato <cm...@collab.net>
CollabNet   <>   www.collab.net   <>   Distributed Development On Demand


Re: How to create a branch/tag using the SVN API?

Posted by Daniel Shahaf <d....@daniel.shahaf.name>.
Jochen Hebbrecht wrote on Wed, Jul 28, 2010 at 11:55:38 +0200:
> Thanks for your answer. Unfortunately, the SVN API  
> (http://php.net/manual/en/book.svn.php) doesn't have a  
> svn_client_copyX() command :-( ...

I saw this on users@ a few months ago.  And I think the fix is to make the
PHP svn bindings support some of our APIs higher-level than the FS library.

<snip what="bad puns around shooting oneself in the foot"/>

Re: How to create a branch/tag using the SVN API?

Posted by Jochen Hebbrecht <jo...@pipa.be>.
On 07/28/2010 11:08 AM, Bert Huijben wrote:
>
> I would use the svn_client_copyX() command to just copy the urls you need.
> Seems like a much easier way to handle it, then to reproduce all the
> behavior myself.
>
> The error you see is that you can only copy from explicit (historic)
> locations, so I think you should copy from a revision root instead of from
> the transaction root. (The target must be the transaction of course)
>
> 	Bert
>    

Bert,

Thanks for your answer. Unfortunately, the SVN API 
(http://php.net/manual/en/book.svn.php) doesn't have a 
svn_client_copyX() command :-( ...
When I try to copy from a revision root, I'm getting this error:

 >> PHP Warning:  svn_fs_copy(): supplied resource is not a valid 
svn-fs-root resource in /var/www/pipa/testsvn.php on line 10

Jochen

RE: How to create a branch/tag using the SVN API?

Posted by Bert Huijben <be...@qqmail.nl>.

> -----Original Message-----
> From: Jochen Hebbrecht [mailto:jochen@pipa.be]
> Sent: woensdag 28 juli 2010 10:14
> To: dev@subversion.apache.org
> Subject: How to create a branch/tag using the SVN API?
> 
> Hi,
> 
> I'm currently trying to create a branch/tag through the SVN API - PHP.
> 
> This is my code:
> 
> <?php
> // CLIENT INFO
> echo svn_client_version();
> 
> // CREATING BRANCH/TAG $svn_repos = svn_repos_open("##PATH_TO_REPO##");
> $svn_fs = svn_repos_fs($svn_repos); $svn_tx =
> svn_fs_begin_txn2($svn_fs,
> svn_fs_youngest_rev($svn_fs)); $svn_tx_root = svn_fs_txn_root($svn_tx);
> svn_fs_copy( $svn_tx_root, "/FOO", $svn_tx_root, "/BAR");
> svn_repos_fs_commit_txn($svn_tx);
> 
> ?>
> 
> But then I'm getting this error:
> 
> [Tue Jul 27 14:50:30 2010] [error] [client 127.0.0.1] PHP Warning:
> svn_fs_copy(): svn error(s) occured\n200007 (Trying to use an
> unsupported feature) Copy from mutable tree not currently supported\n
> in
> /var/www/pipa/testsvn.php on line 10
> 
> Any idea's what I'm doing wrong here?

I would use the svn_client_copyX() command to just copy the urls you need.
Seems like a much easier way to handle it, then to reproduce all the
behavior myself.

The error you see is that you can only copy from explicit (historic)
locations, so I think you should copy from a revision root instead of from
the transaction root. (The target must be the transaction of course)

	Bert