tags:

views:

409

answers:

4

Quite often I'm sitting in the middle of a subversion working copy, and I want to do a quick svn status to find out what changes I have made since the last checkin. However svn status only works on the current folder and it's children. (Similarly for svn up too)

I'd like a quick way to change to the root folder of the subversion working copy so I can run a svn status and see all files that have changed, maybe a checkin or a update, and then get back to work where I was before.

+4  A: 

Here's my first go at an answer: I wrote a little bash script called svnbase:

#!/bin/bash -u

# this command outputs the top-most parent of the current folder that is still 
# under svn revision control to standard out

# if the current folder is not under svn revision control, nothing is output
# and a non-zero exit value is given

parent=""
grandparent="."

while [ -d "$grandparent/.svn" ]; do
    parent=$grandparent
    grandparent="$parent/.."
done

if [ ! -z "$parent" ]; then
    echo $parent
else
    exit 1
fi

So now I can do this:

[~/work/scripts/XXX/code/speech-detection/framework]$ cd $(svnbase)
[~/work/scripts/XXX]$ svn status
?      code/speech-detection/framework/output.old
[~/work/scripts/XXX]$ cd -
/home/XXXX/work/scripts/XXX/code/speech-detection/framework
[~/work/scripts/XXX/code/speech-detection/framework]$
David Dean
The next logical step would be to integrate that series of commands you're typing into the script itself.
Craig McQueen
+1  A: 

It is not possible. SVN can be checked out from any depth, and any subdir acts like brand new checkout.

edit: svnbase script in prev comment works, but it is not precise.

stepancheg
what do you mean by precise?
David Dean
Parent directory may be a checkout of another repository.
stepancheg
+3  A: 

If you use git-svn as your Subversion client, then you can interact transparently with a Subversion repository using Git commands locally. Git automatically shows you pending across the whole repository when you use commands like git status anywhere in the tree.

Greg Hewgill
A: 

actually, if you look in your .svn/entries file, you'll find the base listed in there usually around line 6. In any event, the format of your svn url will give you some significant clues :P Oh yeah, i took the liberty of looking, and svn info will also tell you.

...sigh, that's not what you asked though. I like the solution in the first answer :P

stran
the svn info thing list the root of your repository though, not the working copy. So this wouldn't help if you didn't checkout the entire repository, whereas `svnbase` above still would.
David Dean
yep, agreed. +1 :)
stran