Doug Noel
Doug Noel

Reputation: 704

In SVN, how can you tell which branch a revision was checked into?

Here is the issue we are having:

A developer will have trunk checked out in his sandbox. We have created a switch script to switch certain files to a branch where changes are being made. Sometimes the switch script seems to fail, and the developer checks his changes in. Those changes show up in the revision log, but we can't figure out if they're checked into the branch or trunk. They seem to get lost on the developer's box. This causes a lot of switching back and forth and often when it's a small change, it just gets recoded.

So my question is, how can we tell what branch a revision was checked into?

Upvotes: 1

Views: 419

Answers (3)

Edwin Buck
Edwin Buck

Reputation: 70969

Revisions are per tree, so first you need to get the "changes" for a revision

svn diff -r <start revision>:<end revision> --summarize <root svn URL>

which might produce output such as

A       file:///home/xxx/svn/yyy/trunk/src/main/java/com/proj/App.java
A       file:///home/xxx/svn/yyy/trunk/src/main/java/com/proj
A       file:///home/xxx/svn/yyy/trunk/src/main/java/com
A       file:///home/xx/svn/yyy/trunk/src/main/java
A       file:///home/xxx/svn/yyy/trunk/src/main
A       file:///home/xxx/svn/yyy/trunk/src
A       file:///home/xxx/svn/yyy/trunk/pom.xml
 M      file:///home/xxx/svn/yyy/trunk

Branches are implemented as directories in SVN, so then you need to determine the root of the project, and which immediate subdirectories are considered (by convention) "branches"

In the example above

file:///home/xxx/svn/yyy/

is considered the "root" url of the project, so subracting that from

file:///home/xxx/svn/yyy/trunk

tells me that the "branch" it was checked in on was

trunk

Note that other items were checked in on

trunk/src/main/java/com

But that is not a branch, by my convention. Since the decision of what is a branch is conventional, this last determination of which branches were affected is going to require knowledge of your particular SVN setup. In my case

branches/branchA

is considered a branch by myself (for my project) but

branches/branchA/src

is not considered a branch.

Upvotes: 2

crashmstr
crashmstr

Reputation: 28583

If you are not using TortoiseSVN, you can get a verbose svn log:

svn log --verbose -r HEAD

This will show the svn location of all files in the commit (just like @Gilbert Le Blanc's answer). Example output below. Change HEAD to the specific revision if you need something different.

------------------------------------------------------------------------
r556 | USER | 2012-08-30 13:37:35 -0500 (Thu, 30 Aug 2012) | 1 line
Changed paths:
   M /trunk/Path/File.cs

Commit Comment
------------------------------------------------------------------------

Upvotes: 2

Gilbert Le Blanc
Gilbert Le Blanc

Reputation: 51565

Using Tortoise, I pulled up a log of a program I modified.

Log messages

I highlighted the action and path. The path shows me exactly what was modified, on what branch.

Upvotes: 2

Related Questions