Skip to content

Instantly share code, notes, and snippets.

@ceilfors
Last active October 12, 2016 18:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save ceilfors/741d8152106a310dd454 to your computer and use it in GitHub Desktop.
Save ceilfors/741d8152106a310dd454 to your computer and use it in GitHub Desktop.
Python script to extract all of the svn:externals in a SVN path recursively.
"""
This script is adapted from http://stackoverflow.com/a/10286163/2464295 but without the
multi threading factor of it.
Usage: `externals.py https://svn-server/repository`
Do note that the script is excluding src and hidden directories that starts with dot. Just modify the file
as it's not parameterized.
If you want this script to run faster, SSH to the SVN server and use file protocol.
Usage: `externals.py file:///svn/repository`
"""
import os
import sys
def getExterns(url, base_dir):
cmd = 'svn propget svn:externals "%s"' % url
pipe = os.popen(cmd, 'r')
data = pipe.read()
pipe.close()
if (data):
print "#", url
print(data.strip())
print
def processDir(url, base_dir):
getExterns(url, base_dir )
cmd = 'svn list "%s"' % url
pipe = os.popen(cmd, 'r')
listing = pipe.read().splitlines()
pipe.close()
dir_list = []
for node in listing:
if node.endswith('/') and not node.endswith('src/') and not node.startswith('.'):
dir_list.append(node)
for node in dir_list:
processDir(url+node, base_dir+node )
def analyzePath(url, base_dir = ''):
processDir(url, base_dir )
analyzePath(sys.argv[1])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment