views:

1134

answers:

4

I've been using this long command:

svn st | awk '/\?/ {print $2}' | xargs svn add

Similarly, to svn rm files I accidentally deleted with normal rm with :

svn st | awk '/\!/ {print $2}' | xargs svn rm --force

I guess I can write a bash function to do these two, but I'd prefer an interactive add/rm like the one git has.

+4  A: 

I use a generalization of the command line that you run, called svnapply.sh. I did not write it, but I don't remember where I found it. Hopefully, the original author will forgive me for reposting it here:

#!/bin/bash
#
# Applies arbitrary commands to any svn status. e.g.
#
# Delete all non-svn files (escape the ? from the shell):
# svnapply \? rm
#
# List all conflicted files:
# svnapply C ls -l

APPLY=$1
shift

svn st | egrep "^\\${APPLY}[ ]+" | \
sed -e "s|^\\${APPLY}[ ]*||" | \
sed -e "s|\\\\|/|g" | \
xargs -i "$@" '{}'

Per the comments, the script allows you to run arbitrary commands against all files with the same status.

Update:

It would not be too difficult to write a script that takes a file path as an argument and prompts the user for add/delete and then does the appropriate thing for that file. Chaining that together with the above script would get you what you want.

Brandon DuRette
A: 

Use a GUI that can show you all the untracked files, then select all and add. Any decent SVN gui should provide this functionality.

That said, be careful you really want all those files.

Colin Jensen
A: 

TortoiseSVN has the option of showing unversioned files in the Commit and Show Changes dialogs. You can right click a file to 'Add' it or to mark it as ignored.

If you are using Visual Studio: The latest stable version of AnkhSVN has a similar command, but in most cases it only shows the files you should add. (The project provides a list of files to version to the SCC provider; other files are ignored automatically)

Bert Huijben
If you're in the TortoiseSVN commit dialog you can be even lazier. TortoiseSVN will automatically add any non-versioned files that you have checked in the dialog when you commit.
Simon Lieschke
+3  A: 

there's an easier line...

svn add `svn status | grep ?`

then you can set it up as an alias in ~/.bashrc such as

alias svn-addi='svn add `svn status | grep ?`'
Mark Shust