How get local root path in svn?
Asked Answered
L

4

8

Mercuril, Git and Bazaar has a way to get path root:

git rev-parse --show-toplevel
hg root 
bzr root

How print the local root path in subversion?

Update

Example:

> svn checkout https://example.com/svn/foo ~/foo --username fabiocerqueira
> cd ~/foo
> svn root (don't works)
  /home/user/project/foo/
Levee answered 16/8, 2012 at 16:57 Comment(0)
I
4

Would the Working Copy Root Path from the svn info command provide what you need?

D:> svn info
Path: .
Working Copy Root Path: D:\workdir\local-tc-common-all
URL: svn://localhost/trunk/tc-common-all/src/main/bin
Repository Root: svn://localhost
Repository UUID: 4f1d1789-e46b-c140-9c77-f79c92213374
Revision: 61
Node Kind: directory
Schedule: normal
Last Changed Author: dweintraub
Last Changed Rev: 3
Last Changed Date: 2012-07-19 12:09:24 -0400 (Thu, 19 Jul 2012)

This gives you the root of the current checkout which seems to be what you're looking for. You can use the --xml switch which sometimes makes it easier to get programmatically since most programming languages are pretty good at parsing XML.

If you're looking for the root of the repository itself separate from the URL scheme, you could get that by taking the Repository Root out of the URL field.

Ichthyolite answered 17/8, 2012 at 13:11 Comment(2)
svn info don't returns "Working Copy Root Path". What is the version of the subversion? My version is 1.6.18 (r1303927)Levee
That example was cut from version 1.7 on Windows. However, I tried it with 1.6.18, and get the Repository Root path on the Mac.Ichthyolite
N
3

Did some search and found nothing... Finally I saw the old friend svn info and see if works for you...

$ svn info | grep 'Root'
Repository Root: http://your.subversion.com/path/to/root

Hope this helps!!!

Nita answered 16/8, 2012 at 17:16 Comment(1)
"svn info" returns remote root path. I wanna get the path where I made the checkout. Example: > svn checkout example.com/svn/foo ~/foo > cd ~/foo > svn root (don't works) /home/user/project/foo/Levee
C
0

If you install the SlikSvn client, you can do a "svn info" at any level of the checkout and it will return the local root path.

Christa answered 17/8, 2012 at 12:50 Comment(0)
P
0

I use svn info | awk -F: '/Root Path: (.*)/ { print $2 }' | xargs on Linux and Windows through Cygwin.

Pelorus answered 1/12, 2014 at 7:13 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.