Created
July 2, 2015 12:28
-
-
Save ph1ee/64559a91bf3bf862719d to your computer and use it in GitHub Desktop.
Remove untrakced files from Subversion working copy
This file contains 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
#!/usr/bin/python | |
import os | |
import re | |
import shutil | |
def removeall(path): | |
if os.path.islink(path): | |
os.unlink(path) | |
return | |
if os.path.exists(path): | |
if os.path.isfile(path): | |
os.remove(path) | |
return | |
for x in os.listdir(path): | |
fullpath=os.path.join(path, x) | |
if os.path.isfile(fullpath): | |
os.remove(fullpath) | |
elif os.path.isdir(fullpath): | |
removeall(fullpath) | |
if os.path.exists(path): | |
shutil.rmtree(path) | |
unversionedRex = re.compile('^ ?[\?ID] *[1-9 ]*[a-zA-Z]* +(.*)') | |
for l in os.popen('svn status --no-ignore -v').readlines(): | |
match = unversionedRex.match(l) | |
if match: removeall(match.group(1)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment