From 458120dd40db6b4df55a4e96b650e16798ef06a0 Mon Sep 17 00:00:00 2001 From: cinap_lenrek Date: Tue, 3 May 2011 11:25:13 +0000 Subject: add hg and python --- sys/src/cmd/hg/contrib/python-hook-examples.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 sys/src/cmd/hg/contrib/python-hook-examples.py (limited to 'sys/src/cmd/hg/contrib/python-hook-examples.py') diff --git a/sys/src/cmd/hg/contrib/python-hook-examples.py b/sys/src/cmd/hg/contrib/python-hook-examples.py new file mode 100644 index 000000000..54fb7d348 --- /dev/null +++ b/sys/src/cmd/hg/contrib/python-hook-examples.py @@ -0,0 +1,22 @@ +''' +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))) -- cgit v1.2.3