##// END OF EJS Templates
templater: ability to display diffstat for log-like commands
Alexander Solovyov <piranha at piranha.org.ua> -
r7879:5c4026a2 default
parent child Browse files
Show More
@@ -830,6 +830,15 b' class changeset_templater(changeset_prin'
830 830 node=hex(ctx.changeset()[0])))
831 831 return self.t('manifest', **args)
832 832
833 def showdiffstat(**args):
834 diff = patch.diff(self.repo, ctx.parents()[0].node(), ctx.node())
835 files, adds, removes = 0, 0, 0
836 for i in patch.diffstatdata(util.iterlines(diff)):
837 files += 1
838 adds += i[1]
839 removes += i[2]
840 return '%s: +%s/-%s' % (files, adds, removes)
841
833 842 defprops = {
834 843 'author': ctx.user(),
835 844 'branches': showbranches,
@@ -846,6 +855,7 b' class changeset_templater(changeset_prin'
846 855 'rev': ctx.rev(),
847 856 'tags': showtags,
848 857 'extras': showextras,
858 'diffstat': showdiffstat,
849 859 }
850 860 props = props.copy()
851 861 props.update(defprops)
@@ -286,6 +286,8 b' PYTHONPATH::'
286 286 was committed. Will be empty if the branch name was default.
287 287 - date: Date information. The date when the changeset was committed.
288 288 - desc: String. The text of the changeset description.
289 - diffstat: String. Statistics of changes with the following format:
290 "modified files: +added/-removed lines"
289 291 - files: List of strings. All files modified, added, or removed by
290 292 this changeset.
291 293 - file_adds: List of strings. Files added by this changeset.
@@ -2017,3 +2017,8 b' def termwidth():'
2017 2017 except ImportError:
2018 2018 pass
2019 2019 return 80
2020
2021 def iterlines(iterator):
2022 for chunk in iterator:
2023 for line in chunk.splitlines():
2024 yield line
@@ -93,7 +93,7 b' cat changelog'
93 93
94 94 echo "# keys work"
95 95 for key in author branches date desc file_adds file_dels file_mods \
96 files manifest node parents rev tags; do
96 files manifest node parents rev tags diffstat; do
97 97 for mode in '' --verbose --debug; do
98 98 hg log $mode --template "$key$mode: {$key}\n"
99 99 done
@@ -534,6 +534,33 b' tags--debug:'
534 534 tags--debug:
535 535 tags--debug:
536 536 tags--debug:
537 diffstat: 1: +1/-0
538 diffstat: 1: +1/-0
539 diffstat: 0: +0/-0
540 diffstat: 1: +1/-0
541 diffstat: 0: +0/-0
542 diffstat: 1: +1/-0
543 diffstat: 1: +4/-0
544 diffstat: 1: +2/-0
545 diffstat: 1: +1/-0
546 diffstat--verbose: 1: +1/-0
547 diffstat--verbose: 1: +1/-0
548 diffstat--verbose: 0: +0/-0
549 diffstat--verbose: 1: +1/-0
550 diffstat--verbose: 0: +0/-0
551 diffstat--verbose: 1: +1/-0
552 diffstat--verbose: 1: +4/-0
553 diffstat--verbose: 1: +2/-0
554 diffstat--verbose: 1: +1/-0
555 diffstat--debug: 1: +1/-0
556 diffstat--debug: 1: +1/-0
557 diffstat--debug: 0: +0/-0
558 diffstat--debug: 1: +1/-0
559 diffstat--debug: 0: +0/-0
560 diffstat--debug: 1: +1/-0
561 diffstat--debug: 1: +4/-0
562 diffstat--debug: 1: +2/-0
563 diffstat--debug: 1: +1/-0
537 564 # filters work
538 565
539 566 hostname
General Comments 0
You need to be logged in to leave comments. Login now