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

Re: script to commit all unversioned/modified files in tree

From: Jeff D <fixedored_at_gmail.com>
Date: 2007-04-20 10:14:29 CEST

On Thu, 19 Apr 2007, Ruslan Sivak wrote:

> I would like to write a script to commit all unversioned/modified files in a
> tree. We have a folder that we keep under svn that has other subfolders, and
> users can upload images there. I would like to set up nightly commits.
> I usually do it by hand using TortoiseSVN, but due to the size of the folder
> this is becoming a problem. I would also like to schedule it to run nightly.
> Is this possible? I think Tortoise does an add and a commit, and it looks
> like you need to specify the files for the add, so perhaps I would need to
> somehow feed the output of the svn status command to svn add?
> Russ
>

I'm not sure what OS you are using, but if you have access sh/bash, here
is a little script that does that. This just checks for files and
directories that have been added or modified, also for files that have
been marked for deletion. There are other states that it could check for
as well, see svn help st for those and add away.

  -------
#!/bin/sh
export PATH=/usr/local/bin:/usr/bin:/bin
cd /path/to/base/of/rep
DATE=`date`
FILELIST=`svn st`
TOADD=`echo "$FILELIST" | grep '^?' | awk '{print $2}'`
MODIFIED=`echo "$FILELIST" | grep '^M' | awk '{print $2}'`
TODEL=`echo "$FILELIST" | grep '^D' | awk '{print $2}'`

if [ ! -z "$TOADD" ] ; then
         svn add $TOADD
fi
if [ ! -z "$TOADD" -o ! -z "$MODIFIED" -o ! -z "$TODEL" ] ;then
         svn ci -m "auto updated on ${DATE} "
fi
echo "done"
--------
example:
$ svn st
? stuff/1/testing.1
D stuff/1/some.file
? stuff/2/newfile
M stuff/2/test
M new
$ ~/auto.add.svn.sh
A stuff/1/testing.1
A stuff/2/newfile
Sending new
Deleting stuff/1/some.file
Adding stuff/1/testing.1
Adding stuff/2/newfile
Sending stuff/2/test
Transmitting file data ....
Committed revision 16.
done

  -+-
8 out of 10 Owners who Expressed a Preference said Their Cats Preferred Techno.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org
Received on Fri Apr 20 10:14:59 2007

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