Category Archives: svn

checkout svn project without svn files

if you have already checkout project using “svn co” command, please go here.

Otherwise, retrieve project using:

==> Please note that myproj, in this case, isn’t a working copy !

import many versions of project to svn repository

I have traditionally versionning my project by copying my project folder, rename the copy and continue work on it.

Now, I have several versions of my project in different folders: myproj_v1, myproj_v2, …
I want to import my project version by version. So, I’ll have change log.

To import like so (e.g. to http://svn.witr.net/repos/myproj), we have to type following commands:
1. copy first version in different folder

2. import to svn

3. rsync the second version

4. force add unversionned elements

5. commit second version

==> repeat steps 3, 4, 5 to continue with next versions folders

checkout single file from svn repo

svn co doesn’t permit checkout files but directories.
use rather :

svn export https://svn.repo/path/to/file/witr.png /tmp/witr.png

another alternative for text files

svn cat https://svn.repo/path/to/file/witr.txt > /tmp/witr.txt

get last 10 log of several svn projects

We have 10 projects checked out from svn repo:
/workspace/proj1
/workspace/proj2
/workspace/proj3
… etc

get last 10 log of several svn projects with shell comand line :

svn first user commit

print users who commits frst commit for each class in project :
> find -name “*.java” -exec svn log -l1 -r1:HEAD {} ; | grep “|” | awk ‘{print $3}’

print java class name and user who leaves first commit of that class
(user /path_to_java_file/java_file.java) :

> find -name “*.java” | while read line; do user=$(svn log -l1 -r1:HEAD $line | grep “|” | awk ‘{print $3}’); echo $user $line; done;

be notified of all svn changes

If you want like me have been notified of all svn changes, the following script I wrote for you.

Prerequisite :

  • svn installed
  • svn well configured for user executing script

#!/bin/bash

export SVN_UPDATES_HOME=/mnt/scripts/svnUpdates
export SVN_UPDATES_LAST=$SVN_UPDATES_HOME/tmp/svnUpdatesLast.txt
export SVN_UPDATES_TMP=$SVN_UPDATES_HOME/tmp/svnUpdates.txt
export SVN_UPDATES_DIFF_TMP=$SVN_UPDATES_HOME/tmp/svnUpdatesDiff.txt
export SVN_UPDATES_DIFF_LOG=$SVN_UPDATES_HOME/log/svnUpdatesLog

if [[ -s $SVN_UPDATES_LAST ]]
then
  echo “copy last svn log to tmp”
  cp $SVN_UPDATES_LAST $SVN_UPDATES_TMP
else
  touch $SVN_UPDATES_TMP
fi

for log in 1 2 3
do
  echo “svn log – try:$log”
  svn log -v -l5 -rHEAD:1 https://svn.witr.net > $SVN_UPDATES_LAST
  if [[ -s $SVN_UPDATES_LAST ]]
  then
    echo “svn logged successfully in try:$log”
    break
  fi
done

if [[ -s $SVN_UPDATES_LAST ]]
then
  echo “proceed to diff last with tmp”
  diff $SVN_UPDATES_LAST $SVN_UPDATES_TMP | grep -E “^<" | sed s/^.// > $SVN_UPDATES_DIFF_TMP
  diffsCount=$(wc -l $SVN_UPDATES_DIFF_TMP | awk {‘print $1’})
  if [ $diffsCount -gt 0 ]
  then
      “diffs found: send notification”
      datetime=$(date “+%Y%m%d-%H%M%S”)
      logFile=$SVN_UPDATES_DIFF_LOG$datetime
      cp $SVN_UPDATES_DIFF_TMP $logFile
      ### put here the way you want be notified (mail, jabber, …)
      ### echo “==== svn updated cf. $logFile ====” | sendxmpp mabrouk@openfire.witr.net
      ### cat $logFile | sendxmpp mabrouk@openfire.witr.net
  fi
fi

Here I choose to be notified by message sent from jabber server from my account to my account.
Prerequisite : sendxmpp installed : apt-get install sendxmpp

echo “==== svn updated cf. $logFile ====” | sendxmpp mabrouk@openfire.witr.net
cat $logFile | sendxmpp mabrouk@openfire.witr.net

Finally, schedule the script in your crontab (executed each minute recommanded)

* * * * * /mnt/scripts/svnUpdates/svnUpdates.sh

statsvn.org

June 21, 2012

shell: svn log -v –xml > logFile.log
shell: java -jar statsvn.jar logFile.log
see more options
details for ant task in my Drive