Use the built-in keyword extension.
A couple of important things:
- ONLY add the specific files you need keyword expansion to the filename pattern in hgrc
[keyword]
.
- The expansion is LOCAL. When your changeset is pushed to another repo, unless that repo also has the same keyword setup, keyword is NOT expanded.
I agree that it should be avoided whenever possible. When it is not possible to avoid is that you need to distribute a few selected files (for example, API headers) to other people (for example, API users), such that there's no way they can use hg to find out the version info.