Wednesday, September 17, 2008

Working some magic in (G)Vim

It's hard not to love Vim when substitutions and movement is as beatiful as it is. The commands of the day are:
:%s/_LIT(K\(.*\),.*);/TBool CAudioMgmtServerWrapper::\1()/g
These few commands actually lets us completely reformat a block of text, remove comments, add variable names and then turn it into a list of functions again. Sweeet.
Let's go through them a bit more in detail:

:g/exp1/d - cut (delete) the text that matches the expression1 inside the "//".

ggVG - go to the top (gg), go into 'mark mode' (V) and then go to the EOF (G). This is performed in ordinary command mode.

:retab! - Let's replace whitespaces with real tabs instead.

:%s/exp1/exp2/g - Replace expression1 with expression2, and do it for all occurences on every line (g).

Tuesday, September 9, 2008

How to change/update the URL of your SVN repository

Sourceforge has done some huge updates and changes during the last couple of months, and I might not be the busiest bee regarding updates and commits to my own project, Subspace Battle.

Today when I was doing some updates and fixes, I tried to call it a night and did the final touch: a commit. But for some reason I kept getting a '403' error, which means there is some security issue. I knew my password was correct, and also the user, so what could it be? Perhaps the UUID of the server had changed after sourceforge's updates, and that somehow stopped the update. I checked their website to see if there were any changes or big "REMEMBER TO DO THIS" signs waving at me, but saw none.

After reading through parts of the svn guide, I compared my repository URL to the one I got from the 'svn info' command. It turns out that they have switched to https (instead of http), which means my URL was wrong. So how do we update it without downloading another local copy of everything? I tried several different solutions, and finally find the right one!
svn switch --relocate
This simply changes the URL of the repository that your local version maps to. Or as the 'help' chapter describes it, if only I had read that sooner...
switch (sw): Update the working copy to a different URL.
usage: switch --relocate FROM TO [PATH...]

Rewrite working copy URL metadata to reflect a syntactic change only.
This is used when repository's root URL changes (such as a scheme
or hostname change) but your working copy still reflects the same
directory within the same repository.
Now let's get on with the commits!

Sunday, September 7, 2008

Sending output from one command to another

When I recently updated xorg-server to version 1.5.0 (which comes with the new that is released soon!) I needed to rebuild some of the drivers (packages) that comes with it. To get the list of drivers I use the command qlist.
$ qlist -I -C x11-drivers/
which outputs a list of packages from the category x11-drivers that are installed (-I) and without color (-C). Although it's nice to get a list like the one I got:
$ qlist -I -C x11-drivers/
it's a bit annoying if you have to copy and past all these onto the command line as parameters to the 'emerge' command. So what we do is get the qlist to list these packages into the emerge command. This is done using the "$" symbol, which first evaluates the output of its embedded command, and then outputs it as a parameter to the parent command. To clarify:
$ parent-command $(command we want the output from)

which in our case turns out to be:
# emerge $(qlist -I -C x11-drivers/)
This starts the emerge and re-compile of all our drivers. Now we wait... ;)