Thursday, March 15, 2007
subversion 'since' trick or how to deal with short-term memory loss
I guess I always kind of knew that svn log and some other subversion commands accept the date ranges instead of revision numbers. But the format is so quirky I suspect many people never use it.

If you lucky enough to use newer client you can take a wild guess and say:

svn log --limit 10

You'll get at most 10 changes this way. But if you want to find out what exactly changed since since March 1, 2007 you can say:

svn log -r {2007-03-01}:HEAD

I usually want to check the changes since yesterday (you know short term memory loss attacks and I need to find out what I am doing). So I ran Google search and guess what! There is a way to convince bash to display yesterday's date.

date -d "1 day ago"

Of course this is not what subversion likes. But we can always specify format.

date -d "1 day ago" +%Y-%m-%d

There is no way I am going to type it every time but bash and its aliases comes handy:

alias svn.since="svn log -r {\`date -d '1 day ago' +%Y-%m-%d\`}:HEAD"

This is one cryptic alias, at least to my untrained eye. What's more it's stuck on displaying yesterday's changes which does not help much good on Mondays.

Aliases in bash apparently do not like parameters, but there is another handy feature: functions. Using it is as easy as adding the following to my .bahsrc:

svn.since() {
since=`date -d "$1 days ago" +%Y-%m-%d`
svn log -r {$since}:HEAD

And now I can type:

svn.since 3

to remind myself what was going on in my favorite project over the weekend.
I'll better code and check in something now...


Powered by Blogger