Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mercurial: get information about repositories without cloning them

Few days ago I started experimenting with Mercurial, and everything went great, until I decided to try writting a small program, that gets the list of repositories and lists of changeset IDs for each repository from a remote server, allows the user to pick repository and changeset, clones it and updates to the chosen revision. This led to two questions:

  1. Is there a way to get a list of repositories from server (besides parsing HTML)?
  2. Is there a way to get information, such as tags, branches, etc. about one of the repositories, without actually cloning it first?
like image 211
Tomas Bingelis Avatar asked Feb 15 '12 12:02

Tomas Bingelis


People also ask

How do I fork a repository on mercurial?

Forking is as simple as cloning the repo. When it comes to creating the fork on your server, that depends on the software your server runs - especially if you have no access to the server... a login would greatly help. Otherwise make sure that you have the server run a software like kallithea.

What is Mercurial repository?

What Is Mercurial? Mercurial is a free, distributed version control system. It's also referred to as a revision control system or Mercurial source control. It is used by software development teams to manage and track changes across projects.

What is tip in Mercurial?

The tip is the changeset added to the repository most recently. If you have just made a commit, that commit will be the tip. Alternately, if you have just pulled from another repository, the tip of that repository becomes the new tip. Use hg tip to show the tip of the repository.

How does Mercurial work?

Mercurial groups related changes to multiple files into single atomic changesets, which are revisions of the whole project. These each get a sequential revision number. Because Mercurial allows distributed parallel development, these revision numbers may disagree between users.


1 Answers

No, Mercurial is designed so that you need a local repository for almost all commands. The only built-in command that will give you information about a remote repository is hg id:

$ hg id https://bitbucket.org/aragost/javahg/
3b2711b26dbd

To get hold of more information you can sometimes exploit the raw template for hgweb:

$ wget -q -O - 'https://www.mercurial-scm.org/repo/hg/tags?style=raw' | head 
tip     a3a36bcf122e2ea4edbbe4ac44da59446cf0ee07
4.2.1   c850f0ed54c1d42f9aa079ad528f8127e5775217
4.2     bb96d4a497432722623ae60d9bc734a1e360179e
4.2-rc  616e788321cc4ae9975b7f0c54c849f36d82182b
4.1.3   77eaf9539499a1b8be259ffe7ada787d07857f80
4.1.2   ed5b25874d998ababb181a939dd37a16ea644435
4.1.1   25703b624d27e3917d978af56d6ad59331e0464a
4.1     e1526da1e6d84e03146151c9b6e6950fe9a83d7d
4.1-rc  a1dd2c0c479e0550040542e392e87bc91262517e
4.0.2   e69874dc1f4e142746ff3df91e678a09c6fc208c

That requires that the host is running the hgweb CGI script that comes with Mercurial. For a site like Bitbucket you would need to use their API.

Finally, if you can enable extensions on the remote repository, then it's possible to write an extension that exposes the information you want in a parsable format. I once wrote such an extension as a demo.

like image 91
Martin Geisler Avatar answered Oct 14 '22 05:10

Martin Geisler