Mercurial > hg
view contrib/python-hook-examples.py @ 38733:c2586a6e5884
histedit: add history-editing-backup config option
Instead of passing --no-backup option every time you don't
want to store backup, now you can set config option:
[ui]
history-editing-backup = False
This option aims to operate on every history editing command.
Differential Revision: https://phab.mercurial-scm.org/D3901
author | Sushil khanchi <sushilkhanchi97@gmail.com> |
---|---|
date | Tue, 10 Jul 2018 17:01:06 +0530 |
parents | 2b585677220e |
children | 1a184b727aff |
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['tip'].node() else: last = node diff = patch.diff(repo, first, last) ui.write(patch.diffstat(util.iterlines(diff)))