Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
498 views
in Technique[技术] by (71.8m points)

svn - How can I find the root folder of a given subversion working copy

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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]$ 

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...