diff mercurial/cmdutil.py @ 7879:5c4026a289a4

templater: ability to display diffstat for log-like commands
author Alexander Solovyov <piranha at piranha.org.ua>
date Mon, 23 Mar 2009 10:41:42 +0100
parents 8c09952cd39a
children caef5fdf1375
line wrap: on
line diff
--- a/mercurial/cmdutil.py	Mon Mar 23 13:15:57 2009 +0100
+++ b/mercurial/cmdutil.py	Mon Mar 23 10:41:42 2009 +0100
@@ -830,6 +830,15 @@
                              node=hex(ctx.changeset()[0])))
             return self.t('manifest', **args)
 
+        def showdiffstat(**args):
+            diff = patch.diff(self.repo, ctx.parents()[0].node(), ctx.node())
+            files, adds, removes = 0, 0, 0
+            for i in patch.diffstatdata(util.iterlines(diff)):
+                files += 1
+                adds += i[1]
+                removes += i[2]
+            return '%s: +%s/-%s' % (files, adds, removes)
+
         defprops = {
             'author': ctx.user(),
             'branches': showbranches,
@@ -846,6 +855,7 @@
             'rev': ctx.rev(),
             'tags': showtags,
             'extras': showextras,
+            'diffstat': showdiffstat,
             }
         props = props.copy()
         props.update(defprops)