Skip to content

Instantly share code, notes, and snippets.

@dreyescat
Created May 17, 2012 12:32
Show Gist options
  • Save dreyescat/2718612 to your computer and use it in GitHub Desktop.
Save dreyescat/2718612 to your computer and use it in GitHub Desktop.
Remove svn missing (removed by non-svn command) or incomplete files
#!/usr/bin/env python
import sys
from subprocess import check_output, call
if len(sys.argv) > 2:
sys.exit('Usage: {0} svn-folder'.format(sys.argv[0]))
svn_folder = sys.argv[1] if len(sys.argv) == 2 else '.'
output = check_output(['svn', 'status', svn_folder])
if output:
for n, line in enumerate(output.split('\n')):
fields = line.split()
if len(fields) == 2:
if fields[0] == '!':
result = call(['svn', 'rm', fields[1]])
print '{0} svn rm {1} {2}'.format(n, fields[1], result)
else:
print n, fields
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment