Here’s what I’ve ended up doing.
- I’m checking out folders individually into my packages dir.
- I’ve written a script which will bulk-update and bulk-commit changes to the svn packages in the packages dir.
- I run the bulk-update whenever I want to update things.
It’s multithreaded, so it’s pretty fast at updating a lot of small package folders.
The library code (svnlib.py) is this;
import os, sys, subprocess
from threading import Thread
#
# These directories contain subdirectories which are subversion repositories.
# These are, then, collections of SVN repos, rather than repos themselves.
#
dirs =
"c:\\usr",
"c:\\missing",
"C:\\Documents and Settings\\Steve\\Application Data\\Sublime Text\\Packages"
]
def exist(x): return os.path.exists(x) # does a file/folder x exist?
def children(d): return [os.path.join(d, x) for x in os.listdir(d)] # subdirs/files of d
def issvn(x): return exist(os.path.join(x, ".svn")) # is x a subversion folder?
def flatmap(f, L): # like map, but for a fn of type a->**, converts [a]->**, not [a]->**]
for l in L:
for r in f(l):
yield r
def update(direc):
"""starts a subversion update thread for the given directory"""
updater = Updater(direc)
updater.start()
return updater
def commit(direc):
"""starts a subversion commit thread for the given directory"""
committer = Committer(direc)
committer.start()
return committer
class Committer(Thread):
"""Commit thread"""
def __init__(self, direc):
Thread.__init__(self)
self.direc = direc
def run(self):
print "Committing", self.direc
self.result = subprocess.call('svn', 'commit', '-m', '', self.direc ])
class Updater(Thread):
"""Update thread"""
def __init__(self, direc):
Thread.__init__(self)
self.direc = direc
def run(self):
print "Updating", self.direc
self.result = subprocess.call('svn', 'up', self.direc ])
def existingSvnDirs(dirs):
"""gives subversion directories within the dirs directories."""
subs = filter(issvn, flatmap(children, map(os.path.abspath, filter(exist,dirs))))
return subs
def runSvnProcess(proc):
"""Run a subversion process (update, commit) against a set of subversion repos"""
# start the update/commit process
threads = ]
for sub in existingSvnDirs(dirs):
threads.append(proc(sub))
# wait for the threads to join and show the results.
for thread in threads:
thread.join()
print "finished", thread.direc, "with", thread.result
and it’s invoked like this;
import svnlib
svnlib.runSvnProcess(svnlib.update)
The top of the library contains a list of my subversion-controlled folders; you’ll want to edit this before you use it.******