#!/usr/env/python
import os
import os.path
from subprocess import call
if __name__ == "__main__":
apps_dir = os.path.abspath('.')
for app_name in os.listdir(apps_dir):
app_dir = os.path.abspath(os.path.join(apps_dir, app_name))
git_path = os.path.join(app_dir, '.git')
svn_path = os.path.join(app_dir, '.svn')
if os.path.lexists(svn_path):
print "Updating svn %s" % app_dir
os.chdir(app_dir)
call(['svn', 'update'])
elif os.path.lexists(git_path):
print "Updating git %s" % app_dir
os.chdir(app_dir)
call(['git', 'pull'])
else:
continue
Comments
Subversion has an "externals" facility that works well in this situation: simply define all your external apps (even Django itself, perhaps) in
svn:externals, then ansvn upwill pull all the latest versions. (You can also lock a specific revision.)I think
githas something similar, but I don't know how it works.#
Thanks! been wanting this for sometime
#
@kcarnold: yes, but with svn:externals you will always use the most recent version, not the one you've tested against. Have a look at http://piston.rubyforge.org/
#
@kcarnold: That's a really great solution when all of your applications are within a subversion project, and we do it that way for the Pinax project. That being said, I like to keep a separate global directory just for Django apps, and this script addresses that particular use case.
#
Great snippet, but is it possible to add Mercurial support?
The update command is
hg -u pull#