Subversion on OS X, Part 2: Your First Project
I ran into some permissions problems trying to actually get a project into the repository, so I thought I’d walk through how to get things working in just one try instead of twenty:
- Do Not put your repository under your Apache web root, or any virtual host web root. Just don’t. It won’t work.
- Apache needs read and write permissions on your Subversion directory. The simplest but perhaps not the most secure way to do this is, after you create the repository, to change the owner of the repository directory and all its contents to the user that Apache runs as (in my case,
www).If you want to still be able to write directly to it (for instance, to set up the configuration) without sudo-ing, you can change the group permissions to allow a group that you’re a member of to write to it. (Like I said, this is probably not the most secure way to do things, but it’s the easiest, and probably fine for something that’s carefully limited to your own machine. I hate dealing with file permissions, so I set it up the lazy way.)
You can do all of this with OS X’s “Get Info”, or on the command line with
chown -Randchgrp -R - In your repository, find
conf/svnserve.conf, and uncomment the following lines:anon-access = read
auth-access = write
password-db = passwd - Now open conf/passwd and add a line to the bottom with the format:
username = passwordsubtituting, of course, the username and password that you want to use to access your repository. You can add additional lines for additional users.
- The SVNbook recommends creating
trunk,branches, andtagssubdirectories for each project in your repository, although this is by no means required. I don’t ancipate doing a huge amount of branching, but I figured it couldn’t hurt.The easiest way to get this set up, if you have already started your project somewhere and can’t change its location without breaking things because of absolute path configurations, is as follows:
- Create a
tmpdirectory on your desktop. - Inside
tmp, create a directory with the name of your project. You’ll be happiest if this is short and doesn’t include any spaces. - Inside the project directory, create
trunk,branches, andtagsdirectories. svn import . --username YOURUSERNAME --password YOURPASSWORD http://localhost:81/svn -m "repository layout for PROJECTNAME", substituting the appropriate username, password, and projectname. If you’re using a different URL for your repository, substitute that too, of course.
- Create a
- You may want Subversion to ignore particular types of files. For instance, with Django, I’m working with Python, which creates a compiled bytecode file for each script, with the extension
.pyc. These don’t need to be versioned because each one is recreated automatically from the script every time you change it and run it.Different languages and project types will have different files to ignore. There are also OS metadata files like OS X’s
.DS_Storeand Windows’Thumbs.dbthat you probably don’t want to carry around either.This is set up on the client side, and you’ll probably want to take care of it before importing or adding anything beyond that skeletal directory structure.
Open
~/.subversion/config, and locate the[miscellany]section. In there is a line, possibly commented out, that looks something like this:# global-ignores = *.o *.lo *.la #*# .*.rej *.rej .*~ *~ .#* .DS_StoreUncomment the line if it’s commented out, and add
.DS_Store(if it’s not already there) and*.pycto the end, so it looks something like this:global-ignores = *.o *.lo *.la #*# .*.rej *.rej .*~ *~ .#* .DS_Store *.pycWhile you’ve got the file open, you might want to scroll up to the
[helpers]section, and uncomment theeditor-cmdline, and set it to use your editor of choice. - OK, we need to import our project now.
First,
cdinto the parent directory of your project directory, and check out the trunk of the project (since the trunk is empty, this will do nothing except create a.svndirectory in the project directory, so subversion can handle it properly as a “working copy.):svn checkout http://localhost:81/svn/PROJECTNAME/trunk PROJECTDIRThen,
cdinto the project directory and tell Subversion to add everything from your project to the repository. For each subdirectory of the project that you want under version control (Subversion will recursively add directory contents):svn add SUBDIRNAMEThen add the files that live in the root in the project directory that you want versioned. I had a couple files I wanted to ignore (such as my sqlite database), so I just added the Python scripts:
svn add *.pycThen commit everything:
svn commit -m "Adding initial project files"And you’re done!
Post a Comment