467,077 Members | 1,008 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,077 developers. It's quick & easy.

snippet to update local (bazaar, mercurial, svn) versioned source

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>
Jul 16 '08 #1
  • viewed: 1041
Share:
1 Reply
On Jul 16, 8:34*am, Alia Khouri <alia_kho...@yahoo.comwrote:
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>
My bad...., here's the one that actually (-:

<code>

#!/usr/local/bin/python
import os, sys

src = '/Users/sa/Code/src'

# utility functions
join, isdir = 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 = join(src,folder)
if isdir(target):
internal = os.listdir(target)
for f in internal:
if f in ops:
print
# print f, target
os.chdir(target)
cmds = ops[f]
print
print target, '-->',
for cmd in cmds:
run(cmd)

</code>

Jul 16 '08 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by R. Rajesh Jeba Anbiah | last post: by
1 post views Thread by frankatle@gmail.com | last post: by
11 posts views Thread by Jorgen Bodde | last post: by
3 posts views Thread by Adem24 | last post: by
3 posts views Thread by sniipe@gmail.com | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.