view contrib/python-hook-examples.py @ 12153:d598d24a7e67 stable

test-convert-cvs: add a sleep to make test more stable The recent addition of fuzzy tests introduced a new cvs commit which sometimes fails. This adds a sleep to make sure that cvs notices that the file has changed, similar to how it is done in other tests.
author Mads Kiilerich <mads@kiilerich.com>
date Thu, 02 Sep 2010 22:38:12 +0200
parents 62f11ef0df5b
children a8d13ee0ce68
line wrap: on
line source

'''
Examples of useful python hooks for Mercurial.
'''
from mercurial import patch, util

def diffstat(ui, repo, **kwargs):
    '''Example usage:

    [hooks]
    commit.diffstat = python:/path/to/this/file.py:diffstat
    changegroup.diffstat = python:/path/to/this/file.py:diffstat
    '''
    if kwargs.get('parent2'):
        return
    node = kwargs['node']
    first = repo[node].parents()[0].node()
    if 'url' in kwargs:
        last = repo['tip'].node()
    else:
        last = node
    diff = patch.diff(repo, first, last)
    ui.write(patch.diffstat(util.iterlines(diff)))