Skip to content

Instantly share code, notes, and snippets.

@KayEss
Created January 4, 2014 12:40
Show Gist options
  • Save KayEss/8255030 to your computer and use it in GitHub Desktop.
Save KayEss/8255030 to your computer and use it in GitHub Desktop.
Some Python code for parsing the output of the `svn log` command.
#!/usr/bin/env python
import os
import subprocess
import sys
REPO="file:///var/backups/fsl-svn/felspar/"
def capture(args):
print args
return subprocess.check_output(args)
def log(path):
location = os.path.join(REPO, path[1:])
logdata = capture(['svn', 'log', '-v', '--incremental', location]).split('-'*72)
for logitem in logdata:
lines = logitem.split('\n\n')
meta = lines[0].split('\n')
if len(meta) > 2:
print
print '-' * 72
print meta[1]
for change in meta[3:]:
details = change.strip().split(' (')
change = details[0][2:]
print details[0][0], change[1:]
log(sys.argv[1])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment