mercurialidentifierrevisions

Mercurial : user friendly way to display exact revision number of files?


When I was using Subversion as part of the build process I'd run an 'svn info' and capture the unique ID number and echo it to a header file for inclusion by other programs. This made it easy for users to say for example, 'I'm running build 456' and given the number 456 I could always cross reference exactly what they were running.

I'm trying to figure out how to achieve the same thing with Mercurial. 'hg summary' displays an integer id as well as the hex hash code. From what I was reading the integer id could be different for different people. I'm supposing the hash code is unique, but it's not very user friendly.

Is the hg hash code the only unique way of identifying a particular version of files in Mercurial?

Thank you, Fred


Solution

  • Yes it is the only way to uniquely identify a changeset.

    More details in the documentation : ChangeSet and ChangeSetID

    If you want to use an integer number, I see two possible solution depending on your build process.

    1. If the build always happens on the same machine (ie: same repository), you can use the integer id because it never changes on a particular repo (except if you do history rewriting)
    2. If the build of a particular version only happens once, you can use a variable that you increment each time in your build script.