Muffinresearch Labs by Stuart Colville

Django: Switching between development branches | Comments (2)

Posted in Code, Linux/Unix on 9th March 2008, 7:47 pm by Stuart

Cyril and I have been using new forms admin for some stuff we are working on for fun whilst we are here at SXSWi. One of the issues is that if you’re developing several different Django sites you won’t necessary want to migrate away from trunk to migrate everything to one of the other branches that you’re trying out. Obviously at some point in the future work like the new forms admin branch and the queryset refactor branch will be merged back to trunk and you’ll want to switch back.

To make life a little easier I knocked up a simple shell script to switch between branches by changing the symlink to site-packages. This assumes you are already using the method which symlinks the svn source into site-packages.

As long as the branches are in the same directory this script will work as it simply creates a selection based on the branches contained withing the directory specifed in the constant “DJANGOBRANCHES”. Simply change the constant to meet your needs:

#!/usr/bin/env bash

DJANGOBRANCHES=/Users/muffin/django/
SITEPACKAGES=/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/

cd $DJANGOBRANCHES
echo 'Choose Django branch:'

select dir in *;
do
    if [ -n "$dir" ] && [ -d ${DJANGOBRANCHES}${dir}/ ]
    then
      rm -f ${SITEPACKAGES}django
      ln -s ${DJANGOBRANCHES}${dir}/django ${SITEPACKAGES}django
      break
    else
      echo "Error: You choice '$REPLY' does not correspond to a branch"
    fi
done

exit 0

Using the script is simple:

muffin@shiva muffin/django $ switch_django
Choose Django branch
1) django_src
2) newforms-admin
#? 2

Check the site-packages directory and you should see the correct branch is now sym-linked.

Post Tools

Comments: Add yours

1. On March 18th, 2008 at 8:40 pm Justin Bronn said:

I also created a script, chdjango, (in Python) for the same purpose. However, it lacks the interactive menu — I may have to borrow that idea.

2. On March 18th, 2008 at 10:34 pm Stuart Colville said:

@justin: Great minds think alike!







XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>



Using Loggerhead with mod_wsgi|(0)

Here’s a post I wrote over on the Project Fondue Blog about our use of Loggerhead with mod_wsgi under Apache. Loggerhead is the rather nice branch viewer for bazaar branches as used on Launchpad.net.

If you’re not already subscribed to the Project Fondue blog feed then I can recommend it, as there should be some interesting posts coming out of there in the coming months (yes I’m unashamedly biased!).

Ubuntu: Turn off changing workspace with mouse wheel|(1)

I found the changing with the workspace with the mouse wheel really annoying. To disable it go to System => Preferences => CompizConfig (available if the compizconfig-settings-manager package is installed) and uncheck “Viewport Switcher” which is under the “Desktop” heading.

Photos on Flickr

© Copyright 2004-10 Stuart Colville, all rights reserved. May contain traces of Muffin. Powered by WordPress. Hosting by Slicehost.com This page was baked in 0.556s.