Reputation: 5922
Background: I'm writing a Java server application that needs to perform basic interactions with remote SCM systems served over http.
Is it possible to interact with Mercurial and Git repositories using some sort of predefined API (or if there is a convention to how these repositories are laid out when served via http) from the server without having to clone? The only sort of interactions needed are listing of files currently under version control and the ability to download particular revisions of a version controlled file.
EDIT: For Mercurial, I used Ry4an's solution. For Git, I scrape the screens of repositories served using gitweb.
Upvotes: 2
Views: 442
Reputation: 78340
Mercurial isn't designed to work on remote repositories except to clone, push, and pull. That said, there's a lot one can do depending how it's served. If it's being served through hgweb, the built in web interface available as hg serve
there are style=raw
views of many details which can be easily handled programmatically. Some examples:
With those you can browse files, revision, tags, and branches.
If, however, you want to write you're best off running Mercurial in Jython in your Java app and invoking the commands directly.
Upvotes: 4
Reputation: 56058
Mercurial has two web APIs. One you probably shouldn't use. It's designed for other instances of Mercurial to use to send and receive changesets.
The other is easily accessible via an ordinary web browser. The URLs you see are designed to be clear and easy to parse or put together programatically. As @Ry4an points out, the file browser also has the ability to give you a raw (aka verbatim, with no HTML tags) copy of any version of any file.
Though, you raise an interesting point. I think Mercurial could use an XML template in which it sends you the same information as the pages in a Mercurial specific XML format that's designed to be used by programs.
Upvotes: 2