Source

Mercurial Version Info Plugin /

Filename Size Date modified Message
319 B
38 B
1.4 KB
1.4 KB
570 B

Mercurial Version Info Plugin

Overview

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 hook that can be run on commit and update.

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'

Configuration

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:

[hooks]
commit.versioninfo = python:hgversioninfo.hook
update.versioninfo = python:hgversioninfo.hook

[hgversioninfo]
version_file_path = relative/to/your/repo/version.py

[extensions]
hgversioninfo=

Usage

The post-commit and update hooks are run automatically. A file with version info will appear at the path that you specify upon every commit and update.