472,353 Members | 1,201 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,353 software developers and data experts.

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
1 1143
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: R. Rajesh Jeba Anbiah | last post by:
I'm searching for a pure svn client in PHP, but didn't find one yet. Also, I see many Wiki system designs are somewhat flawed as they didn't use...
5
by: Klemens | last post by:
I get SQL30090 reason 18 by trying to do an insert in a federated table and an update in a local table in one transaction Do I have to change...
0
by: Larry Hastings | last post by:
I'm working on a patch or two for Python. Now, it's always best to use a source code manager (rcs, whatever) when writing code; in particular it'd...
1
by: frankatle | last post by:
Hi. I am writing a opensource code snippet manager in python (pyqt4). The idea is that users can upload their snippets to remote subversion...
11
by: Jorgen Bodde | last post by:
Hi all, I want to provide my users the ability to download a repository from the web, and after that check for updates. I thought of a mechanism...
1
by: Oltmans | last post by:
Hi all, I'm new to sub-version and still learning the process. We've a scenario in our office where we do a Svn-Update on a certain folder to...
3
by: Adem24 | last post by:
The history of the continuing decline and fall of the hated Empire: "The Cathedral and the Bazaar":...
3
by: sniipe | last post by:
Hi, I am looking fo svn library(module) which is used in the svn- mailer(http://opensource.perlig.de/svnmailer/) project. Does anybody know...
1
Airslash
by: Airslash | last post by:
Hello, not really sure if this is the correct forum, but there's something I need to check/ask. It will probably be a logical thing for seasoned...
1
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific...
0
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand....
0
BLUEPANDA
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.