68

I am trying to merge the latest changes from trunk into a branch of my project, but the problem is I don't know what revision of the trunk I checked out that I eventually created the branch from. I would think SVN logged this somewhere. Does anyone know how I can find the revision number?

(In other words, the Subversion equivalent of git merge-base master branch-name)

Andy
  • 7,885
  • 5
  • 55
  • 61
  • 1
    If you're using svn 1.5 or later, you don't need to know this revision number in order to do the merge. `svn merge ^/trunk .` will figure it out for itself. If that's not happening, you might have to `svnadmin upgrade` your repository. – slowdog Jun 07 '11 at 13:23
  • Hmmm...Subclipse asks for the start revision, I'll have to see if it can do a merge this way – Andy Jun 08 '11 at 23:33
  • @slowdog you mean the version of the server, right? – Line Jan 30 '19 at 12:05

6 Answers6

78

From the command line, the --stop-on-copy flag can be used to help show you where you copied a branch from:

svn log --stop-on-copy --verbose --limit 1 -r0:HEAD ^/branches/feature

(where feature is the name of your branch)

The last line of will say something like this:

Changed paths:
   A /branches/feature (from /trunk:1234)
rjdown
  • 9,162
  • 3
  • 32
  • 45
richq
  • 55,548
  • 20
  • 150
  • 144
  • ahh man. I wish there was a "stop on N copies" option! will have to traverse them manually. thanks! – Andy Jun 08 '11 at 23:36
  • I think a svn move will be picked up as a "copy" ... since it is an an copy and delete in one shot. So if you create a branch, and then rename it (rename as in the tortoise command to rename), it will throw off the "when did this branch start?" data. I only mention this because "rename" does not sound like "create"......sadly I learned this the hard way. – granadaCoder Mar 08 '13 at 21:31
  • 1
    The git equivalent of this is so much more logical... `git merge-base master feature-branch`. And it works well for scripting. – Andy Mar 08 '19 at 08:16
  • 1
    had to add `--verbose` to actually see the changed path with current TortoiseSVN svn command-line tool – Tono Wiedermann Dec 16 '19 at 16:07
22

Perhaps a little bit late but.

If you're currently in the branch you can run:

svn log -r 1:HEAD --limit 1 --stop-on-copy

It displays the first revision of the branch i.e. when you created it.

perkrlsn
  • 249
  • 3
  • 10
  • 1
    This is the correct answer. It doesn't list thousands of useless revisions, only to look at the last one. – bobbogo Mar 21 '17 at 13:27
  • 4
    I'd suggest adding the `-v` option to the above command so you can also get the `(from path:rev)` message. – Brian Stormont Jun 06 '17 at 15:01
  • @perkrlsn is there a command that displays just the revision in trunk right before that? – Andy Mar 08 '19 at 08:22
  • 1
    @BrianStormont could you please help me understand, how is it possible that the revision visible by adding `-v` is the revision not existing in a branch that is mentioned? so for me it says 15.1:860717, while 860717 is not visible in 15.1- it's a commit from 15.0 (another branch) – Line Sep 05 '22 at 07:51
13

Are you using TortoiseSvn or command line?

Command Line: svn log --stop-on-copy and then look at the smallest rev number.

Tortoise SVN: right-click, tortoise-svn, show log, make sure 'stop on copy' is *checked* and press refresh. Scroll to the bottom and find the smallest rev number. enter image description here

KOGI
  • 3,959
  • 2
  • 24
  • 36
  • actually I was using Subclipse – Andy Jun 08 '11 at 23:30
  • 1
    Not completely correct. When creating a branch you can specify which revision the branch is based on (using -r) - eg. `svn copy -r 1234 svn://foo.com/trunk svn://foo.com/branches/b1`. The base revision is not necessarily the same as the one at which the branch was created. @richq's answer shows how to get it correctly. – harmic Apr 09 '15 at 00:38
2

If you have used svn copy to create a tag/branch, then svn log can tell you from where your stuff in the branch was copied. For example, let's say we have svn://svn/trunk/foo and we have created a branch svn://svn/branches/super_foo. Run svn log -v svn://svn/branches/super_foo, it will tell you something like this - /branches/super_foo from /trunk/foo:22890, which means that you have copied revision 22890 of trunk into your branch.

0

For the Cornerstone app, to see where a tag or branch originated, look in the timeline.

bbarnhart
  • 6,620
  • 1
  • 40
  • 60
0

To see changed paths with current TortoiseSVN command-line tool and to query repo without having local checkout run this (from any directory)

svn log --stop-on-copy --limit 1 --verbose -r0:HEAD "http://server:9876/svn/reponame/branches/branch name"

Notice --verbose to actually show the changed paths and explicit repo/branch URL to avoid having to check it out

Tono Wiedermann
  • 608
  • 6
  • 13