Created
September 18, 2014 10:47
-
-
Save wolf0403/2b94d85abc1f73a29845 to your computer and use it in GitHub Desktop.
List svn revisions by parsing `svn log` output.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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