Mercurial Version Info Plugin /

Filename Size Date modified Message
135 B
38 B
1.6 KB
1.5 KB
502 B

Mercurial Version Info Plugin


This plugin provides a way to easily record repository version information to a .py file that you can use at runtime in your code to display version information to your users. It provides a post-commit hook and a new command via an extension.

The version file that is generated isn't meant to be versioned itself, but is meant to be distributed with your application. You should probably code defensively in case it isn't present for one reason or another though.

The Version Info File

The file that gets generated looks like this:

revision_id = '4519682deeb7cc8ca370410c251e9352ff45b1d8'
revision_number = 39
branch = 'default'
tags = ['tip']
date = 'Wed May 12 15:03:58 2010'


It's probably best to specify the settings below in your repo-local .hg/hgrc file instead of site wide, but do what works best for you.

To use the hook and extension you need to enable them in your .hgrc like so:

commit.versioninfo = python.hgversioninfo.hook

version_file_path = relative/to/your/repo/



The post-commit hook is run automatically. A file with version info will appear at the path that you specify upon every commit.

The command that is installed via the extension is called write-versioninfo. It takes no arguments and writes the version info for the changeset that you are currently updated to in your working copy.