Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

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.

like image 345
David Dean Avatar asked Aug 07 '09 01:08

David Dean


People also ask

How do I find my svn working copy?

The working copy will be located in a directory called trunk on your computer relative to the directory you issued the command in. If you wish to have a different name for your working copy you can add that as a parameter to the end of the command. e.g. This will create a working copy called MyProjectSource .

How do I find my svn path?

http:// or https:// This is svn over http or https. You need to find the virtual host in your apache configuration and look for a <Location> section that matches your url path and look for a SVNPath or SVNParentPath config line. This will tell you the location of your subversion repository.

What is working copy in Subversion?

Working copies A Subversion working copy is your own private working area, which looks like any other ordinary directory on your system. It contains a COPY of those files which you will have been editing on the website. You can edit these files however you wish, in the usual way.

What is working directory in svn?

svn, also known as the working copy administrative directory. This administrative directory contains an unaltered copy of the last updated files from the repository.


1 Answers

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]$  
like image 166
David Dean Avatar answered Oct 26 '22 16:10

David Dean