Search code examples
mercurial

How can I get the Mercurial Changeset ID from a revision number?


If I use hg grep I get a filename and a revision number. How can I transform these bits of information to a changeset identifier that I can use in other commands?


Solution

  • You can use hg id or hg log:

    $ hg id -r 100
    526722d24ee5
    $ hg log -r 100
    changeset:   100:526722d24ee5
    user:        jake@edge2.net
    date:        Fri May 13 17:48:10 2005 -0700
    summary:     reorganize code into classes
    

    But please note that you don't have to convert the revision number. All Mercurial commands that take a changeset ID also take a revision number. They're interchangeable, as explained in hg help revisions. This means that you can use a tag, a branch name, a bookmark, a revision number, or a changeset ID everywhere.

    It is only if you need to communicate with other people that you really need the changeset IDs. The revision numbers are local and so my revision 100 can be different from your revision 100. So use the changeset ID in emails, bugtrackers, etc.