Skip to content

Instantly share code, notes, and snippets.

@PowerKiKi
Created May 12, 2011 13:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PowerKiKi/968513 to your computer and use it in GitHub Desktop.
Save PowerKiKi/968513 to your computer and use it in GitHub Desktop.
#!/usr/bin/ruby
=begin
If you have subversion repository with many externals, it may take a bit too long to update it, as updates happen one after another.
This bit of script updates each external in parallel, making it oh so much faster.
(note: if you add an external or change an external property in another way, you'll need to run the standard svn up once)
Last seen on http://codesnippets.joyent.com/posts/show/548
=end
puts(
( `svn pl -R`.scan(/\S.*'(.*)':\n((?: .*\n)+)/)\
.inject({}) { |h, (d, p)| h[d] = p.strip.split(/\s+/); h }\
.select { |d, ps| ps.include? 'svn:externals' }\
.map { |xd, ps| [xd, `svn pg svn:externals #{xd}|grep -v ^#`] }\
.map { |xd, exts| exts.strip.split(/\s*\n/).map { |l| xd + '/' + l.split(/\s+/).first } }\
.inject { |a, b| a + b }\
.map { |d| "cd #{d} && svn up 2>&1" } \
<< 'svn up . --ignore-externals 2>&1'
)\
.map { |cmd| [cmd, Thread.new { `#{cmd}` }] }\
.map { |cmd, thread| "#{cmd}\n#{thread.value}" }.join("\n")
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment