[PATCH 1 of 1] changeset templater: ability to display diffstat
Alexander Solovyov
piranha at piranha.org.ua
Fri Jan 23 05:57:46 CST 2009
# HG changeset patch
# User Alexander Solovyov <piranha at piranha.org.ua>
# Date 1231871526 -7200
# Node ID ef76e0f10e2612f3e6106c34315d56f9f6b412ea
# Parent 9c8bbae02e9c4b51cc9cc0494677a1f4554cec45
changeset templater: ability to display diffstat
diff -r 9c8bbae02e9c -r ef76e0f10e26 mercurial/cmdutil.py
--- a/mercurial/cmdutil.py Thu Jan 22 16:07:44 2009 +0100
+++ b/mercurial/cmdutil.py Tue Jan 13 20:32:06 2009 +0200
@@ -822,6 +822,16 @@
node=hex(changes[0])))
return self.t('manifest', **args)
+ def showdiffstat(**args):
+ diff = ''.join(patch.diff(self.repo, log.parents(changenode)[0],
+ changenode))
+ files, adds, removes = 0, 0, 0
+ for i in patch.diffstatdata(diff.splitlines()):
+ files += 1
+ adds += i[1]
+ removes += i[2]
+ return '%s: +%s/-%s' % (files, adds, removes)
+
defprops = {
'author': changes[1],
'branches': showbranches,
@@ -838,6 +848,7 @@
'rev': rev,
'tags': showtags,
'extras': showextras,
+ 'diffstat': showdiffstat,
}
props = props.copy()
props.update(defprops)
diff -r 9c8bbae02e9c -r ef76e0f10e26 mercurial/help.py
--- a/mercurial/help.py Thu Jan 22 16:07:44 2009 +0100
+++ b/mercurial/help.py Tue Jan 13 20:32:06 2009 +0200
@@ -276,6 +276,8 @@
was committed. Will be empty if the branch name was default.
- date: Date information. The date when the changeset was committed.
- desc: String. The text of the changeset description.
+ - diffstat: String. Statistics of changes in format:
+ "modified files: +added/-removed lines"
- files: List of strings. All files modified, added, or removed by
this changeset.
- file_adds: List of strings. Files added by this changeset.
diff -r 9c8bbae02e9c -r ef76e0f10e26 tests/test-command-template
--- a/tests/test-command-template Thu Jan 22 16:07:44 2009 +0100
+++ b/tests/test-command-template Tue Jan 13 20:32:06 2009 +0200
@@ -93,7 +93,7 @@
echo "# keys work"
for key in author branches date desc file_adds file_dels file_mods \
- files manifest node parents rev tags; do
+ files manifest node parents rev tags diffstat; do
for mode in '' --verbose --debug; do
hg log $mode --template "$key$mode: {$key}\n"
done
diff -r 9c8bbae02e9c -r ef76e0f10e26 tests/test-command-template.out
--- a/tests/test-command-template.out Thu Jan 22 16:07:44 2009 +0100
+++ b/tests/test-command-template.out Tue Jan 13 20:32:06 2009 +0200
@@ -534,6 +534,33 @@
tags--debug:
tags--debug:
tags--debug:
+diffstat: 1: +1/-0
+diffstat: 1: +1/-0
+diffstat: 0: +0/-0
+diffstat: 1: +1/-0
+diffstat: 0: +0/-0
+diffstat: 1: +1/-0
+diffstat: 1: +4/-0
+diffstat: 1: +2/-0
+diffstat: 1: +1/-0
+diffstat--verbose: 1: +1/-0
+diffstat--verbose: 1: +1/-0
+diffstat--verbose: 0: +0/-0
+diffstat--verbose: 1: +1/-0
+diffstat--verbose: 0: +0/-0
+diffstat--verbose: 1: +1/-0
+diffstat--verbose: 1: +4/-0
+diffstat--verbose: 1: +2/-0
+diffstat--verbose: 1: +1/-0
+diffstat--debug: 1: +1/-0
+diffstat--debug: 1: +1/-0
+diffstat--debug: 0: +0/-0
+diffstat--debug: 1: +1/-0
+diffstat--debug: 0: +0/-0
+diffstat--debug: 1: +1/-0
+diffstat--debug: 1: +4/-0
+diffstat--debug: 1: +2/-0
+diffstat--debug: 1: +1/-0
# filters work
hostname
More information about the Mercurial-devel
mailing list