Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rewrite svn-clean to improve performance
Don't run svn status three times which is rather expensive. Also, instead of sleeping, use a flag (-f) to force the clean. This behavior is similar to git-clean.
- Loading branch information
1 parent
8b6b2c4
commit bfa9a58
Showing
1 changed file
with
25 additions
and
10 deletions.
There are no files selected for viewing
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
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -1,16 +1,31 @@ | |||
#!/bin/sh | #!/bin/sh | ||
|
|
||
if [ ! -d ".svn" ]; then | cleanup() { | ||
echo "Not in svn working copy" | rm "$svn_out" | ||
rm "$svn_err" | |||
} | |||
|
|||
svn_out=$(mktemp) | |||
svn_err=$(mktemp) | |||
|
|||
svn status --no-ignore 2> "$svn_err" | grep '^[?I]' | cut -c '9-' > "$svn_out" | |||
|
|||
if [ -s "$svn_err" ]; then | |||
echo "svn error:" | |||
cat "$svn_err" | |||
cleanup | |||
exit 1 | exit 1 | ||
fi | fi | ||
|
|
||
res=$(svn status --no-ignore | grep '^[?I]' | cut -c '9-') | if [ -s "$svn_out" ]; then | ||
if [ -n "$res" ]; then | if [ -z "$1" ]; then | ||
echo "List of files to clean:" | echo "Would remove (use -f to force):" | ||
svn status --no-ignore | grep '^[?I]' | cut -c '9-' | cat "$svn_out" | ||
echo "Cleaning in 10 seconds" | else | ||
sleep 10 | echo "Removing:" | ||
svn status --no-ignore | grep '^[?I]' | cut -c '9-' | \ | cat "$svn_out" | ||
xargs -d '\n' rm -rf | xargs -d '\n' rm -rf < "$svn_out" | ||
fi | |||
fi | fi | ||
|
|||
cleanup |