views:

428

answers:

4

Having been spoiled by tortoiseSVN, I'm now using the command line in linux to interact with an svn repo.

In tortoise svn I would just commit changes and it would show me a list of what was added, what was deleted and what was modified. I'd check all the boxes and click OK.

With the command line, it appears I have to do svn add when I add files and svn rm when I remove files and when that's all done, then I type svn commit and it commits the added, the removed and the modified.

So my question is this: is there a command I can use that just commits files/folders I've removed, files/folders I've added and files I've modified all in one go?

+3  A: 

There's no svn command, but I'm sure there's a script or two that can scan for unversioned/missing files and issue the appropriate commands...

Edit: I found one here: http://gael-varoquaux.info/computers/svnautocommit/index.html

Edit: Adding the full script

#!/bin/bash


#------------------------------- Subroutines ---------------------------------
usage(){
echo " Usage: $(basename $0) PATH" 
echo ""
echo "Automatically commits the changes of svn working copy located in PATH."
echo "The new files are automatically added and the files that have been removed"
echo "are removed."
echo ""
echo "By Gael Varoquaux"
}

#------------------------------- Process the options -------------------------
if [ $# -eq 1 ]
then
    workingdir="$1"
else
    usage
    exit 1
fi

if ! cd $workingdir
then
    echo $workingdir is not a accessible path.
    usage
    exit 1
fi

#------------------------------- Find out what has changed -------------------

# A warning if this fails :
echo "SVN autocommit failed" > $HOME/local/motd

svnstatus=$(svn status $workingdir)
added=$(printf "$svnstatus" | sed -n 's/^[A?] *\(.*\)/\1/p')
removed=$(printf "$svnstatus" | sed -n 's/^! *\(.*\)/\1/p')

if [ "x$added" != "x" ]
then
    echo adding "$added" to repository
    svn add $added
fi

if [ "x$removed" != "x" ]
then
    echo removing "$removed" to repository
    svn remove $removed
fi

svn commit -m "autocommit" && rm $HOME/local/motd

The python version appears to not be there unfortunately.

You may want to modify the script to take a parameter for comments, but its a start. You can also modify it to be an easy way to do the add/deletes for you, and do the commit manually.

Nader Shirazie
A: 

In short, no. You have to svn add and svn delete each item.

If you are not tied to SVN, some other source control systems offer this feature; for example, Mercurial’s hg addremove.

Nate
A: 

With the standard svn tools, there's no such thing - it's mentioned in the FAQ as a Bad Thing.

nos
I'm more tied to svn but at least I understand why they made this decision. Thanks.
+1  A: 

to add:

svn status | grep "^\?" | sed -e 's/? *//' | sed -e 's/ /\\ /g' | xargs svn add

to remove:

svn status | grep "^\!" | sed -e 's/! *//' | sed -e 's/ /\\ /g' | xargs svn remove

works fine for me.

luca