You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@subversion.apache.org by Nathan Lewis <Na...@bbc.co.uk> on 2006/01/11 18:19:04 UTC

query for the root of the working directory?

Hi Everyone,

Is there a way in subversion to get the root of the working copy? I am
seeking to write a pre-commit hook that runs tests on the committed
files but I need to run them from within the user's working copy.

I have tried looking through the documentation and the .svn directories
in my local checkout but haven't spotted anything.


Thanks in advance for your help.


Nathan

Re: query for the root of the working directory?

Posted by Carsten Koch <Ca...@icem.com>.
Nathan Lewis wrote:
...
> Is there a way in subversion to get the root of the working copy? 

You should be able to do that with a few lines of shell
or python code.
"svn info" gives you the URL of the current working
directory like this:
URL: http://server/repos/top-dir/second-dir/third-dir

After a "cd .." this should be:
URL: http://server/repos/top-dir/second-dir

etc.

Just keep doing "cd .." until the URL returned is not
the previous URL without the last element.
Then go back down one level to the previous wd.

Carsten.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org

Re: query for the root of the working directory?

Posted by Paul Koning <pk...@equallogic.com>.
>>>>> "Nathan" == Nathan Lewis <Na...@bbc.co.uk> writes:

 Nathan> Hi Everyone,

 Nathan> Is there a way in subversion to get the root of the working
 Nathan> copy? I am seeking to write a pre-commit hook that runs tests
 Nathan> on the committed files but I need to run them from within the
 Nathan> user's working copy.

 Nathan> I have tried looking through the documentation and the .svn
 Nathan> directories in my local checkout but haven't spotted
 Nathan> anything.

How about something like this:
    while ("../.svn" exists) { cd .. }

Somewhat of a hack, but it should work just fine.

	 paul


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org

Re: query for the root of the working directory?

Posted by Ryan Schmidt <su...@ryandesign.com>.
On Jan 11, 2006, at 19:19, Nathan Lewis wrote:

> Is there a way in subversion to get the root of the working copy? I  
> am seeking to write a pre-commit hook that runs tests on the  
> committed files but I need to run them from within the user's  
> working copy.

You do realize that the pre-commit hook runs on the server, and the  
working copy is located on the client, and so the hook script never  
has access to the client's working copy?

Unless of course all your users' working copies are stored on the  
same machine that serves as the repository server. We happen to have  
things set up that way at work, accessing the working copies via SMB  
and SSH, but every time I mention it on this list, people think I'm  
nuts, so I don't think it's the way most people use Subversion.

Even if you are set up that way, once a transaction comes in to the  
repository and your hook is called, the hook will only know what path  
within the repository the transaction is trying to affect; it won't  
know the path to the working copy that caused the commit. You would  
have to define a policy for your users, such as "Thou shalt always  
put your working copies in ~/working_copies and must always name the  
directories exactly as they appear in the repository" so that you  
would have some chance of programmatically locating the working copy.  
That would seem to restrict your users to a single working copy of  
each project, though, a limitation I would not be pleased to have to  
deal with, were it imposed on me...

Don't forget that the user may have other files in their working copy  
which they haven't committed yet, so it doesn't seem like a very good  
idea to try to use their working copy as a basis for allowing or  
denying a transaction.

Others who have the need to have a working copy in order to verify a  
transaction (for example, because they want to compile checked-in  
code, and prevent the commit if the build fails) have the hook script  
maintain its own private working copy for this purpose.



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org