Hello. My name is Noemi Millman, and Triopter is my web development agency. We handcraft beautiful, dynamic websites.

See what I can do for you.

Noemi Millman: Triopter: Subversion on OS X, Part 2: Your First Project

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:

  1. Do Not put your repository under your Apache web root, or any virtual host web root. Just don’t. It won’t work.
  2. 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 -R and chgrp -R

  3. In your repository, find conf/svnserve.conf, and uncomment the following lines:

    anon-access = read
    auth-access = write
    password-db = passwd

  4. Now open conf/passwd and add a line to the bottom with the format:

    username = password

    subtituting, of course, the username and password that you want to use to access your repository. You can add additional lines for additional users.

  5. The SVNbook recommends creating trunk, branches, and tags subdirectories 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:

    1. Create a tmp directory on your desktop.
    2. 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.
    3. Inside the project directory, create trunk, branches, and tags directories.
    4. 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.
  6. 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_Store and Windows’ Thumbs.db that 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_Store

    Uncomment the line if it’s commented out, and add .DS_Store (if it’s not already there) and *.pyc to the end, so it looks something like this:

    global-ignores = *.o *.lo *.la #*# .*.rej *.rej .*~ *~ .#* .DS_Store *.pyc

    While you’ve got the file open, you might want to scroll up to the [helpers] section, and uncomment the editor-cmd line, and set it to use your editor of choice.

  7. OK, we need to import our project now.

    First, cd into 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 .svn directory in the project directory, so subversion can handle it properly as a “working copy.):

    svn checkout http://localhost:81/svn/PROJECTNAME/trunk PROJECTDIR

    Then, cd into 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 SUBDIRNAME

    Then 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 *.pyc

    Then commit everything:

    svn commit -m "Adding initial project files"

    And you’re done!

Post a Comment

Your email is never published nor shared. Required fields are marked *

Comments may be held for moderation to prevent spam: your comment may not appear immediately.