user470760
user470760

Reputation:

Cloning Mercurial Repositories from C#?

I am writing an application that will allow users to schedule repeating tasks that download/package up files from any number of sources (SVN/Mercurial/etc).

I have managed to implement everything except for Mercurial. As I want my application to handle everything, I would like to avoid having to distribute the entire Mercurial directory with my application, or worse, requiring the user to have it installed.

I have not been able to find any sort of API for it, so I am wondering what the best approach would be. Is there a standalone executable I could include with my project, and use that when my application issues an "hg clone" command?

Upvotes: 7

Views: 1410

Answers (2)

Steve Kaye
Steve Kaye

Reputation: 6262

Have a look at this page - MercurialApi.

The recommended API is actually the command line and it starts with reasons why you shouldn't use the internal API.

However, it does have a lot of info on how to use the internal API if you really want to.

You'd need to find some way to call Python from C#. One that I found when looking into doing something like this was called IronPython.

Also, I'm pretty sure that your program would have to be open source if you were to use Mercurial's internal API but you'd need to look Into that yourself.

Upvotes: 4

Laurens Holst
Laurens Holst

Reputation: 21066

The best way to interface with Mercurial is through the command server.

Basically the command server is similar to the command line, but avoids the Mercurial instantiation overhead. There is a Java (JavaHg) and a Python implementation (PythonHgLib), a C# version of it does not exist yet I think but it shouldn’t be too complex to implement, the communication protocol is designed to be simple.

Otherwise, invoking the command line is the recommended approach.

Upvotes: 2

Related Questions