Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mercurial API for .NET

Tags:

.net

mercurial

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

like image 382
Developer Avatar asked Feb 12 '26 03:02

Developer


2 Answers

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.

like image 152
Lasse V. Karlsen Avatar answered Feb 17 '26 11:02

Lasse V. Karlsen


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.

like image 41
Martin Geisler Avatar answered Feb 17 '26 10:02

Martin Geisler



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!