Imagine you\'ve got a big SVN tree with branches all over the place. There is the trunk, there are branches, those branches have branches, etc. So, given two branches in the
It's a bit late for the OP, but I needed the same thing and couldn't find an answer. The following Powershell script works for me.
Basically we fetch a list of revision numbers for each of the paths to be compared (up to an optional revision limit to avoid fetching the entire history), then step through the lists looking for a matching revision number. The lists are naturally sorted in descending revision number order.
param ([string]$path1, [string]$path2, [int]$rev = 0)
if ($path1 -eq "" -or $path2 -eq "") { "Specify two svn paths to compare."; break }
$revs1 = new-object System.Collections.Generic.List``1[System.Int32]
svn log -r HEAD:$rev $path1 | %{ if ($_ -match "^r(\d+)") { $revs1.Add($matches[1]) } }
$revs2 = new-object System.Collections.Generic.List``1[System.Int32]
svn log -r HEAD:$rev $path2 | %{ if ($_ -match "^r(\d+)") { $revs2.Add($matches[1]) } }
$i1 = 0
$i2 = 0
while ($true) {
if ($revs1[$i1] -eq $revs2[$i2]) { $revs1[$i1]; break }
elseif ($revs1[$i1] -gt $revs2[$i2]) { do { $i1 += 1} until ($i1 -eq $revs1.Count -or $revs1[$i1] -le $revs2[$i2]) }
else { do { $i2 += 1} until ($i2 -eq $revs2.Count -or $revs2[$i2] -le $revs1[$i1]) }
if ($i1 -eq $revs1.Count -or $i2 -eq $revs2.Count) { "No common base revision found - try increasing limit."; break }
}
Look at the logs at root of the tree. Branching operations will be indicated as copy operations, so you can reconstruct a full ancestor tree of what was copied from where. Leave that code running overnight and you'll have the complete copy tree the next morning, which you can then use to identify common ancestors of your branches.
Next time, you can resume work from the last revision you processed.
I guess this is what you need
svn log -v --stop-on-copy
would return the below
r43477 | username | 2010-09-21 13:19:58 +0530 (Tue, 21 Sep 2010) | 1 line Changed paths: A /trunk/re/XXX (from /branches/release/post_XXX/re/XXX:43476)
From this you can identify that this branch is a ancestor of the current branch. If you combine this the logic mentioned by Victor Nicollet you will be able to get the results in real time.
While looking for an equivalent in svn for git merge-base, I hit this post. There's still no simple way around this?
Then here's one possible solution: Clone the repo using git-svn, run git-merge-base providing both braches. Voila!