Alex Rivera | Logout

Monotone-increasing Version Number based on Mercurial Commits

Asked 2010-03-21T06:30:36.763
15

When I was using subversion for the code for an application, I could append a period and the result of svnversion to the version number to create a unique and monotone-increasing version number and also be guaranteed that any check-out of the same revision of the code would generate the same version number.

In Mercurial, because revision numbers are not necessarily consistent across clones, the local revision number is not suitable. The hash is appropriately unique and consistent, but does not create a number that is monotone-increasing. How can I generate a suitable number to append to the version number based on the Mercurial repository commits?

edit: I have an application that has automatic update checking that is dependent on a version number that is a chain of period-separated whole numbers to determine whether or not a version is newer or not. It has become common that in the time between releases, I have some users trying out test builds. Often, these builds solve an issue the tester was having, so the tester stops using the released version and switches to the test build. My original goals in adding the additional component to the version number were to:

  • ensure that when the release came, those using the test build were automatically presented with the update as well
  • be able to easily tell if a tester was using the most recent test build

For example, the 0.5.0 release had version number 0.5.0.410; before 0.5.1 was released, there were test builds with version numbers 0.5.1.411, 0.5.1.420, and 0.5.1.421; then, the 0.5.1 release had version number 0.5.1.423.

Edit
Report

2 Answers

5

This is how Fog Creek does the build versioning using Mercurial + some other suggestions: https://web.archive.org/web/20130501070904/http://kiln.stackexchange.com/questions/2194/best-practice-generating-build-numbers

answered 2011-07-28T07:41:19.943
4

You've pretty much hit the nail on the head. Using any monotonically-increasing local revision number can conflict with the distributed nature. There is no elegant way around this fundamental design decision.

answered 2010-03-21T06:46:11.287

Your Answer