Home

Automatic mercurial tagging

Welcome to my tag revision script written in Perl. I have used it to keep track of my beta versions distributed with the Hockey framework.

What can it do for you ?

You can use this script to track your version numbers especially in the beta development phase. It does so by using mercurial's tag feature to tag the revision with the version string and also updating the version in the Info.plist file. This is neccessary because only higher version numbers can be installed over existing ones. //

To make it easier to use it can be used from Xcodes build system. Just choose your special "build beta version" target, build&archive it and you can directly choose to distribute it via the Hockey framework without having to take care of the version numbers.

If you like it, find it useful or have any ideas about improvements or issues, please use the issue tracker or drop me a tweet Thomas Westfeld .

Features

  • Automatically tags revisions with the next highest version nubmer
  • Makes sure that there are no uncommited changes present before tagging to ensure data integrity
  • Checks if this revision already has been tagged, does not tag the same revision twice even if built twice.

Setup

Install the script

  • Add the script file "tagRevision.pl" to your project and add it to your mercurial repository. Note: Consider making a "Scripts" folder to keep your code organized.
  • Edit the script of the new build phase as shown here. Make sure the path to the script is correct. In this case there is a "Scripts" subdirectory in the projects directory. Note: Line 2 and 3 are neccessary to pass the return code of the perl script to the build system.

Picture of the script phase dialoge

Edit the target

  • Add a "Run Script Phase" to your target you want to track the version number of. Add it after the "Link Binary With Library" phase as shown here. Note: It is beneficial to have separate Info.plist files and bundle identifier for development, ad-hoc distribution and app store distribution.

Script phase in target

  • Add at least the two user-defined settings to the target's build settings. Use the "MERCURIAL_EXECUTABLE" variable to specify the full path to the hg binary and set the "VERSION_PREFIX" variable to the fixed part of your version number. Make sure it ends with a trailing "." .

Example:

VERSION_PREFIX settingGenerated version numbers
1.1.0 1.1 1.2 1.2 etc.
1.2.1.2.0 1.2.1 1.2.2 etc

How to setup up the target info correctly

Edit your Xcode preferences

  • Deselect the "Continue after errors" checkbox in the build settings to make sure only builds that build without an error are tagged.

How to use it

Whenever you want to make a new version you chose the active target to be the one which executes the script. If there are uncommited changes, the build will fail and give an error message in the build results. If the tagging was successful there will be a message that the version was tagged.

You can build this target multiple times. As long as there are no changes in the repository it will not be tagged again.

Copyright 2010 Thomas Westfeld (Thomas Westfeld on twitter)

Updated

Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.