You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@subversion.apache.org by Mojca Miklavec <mo...@gmail.com> on 2011/12/20 13:08:50 UTC
how to repeatedly checkout sparse directories in a cron job
Hello,
I'm writing a script (also used as a cron job on the server) that
should work independent of whether or not a checkout has already been
done or not. I would like to do "repeated sparse checkout" as
explained below, but I'm not sure how to do it properly. (I have some
kind of a workaround for this problem, but I would like to know if
there is a more elegant solution to this.)
Repository has the following structure:
- project/trunk (I would like to have it checked out)
- project/branches/xxx (I don't want them)
- project/tags/xxx (I would only like to have the latest one, but it
doesn't bother me too much if I don't delete older ones)
The first time I can do the following:
latest=`svn list $URL/tags | grep beta | tail -1 | tr -d '/'`
svn co --depth=empty $URL
svn up project/trunk
svn up --set-depth empty project/tags # temporary workaround for a
bug in svn
svn up project/tags/$latest
I could use "svn up" from that moment on, but since I would like the
script to work even if nothing has been checked out yet, I would like
to keep "svn co" in the script.
The problem is that "svn co --depth=empty $URL" will delete all the
contents next time when I call it. Is there any way to prevent
deleting existing contents within the scope of command line arguments?
A workaround is to use something like
if [ ! -d "project" ]; then
svn co --depth=empty $URL
fi
but I would be really happy if there was some command like:
"please checkout $URL, but no need to fetch any files yet, in
particular don't fetch 'branches'; on the other hand please don't
delete 'trunk' and 'tags' if already present"
Thank you very much,
Mojca
Re: how to repeatedly checkout sparse directories in a cron job
Posted by Mojca Miklavec <mo...@gmail.com>.
On Wed, Dec 21, 2011 at 13:21, Stefan Sperling wrote:
> On Wed, Dec 21, 2011 at 06:07:05AM -0600, Ryan Schmidt wrote:
>> On Dec 20, 2011, at 06:08, Mojca Miklavec wrote:
>> > Is there any way to prevent
>> > deleting existing contents within the scope of command line arguments?
>> > A workaround is to use something like
>> > if [ ! -d "project" ]; then
>> > svn co --depth=empty $URL
>> > fi
>> > but I would be really happy if there was some command like:
>> >
>> > "please checkout $URL, but no need to fetch any files yet, in
>> > particular don't fetch 'branches'; on the other hand please don't
>> > delete 'trunk' and 'tags' if already present"
>>
>> I don't think that exists as a built-in command as such. But probably playing with the depth settings you can get what you want. I am not very familiar with these settings however so I cannot advise.
>>
>
> svn-viewspec.py might help: https://svn.apache.org/repos/asf/subversion/trunk/tools/client-side/svn-viewspec.py
Thank you very much for pointing out this script. I think that it will
perfectly suit the need.
Mojca
Re: how to repeatedly checkout sparse directories in a cron job
Posted by Stefan Sperling <st...@elego.de>.
On Wed, Dec 21, 2011 at 06:07:05AM -0600, Ryan Schmidt wrote:
> On Dec 20, 2011, at 06:08, Mojca Miklavec wrote:
> > Is there any way to prevent
> > deleting existing contents within the scope of command line arguments?
> > A workaround is to use something like
> > if [ ! -d "project" ]; then
> > svn co --depth=empty $URL
> > fi
> > but I would be really happy if there was some command like:
> >
> > "please checkout $URL, but no need to fetch any files yet, in
> > particular don't fetch 'branches'; on the other hand please don't
> > delete 'trunk' and 'tags' if already present"
>
> I don't think that exists as a built-in command as such. But probably playing with the depth settings you can get what you want. I am not very familiar with these settings however so I cannot advise.
>
svn-viewspec.py might help: https://svn.apache.org/repos/asf/subversion/trunk/tools/client-side/svn-viewspec.py
Re: how to repeatedly checkout sparse directories in a cron job
Posted by Ryan Schmidt <su...@ryandesign.com>.
On Dec 20, 2011, at 06:08, Mojca Miklavec wrote:
> I'm writing a script (also used as a cron job on the server) that
> should work independent of whether or not a checkout has already been
> done or not. I would like to do "repeated sparse checkout" as
> explained below, but I'm not sure how to do it properly. (I have some
> kind of a workaround for this problem, but I would like to know if
> there is a more elegant solution to this.)
>
> Repository has the following structure:
> - project/trunk (I would like to have it checked out)
> - project/branches/xxx (I don't want them)
> - project/tags/xxx (I would only like to have the latest one, but it
> doesn't bother me too much if I don't delete older ones)
>
> The first time I can do the following:
> latest=`svn list $URL/tags | grep beta | tail -1 | tr -d '/'`
> svn co --depth=empty $URL
> svn up project/trunk
> svn up --set-depth empty project/tags # temporary workaround for a
> bug in svn
> svn up project/tags/$latest
>
> I could use "svn up" from that moment on, but since I would like the
> script to work even if nothing has been checked out yet, I would like
> to keep "svn co" in the script.
>
> The problem is that "svn co --depth=empty $URL" will delete all the
> contents next time when I call it.
You should only be calling "svn co" once per working copy. Once you have a working copy, you should "svn up" it.
> Is there any way to prevent
> deleting existing contents within the scope of command line arguments?
> A workaround is to use something like
> if [ ! -d "project" ]; then
> svn co --depth=empty $URL
> fi
> but I would be really happy if there was some command like:
>
> "please checkout $URL, but no need to fetch any files yet, in
> particular don't fetch 'branches'; on the other hand please don't
> delete 'trunk' and 'tags' if already present"
I don't think that exists as a built-in command as such. But probably playing with the depth settings you can get what you want. I am not very familiar with these settings however so I cannot advise.