2

I want to create a .NET client for mercurial. Nothing fancy, just the basic stuff.

Martin Geisler
  • 72,968
  • 25
  • 171
  • 229
Developer
  • 17,809
  • 26
  • 66
  • 92

3 Answers3

6

I've started writing a wrapper class library in .NET 4.0 for the Mercurial command line client. It's far far too early to use for anything yet, but you might want to keep an eye on it. Hopefully it'll prove useful to more people than just me.

The code is released as open source on bitbucket, here:

http://bitbucket.org/lassevk/mercurial.net

At the moment you can do basic log retrieval. The full syntax support for specying revsets is not in place, but you can do things like:

var repo = new Repository(@"c:\dev\some\project\repo");
var log = repo.Log(verbose: true, set: RevisionSet.FromRevision(10)); // 10:tip

var changesByMeThatModifiesIgnoreFile =
    from changeset in log
    where changeset.AuthorName == "Lasse V. Karlsen"
       && changeset.PathActions.Any(pa =>
           pa.Path == ".hgignore" &&
           pa.Action == PathActionType.Modify)
    select changeset;

I plan on supporting all built-in commands so that you can commit, update, push, pull, check incoming and outgoing, clone, etc.

Lasse V. Karlsen
  • 380,855
  • 102
  • 628
  • 825
4

Like Chad says, use the command line. That is the official API. We go to great lengths to keep it stable in order to make it easy for scripts and programs to parse its output. See the compatibility rules for the details about how we try to ensure backwards compatibility and thus make it easy for programs to use Mercurial.

Because of the stable command line API, people can write wrapper libraries on top of it. For .Net, I would go with Mercurial.Net by Lasse Karlsen.

Martin Geisler
  • 72,968
  • 25
  • 171
  • 229
2

The question isn't identical, but the top answer applies just as well to your situation: Mercurial API for Java?.

Basically I think you'll probably just need to call the command-line functions. The official API seems to be for Python only.

Community
  • 1
  • 1
Chad Birch
  • 73,098
  • 23
  • 151
  • 149