##// END OF EJS Templates
persistent-nodemap: Fix Rust declarations for Revlog_CAPI signatures...
persistent-nodemap: Fix Rust declarations for Revlog_CAPI signatures Use Rust’s `libc::ssize_t` as the closest match to C’s `Py_ssize_t`. See details in test comment. Going forward we should find a way to have such Rust declarations auto-generated from C headers at build time, or auto-checked against them in a test. Differential Revision: https://phab.mercurial-scm.org/D9901

File last commit:

r46554:89a2afe3 default
r47141:7d0405e4 stable
Show More
python-hook-examples.py
27 lines | 633 B | text/x-python | PythonLexer
/ contrib / python-hook-examples.py
'''
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)))