views:

376

answers:

4

The project I'm working on requires access to the users source control. To do this we are wrapping the Perforce API and the Subversion API ( using P4.NET and SubversionSharp respectively ).

We would like to support as many as we can depending on user requirements and I've tried googling for an existing library but no luck. Does a C# library that wraps multiple SCM applications exist?

+2  A: 

You propably search for Microsoft Source Code Control Provider ( MSSCCI ). I know, the Source Safe, Team Foundation Server, Subversion, Evolution, ( and some next others ) source control products has this interface implemented.

TcKs
+1  A: 

MSSCCI would help many source control products to be directly accessible from Visual Studio, but not necessarily usable from .NET code. To my knowledge, there is no .NET library that abstracts access to all the source control products, not even to more than one.

It would be interesting if you could wrap a MSSCCI provider (probably you have to implement some C++ headers) as a .NET assembly.

Sergiu Damian
In VS 2005 SDK is sample how to implement MSSCCI provider in C#. This SDK is free to download.
TcKs
This is not a MSSCCI provider example, but a new style SCC package implementation. (Such packages don't run outside VSS, but allow a much better integration in VS itself than the old MSSCCI api: No checkout-checkin requirements any more)
Bert Huijben
+1  A: 

Can you invoke MSSCCI through DllImport/interop?

Edit as a matter of fact, yes ...

[DllImport(@"C:\Program Files\Microsoft Visual Studio\Common\VSS\win32\SSSCC.DLL")]
andrewbadera
A: 

I would recommend not to use MSSCCI as abstraction layer, as that old style SCC api is fully modeled after the checkout-checkin principal promoted by VSS.

Most newer Source Control systems use the Update/Merge principle and/or allow a combination of Update/Merge and locking to mimick the old behavior.

If you want to use Subversion from .Net you should also look at the new SharpSvn library, as provides you all Subversion power in a .Net style api. (You don't have to think about memory management, apr arrays, function pointers, etc. if you don't like to).

In most cases it allows you to use Subversion with about 1/5th of the code the older bindings need.

using(SvnClient client = new SvnClient())
{
   client.Update(@"C:\My\WorkingCopy");

   // Do something to your working copy
   File.AppendAllText(@"C:\My\WorkingCopy", "\nFile Change\n");

   SvnCommitArgs ca = new SvnCommitArgs();
   ca.LogMessage = "Line added";

   client.Commit(@"C:\My\WorkingCopy", ca);
}
Bert Huijben