Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

Diff of /website/externals.py [000000] .. [r1734] Maximize Restore

  Switch to side-by-side view

--- a
+++ b/website/externals.py
@@ -0,0 +1,51 @@
+#!/usr/bin/env python
+
+import os
+import sys
+import subprocess
+import re
+
+externals = {"site_resources" : "http://www.turbogears.org/svn/turbogears/site_resources/",
+"ez_setup.py" : "svn://svn.eby-sarna.com/svnroot/ez_setup/__init__.py",
+}
+
+urlline = re.compile("^URL: (.*)")
+
+def update(proj):
+    os.chdir(proj)
+    svninfo = subprocess.Popen(["svn", "info"], stdout=subprocess.PIPE)
+    out = svninfo.stdout
+    line = out.readline()
+    while line:
+        line = out.readline()
+        url = urlline.match(line)
+        if url:
+            url = url.group(1).strip()
+            if url != externals[proj] and url != externals[proj][:-1]:
+                print "Switching project %s to %s" % (proj, externals[proj])
+                svnswitch = subprocess.call(["svn", "switch", externals[proj], "."])
+            else:
+                print "Updating project %s" % (proj)
+                svnupdate = subprocess.call(["svn", "update"])
+            break
+    if not url:
+        print "Error! Unable to find URL for project %s"
+    os.chdir("..")
+
+def checkout(proj):
+    print "Checking out %s" % (proj)
+    svncheckout = subprocess.call(["svn", "checkout", externals[proj], proj])
+
+def run():
+    if not os.path.exists("externals.py"):
+        print "You must run this script from the top directory."
+        sys.exit(1)
+        
+    for proj in externals:
+        if os.path.exists(proj):
+            update(proj)
+        else:
+            checkout(proj)
+
+if __name__ == "__main__":
+    run()