tags:

views:

30

answers:

2

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 tree, how can you find the common ancestor?

I know that you could simply take the full log and compare it, but it get's kinda slow if your trunk has 75,000 revisions (and most of the time you do compare trunk with another, possibly faraway, branch).

The process will be automated, so you can suggest things which are not done easily by hand.

Added: Forgot to say, I need to get it done in real time. Not in "real time" as in 10ms, but in "real time" as in "before the person waiting for the output gets annoyed". So it'd be nice if it was under 10s.

+1  A: 

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.

Victor Nicollet
Sorry, I need it to be done in as few seconds as possible. :( People will be running it from the command line and waiting for the response.
Vilx-
Once you have pre-computed the ancestor tree, all the requests for the entire repository should take a few nanoseconds to run. The pre-computation would probably take less time than the actual writing of the program, and it only has to run once. Is there an unmentioned reason why you cannot pre-compute the tree and store it?
Victor Nicollet
Store it where? Everyone will be running it from their local machines. I suppose I could place it on some common network drive, but I was really hoping for a standalone solution that didn't require any extra resources beyond SVN itself.
Vilx-
Since your application would be accessing SVN anyway, why not store the ancestor tree file in the repository itself?
Victor Nicollet
OK, I'll keep this solution in mind, though I'd still vastly prefer something that would do the calculations on the fly.
Vilx-
+2  A: 

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.

Version Control Buddy
I guess this is the best you can get... :P
Vilx-