Josh Stodola
Josh Stodola

Reputation: 82483

Using Subversion TortoiseSVN Merge Algorithm in a .NET Project

I have a whole bunch of pairs of files that have subtle differences. We use subversion for a source control, and I like the Merge/Diff utility that comes with TortoiseSVN for windows. And I can use this utility to manually compare/merge two files together. My question is this: How can I programmatically merge two files together the same way this utility does (and ignore and flag files that have conflicts)?

Upvotes: 3

Views: 705

Answers (4)

Lasse V. Karlsen
Lasse V. Karlsen

Reputation: 391326

Merging two files where there is no conflict, without human intervention, is probably not a good idea, unless you can easily tell what the change actually is, such as having the before-version of both files (like Subversion does.)

For instance, given the following two files, what is the correct course of action? (The # column is the line number, gaps means lines are missing)

--- File #1 ------------------------        --- File #2 ------------------------
1   This is the first line                  1   This is the first line
2   This is the second line                 2   This is the second line
3   This is the third line
4   This is the fourth line                 3   This is the fourth line
                                            4   This is the fifth line
5   This is the sixth line                  5   This is the sixth line

So, what is the correct result here?

Upvotes: 0

Godeke
Godeke

Reputation: 16281

I would suggest using one of the .NET libraries that support an established merge algorithm, such as suggested in this question: Any decent text diff/merge engine for .NET?

No idea about quality, I also stumbled across this: http://razor.occams.info/code/diff/

Upvotes: 2

Chris S
Chris S

Reputation: 65426

A few options I know about:

  • Sharp SVN as used by the ANKH source control provider for Visual Studio. It's slow to grab repositories however
  • DotSVN - '.Net port of Subversion'
  • If veering away from subversion isn't a problem, you could try Google's Diff Match Patch.

I'm not sure if the two subversion projects implement merging, but I imagine it's a server command. The diff won't be and I'd recommend the Google one for that.

I may be way off the mark if you just want to automate tortoise.

Upvotes: 0

Michael Hackner
Michael Hackner

Reputation: 8645

This may help: Automating TortoiseMerge

Upvotes: 2

Related Questions