Does anybody know a way to recursively remove all files in a working copy that are not under version control? (I need this to get more reliable results in my automatic build
I stumbled on svn-clean on my RH5 machine. Its located at /usr/bin/svn-clean
http://svn.apache.org/repos/asf/subversion/trunk/contrib/client-side/svn-clean
Edit:
Subversion 1.9.0 introduced an option to do this:
svn cleanup --remove-unversioned
Before that, I use this python script to do that:
import os
import re
def removeall(path):
if not os.path.isdir(path):
os.remove(path)
return
files=os.listdir(path)
for x in files:
fullpath=os.path.join(path, x)
if os.path.isfile(fullpath):
os.remove(fullpath)
elif os.path.isdir(fullpath):
removeall(fullpath)
os.rmdir(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))
It seems to do the job pretty well.
Since everyone else is doing it...
svn status | grep ^? | awk '{print $2}' | sed 's/^/.\//g' | xargs rm -R
If you are on windows command line,
for /f "tokens=2*" %i in ('svn status ^| find "?"') do del %i
Improved version:
for /f "usebackq tokens=2*" %i in (`svn status ^| findstr /r "^\?"`) do svn delete --force "%i %j"
If you use this in a batch file you need to double the %
:
for /f "usebackq tokens=2*" %%i in (`svn status ^| findstr /r "^\?"`) do svn delete --force "%%i %%j"
Just do it on unix-shell with:
rm -rf `svn st . | grep "^?" | cut -f2-9 -d' '`
Can you not just do an export to a new location and build from there?