George Kastrinis
George Kastrinis

Reputation: 5172

What is the best approach for a mercurial API

I want to experiment with building something similar to a mercurial client. I searched for an official API and what I find is this page https://www.mercurial-scm.org/wiki/MercurialApi which describes an API but highly discourages people from relying on it. In addition the page above states in some place that

For the vast majority of third party code, the best approach is to use Mercurial's published, documented, and stable API: the command line interface.

So is the best approach just to parse the output from the various mercurial commands? I am not afraid of doing something like this but what troubles me is the fact that the output of those commands mind change even slightly in the future, potentially breaking my code.

Is there some other approach, or you just rely on the CLI and if it changes you simply adapt?

Upvotes: 0

Views: 382

Answers (2)

Reimer Behrends
Reimer Behrends

Reputation: 8720

An intermediate option is to use the command server, which uses the command line API, but avoids some issues that a naive wrapping would cause.

There are various clients for this; hglib is a Python implementation, JavaHg is a Java library. I believe that JavaHg also has advanced functionality to do output parsing and interaction for you.

Upvotes: 1

Ned Deily
Ned Deily

Reputation: 85035

Just rely on the CLI. Further, you may be able to package a particular version of hg with your client so that you have control over which version you are using. However, you should investigate the license implications of that before doing so. Start with https://www.mercurial-scm.org/wiki/License

Upvotes: 1

Related Questions