Created
December 9, 2008 17:16
-
-
Save kogakure/33974 to your computer and use it in GitHub Desktop.
Python: Updates Subversion, Git, Mercurial and Bazaar repositories recursive
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import os | |
import os.path | |
from subprocess import call | |
if __name__ == "__main__": | |
apps_dir = os.path.abspath('.') | |
for app_name in os.listdir(apps_dir): | |
app_dir = os.path.abspath(os.path.join(apps_dir, app_name)) | |
git_path = os.path.join(app_dir, '.git') | |
svn_path = os.path.join(app_dir, '.svn') | |
hg_path = os.path.join(app_dir, '.hg') | |
bzr_path = os.path.join(app_dir, '.bzr') | |
if os.path.lexists(svn_path): | |
print "" | |
print "* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *" | |
print "" | |
print "Updating Subversion %s" % app_dir | |
os.chdir(app_dir) | |
call(['svn', 'update']) | |
elif os.path.lexists(git_path): | |
print "" | |
print "* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *" | |
print "" | |
print "Updating Git %s" % app_dir | |
os.chdir(app_dir) | |
call(['git', 'pull']) | |
elif os.path.lexists(hg_path): | |
print "" | |
print "* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *" | |
print "" | |
print "Updating Mercurial %s" % app_dir | |
os.chdir(app_dir) | |
call(['hg', 'fetch']) | |
elif os.path.lexists(bzr_path): | |
print "" | |
print "* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *" | |
print "" | |
print "Updating Bazaar %s" % app_dir | |
os.chdir(app_dir) | |
call(['bzr', 'pull']) | |
else: | |
continue |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment