Subversion or CVS?

Ovid on 2007-01-18T15:02:00

Because I constantly work with package with either a Build.PL or a Makefile.PL and I'm always typing the wrong command, I have the following shell script named 'rebuild':

#!/usr/local/bin/bash
if [ -f Build.PL ]; then
    makeprog=Build
    makecommand=./Build
elif [ -f Makefile.PL ]; then
    makeprog=Makefile
    makecommand=make
else
    echo Nothing to rebuild!
    exit 1
fi

if [ -f $makeprog ]; then
    $makecommand realclean
fi
perl $makeprog.PL && $makecommand && $makecommand test

if [ "$1" = dist ]; then
    $makecommand dist
fi

Note: this is one of the hacks I contributed to Perl Hacks. If you like it, you'll find other items of interest in the book.

In a similar vein, I find that work uses CVS and I use Subversion at home, so I'm always mistyping the command. Hence my writing the following shell script, following a similar theme:

#!/usr/local/bin/bash

if [ -d CVS ]; then
    prog=cvs
elif [ -d .svn ]; then
    prog=svn
else
    echo Cannot determine source control!
    exit 1
fi  

case "$1" in
    "") $prog up    ;; # no arguments
    * ) $prog up $* ;; # Pass 'em straight through
esac

Perhaps I should go ahead and start on a proper compatibility layer. Nah, I have too much work to do with TAPx::Parser. I assume someone has already written something like this?


If you want to be /really/ useful

Adrian on 2007-01-18T15:09:17

Extend SVK so it can push as well as pull from CVS repos :)

Re:If you want to be /really/ useful

Ovid on 2007-01-18T15:13:18

I keep thinking I should check out SVK since so many people I respect say it's so wonderful, but given that I no nothing about it other than how to spell it, it's been pretty low on my list of Things To Do :)

Re:If you want to be /really/ useful

Adrian on 2007-01-18T15:24:39

The thing I like about it is that I can do:

svk mirror $WORK_REPO/project/foo/trunk //foo/trunk
svk cp //foo/trunk //foo/local -m 'a local branch for local folk'
svk sync -a
svk co //foo/local foo

# unplug network & leave work

# work away offline and unnetworked, committing things in my
# local foo repo to my hearts content

# go back to work and plugin network

# to merge in changes other folk might have done while
# I was away
svk pull

# to push my changes back to the main repository
svk push

It just makes offline working so much easier for me. Plus I have a stack of useful things like the subversion book, perl6, prototype, the mod_perl docs, etc. mirrored to my local machine so I have a copy wherever my laptop and I may be.

See cvn on CPAN

Matts on 2007-01-18T15:17:18

Someone beat you to it :-)

Re:See cvn on CPAN

melo on 2007-01-18T16:02:27

hmmms.. searching cvn on http://search.cpan.org/: 0 results.

Google gives: http://search.cpan.org/user/rclamp/cvn-0.04/cvn

Strange...

Bug in your cvs/svn script

grantm on 2007-01-18T20:02:03

In your case statement, do you really intend to pass the 'up' in the second case?

Also, you probably want to do this:

$prog "$@"

Rather than this:

$prog $*

The difference being that "$@" does the right thing with quoted arguments containing spaces (eg: -m "commit message here").