Skip to content

Instantly share code, notes, and snippets.

@wolf0403
Created September 18, 2014 10:47
Show Gist options
  • Save wolf0403/2b94d85abc1f73a29845 to your computer and use it in GitHub Desktop.
Save wolf0403/2b94d85abc1f73a29845 to your computer and use it in GitHub Desktop.
List svn revisions by parsing `svn log` output.
import subprocess as sp
def list_revs(path, limit=10):
""" Parse output from svn log and find log headers. Maybe fooled if log entry contains some other svn log entries, etc."""
out = sp.check_output('svn log -l {limit} {path}'.format(path=path, limit=limit), shell=True)
lines = out.split('\n')
for pre, line, space in zip(lines[:-2], lines[1:], lines[2:]):
if pre.startswith('-------') and space.strip() == '':
parts = line.split('|')
if len(parts) == 4 and parts[0].startswith('r'):
yield parts[0].strip()[1:]
print list(list_revs('.', 10))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment