Skip to content

Instantly share code, notes, and snippets.

@petdance
Created November 14, 2019 17:12
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 petdance/56a2eb3c66a15526125b6ef958ccd6f6 to your computer and use it in GitHub Desktop.
Save petdance/56a2eb3c66a15526125b6ef958ccd6f6 to your computer and use it in GitHub Desktop.
trunkdiff-files
#!/usr/bin/env python3
import os
import re
status = re.compile('^(\\+\\+\\+|---) \\s+ ([^\t]+) \t .+ \t \\((.+?)\\)$', re.X)
deletes = []
adds = []
diffs = []
with os.popen('svn diff svn+ssh://svn.flr.follett.com/svn/tw/trunk .') as f:
for line in f.readlines():
match = status.search(line)
if match:
filename = match.group(2)
if filename == '.':
continue
if match.group(3) == 'nonexistent':
if match.group(1) == '---':
target = adds
else:
target = deletes
else:
target = diffs
if filename not in target:
target.append(filename)
for source in adds, deletes:
for i in source:
diffs.remove(i)
for i in adds, deletes, diffs:
i.sort()
for i in adds:
print(f'={i}')
for i in diffs:
print(i)
for i in deletes:
print(f'# DELETED {i}')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment