Honestly hg shot themselves in the foot by not releasing any stable API and making developers use their CLI interface. Between that and the performance and dynamic typing issues of Python, it was almost sure to lose the race to Git.

Git doesn't have any sort of API either, libgit2 is unofficial.

Git's filesystem layout has always been stable and Git encouraged developers to target it. Mercurial strongly cautioned developers away from its filesystem or source code APIs and told them to subprocess out to the CLI. To be clear, I dislike Git, but it was _designed_ with developers in mind (which isn't to say that it has a nice API, only that the Git people intended for Git to be extended). I prefer Mercurial's concepts and interface, but Mercurial was somewhere between indifferent and hostile toward developers.

[deleted]