Mercurial > hg
view contrib/python-hook-examples.py @ 48997:20c6c9e43397
tests: stop excluding the pycompat module from pyflakes
I assume this was skipped because of all of the py2 stuff causing a lot of spew.
The "unused" imports are left in place in case any 3rd party stuff is using it.
I don't care about most of it, but TortoiseHg uses `io` and `queue`, so
minimally I'd like to keep those.
Differential Revision: https://phab.mercurial-scm.org/D12423
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Wed, 30 Mar 2022 00:57:08 -0400 |
parents | 6000f5b25c9b |
children |
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].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)))