Created
November 22, 2008 19:19
-
-
Save topia/27921 to your computer and use it in GitHub Desktop.
update externals seperately
This file contains hidden or 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
""" | |
zope's huge facade breaks simple svn update (with 1.6.0 r34332). | |
""" | |
import sys | |
import os.path | |
from subprocess import Popen, check_call, PIPE | |
def svn_get_info(args): | |
output = Popen(["svn", "info"] + args, stdout=PIPE).communicate()[0] | |
col = dict() | |
for line in output.splitlines(): | |
line = line.strip() | |
if line: | |
k, v = line.strip().split(': ', 1) | |
col[k] = v | |
return col | |
def main(args): | |
check_call(["svn", "up", "--ignore-externals"] + args) | |
path = svn_get_info(args)['Path'] | |
output = Popen(["svn", "status", "--ignore-externals", path], | |
stdout=PIPE).communicate()[0] | |
dirs = set() | |
for line in output.splitlines(): | |
status, tail = line.split(None, 1) | |
if status == "X": | |
dirs.add(os.path.dirname(tail)) | |
for dir in dirs: | |
output = Popen(["svn", "propget", "svn:externals", dir], | |
stdout=PIPE).communicate()[0] | |
for entry in output.splitlines(): | |
fields = entry.split() | |
if not fields: | |
continue | |
url = fields.pop() | |
path = os.path.join(dir, fields.pop(0)) | |
print "\nFetching external from %s %s" % (path, ' '.join(fields)) | |
if os.path.exists(path): | |
# check URL | |
cururl = svn_get_info([path])['URL'] | |
if cururl != url: | |
check_call(["svn", "switch", url, path] + fields) | |
else: | |
check_call(["svn", "up", path] + fields) | |
else: | |
check_call(["svn", "checkout", url, path] + fields) | |
exit(main(sys.argv[1:])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment