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

Re: Why do commands fail when a file is unknown to svn?

From: C.A.T.Magic <c.a.t.magic_at_gmx.at>
Date: 2004-03-05 01:01:21 CET

I didn't read through all the scripts on the previous mailing but I
get the -strong- feeling that it isn't so easy to find the right
svn command to get what we wantet to know in the first place :-)
so.. is that an indication for a feature request?

:-)
c.a.t.

----- Original Message -----
From: <terry@eatoni.com>
To: "James Goodall" <jgoodall@dmetrix.com>
Cc: "'Nicolás Lichtmaier'" <jnl@synapsis-sa.com.ar>;
<dev@subversion.tigris.org>
Sent: Friday, March 05, 2004 00:49
Subject: RE: Why do commands fail when a file is unknown to svn?

>
> >>>>> "James" == James Goodall <jgoodall@dmetrix.com> writes:
>
> James> You could do this:
> James> --- Begin file isversioncontrolled ---
> James> #/bin/bash
> James> svn info $1 &>/dev/null
> James> --- End of file
>
> James> svn ci $( find . -name Makefile -exec isversioncontrolled {}
\; -print )
>
> I'm not sure how/why this works, because, unfortunately, svn info
> exits with status 0 even when the file is not under version control.
> This should probably be changed.
>
> Meanwhile, you can get around it with grep -q as below.
>
> $ find . -name Makefile | xargs check-in-if-under-svn
>
> With a check-in-if-under-svn script looking like this
>
> --- Begin file check-in-if-under-svn ---
> #!/bin/bash
> for i in "$@"
> do
> svn info "$i" 2>&1 | grep -q -i 'Not a versioned resource' || svn ci
"$i"
> done
> --- End of file ---
>
>
> I still wouldn't recommend this (it's slow because it fires up
> potentially many svn processes). Also, I have a feeling (and people
> who've actually used svn for more than a week, unlike me, will have to
> confirm) that it's somehow nicer if you do all the checkins at once,
> creating one new change set in svn.
>
> So better (but more involved):
>
> $ find . -name Makefile | xargs check-in-if-under-svn.pl
>
> Where check-in-if-under-svn.pl looks like this:
>
> ----------------------------------------------
> #!/usr/bin/perl -w
>
> use strict;
>
> my $svn = '/usr/local/bin/svn';
> my $echo = '';
> my %invalid;
>
> if ($ARGV[0] eq '-n'){
> $echo = 'echo ';
> shift;
> }
>
> exit(0) unless @ARGV;
>
> open(INFO, sprintf("$svn info %s |", join(' ', map { "'$_'" } @ARGV))) or
die;
>
> map { $invalid{$1} = undef if /^([^:]+):\s*\(Not a versioned
resource\)$/ } <INFO>;
>
> my @ci = grep { ! exists $invalid{$_} } @ARGV;
>
> exit(0) unless @ci;
>
> system("$echo$svn ci " . join(' ', map { "'$_'" } @ci));
>
> exit $? >> 8;
> ----------------------------------------------
>
>
> BTW, you can give this script an initial -n argument if you just want
> it to echo what it would check in.
>
> Note also that the above assumes you don't have files with a single
> quote in their name.
>
> Finally, make sure you prune your find command if it encounters any
> .svn directories.
>
>
> Terry
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
> For additional commands, e-mail: dev-help@subversion.tigris.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org
Received on Fri Mar 5 01:00:27 2004

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