##// 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 node=hex(ctx.changeset()[0])))
830 node=hex(ctx.changeset()[0])))
831 return self.t('manifest', **args)
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 defprops = {
842 defprops = {
834 'author': ctx.user(),
843 'author': ctx.user(),
835 'branches': showbranches,
844 'branches': showbranches,
@@ -846,6 +855,7 b' class changeset_templater(changeset_prin'
846 'rev': ctx.rev(),
855 'rev': ctx.rev(),
847 'tags': showtags,
856 'tags': showtags,
848 'extras': showextras,
857 'extras': showextras,
858 'diffstat': showdiffstat,
849 }
859 }
850 props = props.copy()
860 props = props.copy()
851 props.update(defprops)
861 props.update(defprops)
@@ -286,6 +286,8 b' PYTHONPATH::'
286 was committed. Will be empty if the branch name was default.
286 was committed. Will be empty if the branch name was default.
287 - date: Date information. The date when the changeset was committed.
287 - date: Date information. The date when the changeset was committed.
288 - desc: String. The text of the changeset description.
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 - files: List of strings. All files modified, added, or removed by
291 - files: List of strings. All files modified, added, or removed by
290 this changeset.
292 this changeset.
291 - file_adds: List of strings. Files added by this changeset.
293 - file_adds: List of strings. Files added by this changeset.
@@ -2017,3 +2017,8 b' def termwidth():'
2017 except ImportError:
2017 except ImportError:
2018 pass
2018 pass
2019 return 80
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 echo "# keys work"
94 echo "# keys work"
95 for key in author branches date desc file_adds file_dels file_mods \
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 for mode in '' --verbose --debug; do
97 for mode in '' --verbose --debug; do
98 hg log $mode --template "$key$mode: {$key}\n"
98 hg log $mode --template "$key$mode: {$key}\n"
99 done
99 done
@@ -534,6 +534,33 b' tags--debug:'
534 tags--debug:
534 tags--debug:
535 tags--debug:
535 tags--debug:
536 tags--debug:
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 # filters work
564 # filters work
538
565
539 hostname
566 hostname
General Comments 0
You need to be logged in to leave comments. Login now