[PATCH 1 of 1] function to output diffstat for commit/changeset hooks
Alexander Solovyov
piranha at piranha.org.ua
Thu Mar 26 09:49:59 CDT 2009
# HG changeset patch
# User Alexander Solovyov <piranha at piranha.org.ua>
# Date 1238078987 -7200
# Node ID aeea7ce9ce7eabdceffa4cd15abcc76d425d18be
# Parent c2ecaf63badee4e973c4d843121139d4d3269f12
function to output diffstat for commit/changeset hooks
diff --git a/mercurial/hook.py b/mercurial/hook.py
--- a/mercurial/hook.py
+++ b/mercurial/hook.py
@@ -7,6 +7,7 @@
from i18n import _
import util, os, sys
+from mercurial import util, patch
def _pythonhook(ui, repo, name, hname, funcname, args, throw):
'''call python hook. hook is callable object, looked up as
@@ -119,3 +120,18 @@ def hook(ui, repo, name, throw=False, **
os.close(oldstdout)
return r
+
+
+# Built-in hooks
+
+def diffstat(ui, repo, **kwargs):
+ 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)))
More information about the Mercurial-devel
mailing list