view contrib/python-hook-examples.py @ 41036:b373477948df

revlog: limit base to rev size ratio to 500 instead of 50 While a value of 50 provided large speedup in some case (400s → 7s) it also creates a slow down for a whole class of revision we are seeing in a private repository (0.1s → 3s). A value of 500 makes them disappear improving the total runtime (the slower revision still improve significantly (400s → 21s)). We need to run a wider array of tests on various repositories to see the effect on speed and size of different values for this acceptable constant. However, in the meantime, it seems safer to move back to a less impactful value.
author Boris Feld <boris.feld@octobus.net>
date Wed, 19 Dec 2018 10:54:25 +0100
parents 1a184b727aff
children 2372284d9457
line wrap: on
line source

'''
Examples of useful python hooks for Mercurial.
'''
from __future__ import absolute_import
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].p1().node()
    if 'url' in kwargs:
        last = repo.changelog.tip()
    else:
        last = node
    diff = patch.diff(repo, first, last)
    ui.write(patch.diffstat(util.iterlines(diff)))