Search code examples
pythonapimercurial

get the tip revision informations from mercurial API


How can I get the tip revision informations of a remote mercurial repository from a python script?

I want something like:hg tip. AFAIK hg commands needs a local repository.

I found another approach with mercurial API : List remote branches in Mercurial. But I can't find a documentation on mercurial API to go further this way.

Any help would be very much appreciated.


Solution

  • Here's the "official" way to do it (based on the selected answer to which you linked):

    $ ssh ry4an.org hg -R /srv/hg/unblog id -r tip
    30117899846f tip
    

    If you don't have ssh access to the remote repo then you probably have hgweb access, which makes information about the most tip commit availble at a URL like this: http://ry4an.org/hg/unblog/raw-rev/tip

    You can definitely use the Mercurial internals as seen in @resi's excellent answer, but be sure you're aware it's actively discouraged.