snippet to update local (bazaar, mercurial, svn) versioned source
Alia Khouri
alia_khouri at yahoo.com
Wed Jul 16 01:34:42 EDT 2008
Here's a very simple snippet I use to automatically keep my versioned
sources fresh.. Posted here in case it may be of use to anybody...
<code>
#!/usr/local/bin/python
import os, sys
src = '/Users/ak/Code/src'
# utility functions
join, isdir, listdir = os.path.join, os.path.isdir
def run(cmd):
print cmd
os.system(cmd)
ops = {
'.bzr': ['bzr pull', 'bzr update'],
'.hg': ['hg pull', 'hg update'],
'.svn': ['svn update']
}
for folder in os.listdir(src):
target = os.path.join(src,folder)
if os.path.isdir(target):
internal = os.listdir(target)
for f in internal:
if f in ops:
print
os.chdir(target)
cmds = ops[f]
print
print target, '-->',
for cmd in cmds:
run(cmd)
</code>
More information about the Python-list
mailing list