SVN

From Computer Club Wiki

Jump to: navigation, search

The Computer Club runs a local SVN server for many projects. Read-only access is allowed to everyone. For commits, make a patch and send it to an admin, or talk to an admin about write access.

Contents

For the love of god

  1. read an svn tutorial on the internets
  2. don't add your music
  3. don't add your documents
  4. don't add your movies
  5. don't add anything at all *unless* you know what the heck you're doing and are very careful

There is much knowledge floating around. I'll try to keep words here focused on the cclub's server to keep things as "simple" as possible.

Our Beloved Repository

The repo is located at:

/home/svn/repo

You can see what's in there with the following:

svn ls file:///home/svn/repo

To see changes (starting with most recent) do this:

svn log file:///home/svn/repo

Etc. Check out those tutorials on the internets to learn other things about simple svn usage.

Keeping It Pretty

Each project has its place, so find a place for yours within the main tree. If it's an irc-bot, put it in repo/bots, if it's related to the website put it in repo/www.

For each project, you should create a sub-directory for "branches", "tags", and "trunk". In most cases, you'll only be using "trunk" but it's kind of a big hassle to move things around later so we're just gonna prepare by having all three from the get-go.

repo/bots/my-cool-bot
   repo/bots/my-cool-bot/branches
   repo/bots/my-cool-bot/tags
   repo/bots/my-cool-bot/trunk

You can read about the significance of these three directories on most tutorials so I'll leave it at that for now.

Importing A Project

Prepare Your Project

Remove all private/personal/login/passwords information. Pretend you were giving this to someone at a conference. Don't leave anything that could be potentially... bad. Once it's in the repository, it's in there. No one wants to go cleaning up after your mess if you accidentally check in the passwords to all your bank accounts. Also don't use paths specific to yakko. Your code should be able to run on any machine, from any directory. If your code relies on paths to other programs, or accesses other system resources, put these paths inside a config file and then check in a sample config file that people may copy and modify on their own (note: you should probably include "sample" somewhere in the filename of the sample config file, just to make things easy). If you want a good example, look at the wordpress source code. Check it out to your local machine, and notice that there is no wp-config.php file, only a wp-config.sample.php which you should be able to easily copy and change to work for you.

Ok, got all that? Is your project svn-worthy? Let's move forward...

Adding A Project

Say you want to add a bot. Go to the directory just above your bot. You should see the directory with your bot hidden away inside. Let's say it looks like this when you ls:

my-cool-bot

Ready to add it?

svn import my-cool-bot file:///home/svn/repo/bots/my-cool-bot

Checking-Out

To access code inside the repository (we'll use an example of the "bots" directory) check out the code as follows:

svn co file:///home/svn/repo/bots

This will check out the entire bots directory to your current directory. If you want to check out a specific bot, include that bots directory. Keep in mind that things should be organized in the branches/tags/trunk structure so your command should look more like this:

svn co file:///home/svn/repo/bots/geekboy/trunk geekboy

That will check out the "trunk" (main code-base) of "geekboy" (assuming he is there) into a local directory "geekboy". When you go into the directory you'll be able to do all the fancy svn things like:

svn log somefile.txt
svn edit somefile.txt
svn commit somefile.txt

etc...

See Also

Personal tools