Posts tagged ‘svn’

How to install svn 1.6 for centos 5.5:
First enable the rpmforge repo (repository – a place for “rpm” packages),
then you can just install using yum. Note that after I installed the subversion, I then disabled the repo to keep my install as close to CentOS as I can.

wget http://dag.wieers.com/rpm/packages/rpmforge-release/rpmforge-release-0.3.6-1.el5.rf.x86_64.rpm

rpm -ivh rpmforge-release-0.3.6-1.el5.rf.x86_64.rpm

yum install subversion.x86_64

You can disable the rpmforge repo in /etc/yum.repos.d/rpmforge.repo
and changed enabled = 1 to enabled = 0

As you know, I’m tortured by the pseudo requirement to layout your projects a certain way with svn. Some more thought (and chats with my svn friends) have led me to think that the tool doesn’t really force you to lay things out a certain way, since you could (and should I guess) checkout your projects at a lower level than the top.

eg
ft/
ft/cgi
ft/www

in svn would be

ft.repo/trunk/ft/
ft.repo/trunk/ft/cgi
ft.repo/trunk/ft/www

So you make the project called ft.repo, and make the svn directories under that of trunk, tags and branches. Then ft is my top level directory, and so I check it out with

svn checkout svn://…/ft.repo/trunk/ft ft

and this way my directories are arranged the way I want in my workspace, and tagging will not clutter up my workspace.

But I’m still not overly happy with this, and couldn’t be bothered moving my stuff around, so I decided to write a small shell script that associates the current revision with a tag that is saved into the file .tags in current directory (and committed). It doesn’t let you tag files, but certainly sub-directories are fine. I also merged in the svnignore program from a previous post. Suggestions for improvement are welcome, as this is the first version 🙂

This works by writing version=tag to the file .tags in the current directory.
It is not a "real tag"

Usage:
svn tag “version-1.0”
This will write a “tag” to the current directory as version-1.0

svn listtags
This will list the “tags” for the current directory.

Put this in your path ahead of the real svn (or rename this file)
File: $HOME/bin/svn

#!/bin/sh
# @author Cameron Gregory. http://www.bloke.com/

SVN=/usr/bin/svn
if [ "$1" == "ignore" ]; then
        shift;
        #Usage svn ingore [file|dir|pattern]+
        echo "Intercept ignore"

        if [ $# -eq 0 ]; then
                svn propget svn:ignore .
                exit 0;
        fi
        FILE="/tmp/svnignore.$$"
        $SVN propget svn:ignore . > $FILE
        i=0;
        while [ $i -lt $# ]; do
                echo "$1" >> $FILE
                shift
        done
        sort -u $FILE | grep -v "^$" > $FILE.2
        $SVN propset svn:ignore -F $FILE.2 .
        $SVN propget svn:ignore .
        /bin/rm -f $FILE $FILE.2
        exit 0;
fi
if [ "$1" == "tag" ]; then
        shift;
        echo "Intercept tag"

        TAG="$1"
        $SVN update .
        VER=`svnversion .`
        echo "$VER=$TAG" >> .tags
        $SVN add .tags  2> /dev/null
        $SVN commit .tags -m "saving tag: $TAG"
        tail -5 .tags
        exit 0;
fi
if [ "$1" == "listtags" ]; then
        echo "Intercept listtags"
        if [ -f .tags ]; then
                cat .tags
        else
                echo no tags
        fi
        exit 0;
fi

$SVN $*
exit $?

So if you want to checkout with a tag, then lookup the revision
and checkout using that. Hmm .. perhaps a little grep in the .tags file would be useful. Next time 🙂

properties for ignoring files. Come on guys (gals?), this is crazy. Imagine you wanted an easy to use source code control system. You’d have something like:

svn ignore [files|dirs]+

But no, ignore files are handled through properties.
So fine, you need to do:

svn propset svn:ignore [files|dirs]* [target]

you can feel the pain, but even worse, when you run two in a row, it just takes the last (which makes sense because it’s “propset”, but please.

Like the dumbarse who put ?a=b&c=d in the W3 standard for links (& not &), not having standard control for ignore is just crazy.

Here is my “fix”. File “svnignore”:

#!/bin/sh
#Usage svnignore [file|dir|pattern]+

if [ $# -eq 0 ]; then
        svn propget svn:ignore .
        exit 0;
fi
FILE="/tmp/svnignore.$$"
svn propget svn:ignore . > $FILE
i=0;
while [ $i -lt $# ]; do
        echo "$1" >> $FILE
        shift
done
sort -u $FILE | grep -v "^$" > $FILE.2
svn propset svn:ignore -F $FILE.2 .
svn propget svn:ignore .
/bin/rm -f $FILE $FILE.2

exit 0;

Example usage:

#ignore all files ending in .cgi (note the "s)
svnignore "*.cgi"

# just ignore the file mylog.out
svnignore mylog.out

#ignore the files file1.txt, blah.out and the subdirectory "mydir"
svnignore file1.txt blah.out mydir

ahh .. now I can easily ignore all the stuff I don’t want. Perhaps an alias for “svn propedit svn:ignore .” would also be handy…

Did I mention a nice interface for tags would also be good?