A convenience script to update a pre-specified folder containing subversion, mercurial, bazaar, and/or git source folders
To use it:
change the 'src' variable below to point to your source folder
name this script to something appropriate (I call it 'update')
put it into a directory on your PATH
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | #!/usr/bin/env python
"""
A convenience script to update a pre-specified folder containing
subversion, mercurial, bazaar, and/or git source folders
To use it:
- change the 'src' variable below to point to your source folder
- name this script to something appropriate (I call it 'update')
- put it into a directory on your PATH
"""
import os, sys
# define source folder here
src = '/home/user/src'
def run(cmd):
print cmd
os.system(cmd)
operations = {
'.bzr': ['bzr pull', 'bzr update'],
'.hg': ['hg pull', 'hg update'],
'.svn': ['svn update'],
'.git': ['git pull']
}
for folder in os.listdir(src):
target = os.path.join(src, folder)
if os.path.isdir(target):
contents = os.listdir(target)
for f in contents:
if f in operations:
print
# print f, target
os.chdir(target)
cmds = operations[f]
print
print target, '-->',
for cmd in cmds:
run(cmd)
|
Related package - sources: http://code.activestate.com/pypm/sources/