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

A

Alia Khouri

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>
 
A

Alia Khouri

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>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top