[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: Svn tags and branch creation

From: Ryan Schmidt <subversion-2007b_at_ryandesign.com>
Date: 2007-08-30 02:24:37 CEST

On Aug 29, 2007, at 10:46, Patwardhan, Rajesh wrote:

> Ryan Schmidt wrote:
>
>> On Aug 26, 2007, at 23:56, Patwardhan, Rajesh wrote:
>>
>>> Wondering how users are handling the creation of tags and
>>> branches if
>>> a branch or tag already exists ...
>>>
>>> For e.g
>>> 1/ Url: http://svn.mycompany.com/svn/
>>>
>>> 2/ I have the typical project -- trunk
>>> branches --|
>>> --> mybranch
>>> tags
>>>
>>> Now if a branch for e.g. mybranch exists and I try to create it
>>> again
>>>
>>> 3/ svn copy $URL/trunk $URL/branches/mybranch now if the mybranch
>>> exists then I would expect the svn operation to fail ..
>>> But I get
>>> mybranch/trunk
>>>
>>> Any hints or scripts.
>>
>> The behavior of the svn cp command is consistent with the behavior
>> of the Unix cp command.
>
> Agreed: This is as per unix but in unix I can do test to see if the
> directory \ file I am copying exists in the destination.
> How can I simulate that with Subversion.
> Is svn ls the only method or could someone suggest other alternatives.
> Is there a hook someone else already has ...

"svn ls" seems completely sufficient for this task. Here's a little
shell script you can save as "svnbranchexists":

#!/bin/sh

REPO=http://svn.collab.net/repos/svn

if [ -z "$1" ]; then
        echo "usage: $0 <branch>"
        exit 1
fi

BRANCHES=$REPO/branches
BRANCH=$BRANCHES/$1

svn ls $BRANCH >/dev/null 2>&1
if [ 0 -eq $? ]; then
        echo "branch $1 exists"
else
        echo "branch $1 does not exist"
fi

Here's examples of using it:

$ ./svnbranchexists
usage: ./svnbranchexists <branch>
$ ./svnbranchexists nonexistent
branch nonexistent does not exist
$ ./svnbranchexists 1.4.x
branch 1.4.x exists
$

To use it on your repo, put your repository URL into the REPO
variable instead.

This assumes you're on a Unix-like operating system. If you're on
Windows, you'll need to convert the script to a scripting language
that exists on Windows, or use Bash in Cygwin.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org
Received on Thu Aug 30 02:23:16 2007

This is an archived mail posted to the Subversion Users mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.