comparison 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
comparison
equal deleted inserted replaced
7878:8c09952cd39a 7879:5c4026a289a4
828 args = args.copy() 828 args = args.copy()
829 args.update(dict(rev=self.repo.manifest.rev(ctx.changeset()[0]), 829 args.update(dict(rev=self.repo.manifest.rev(ctx.changeset()[0]),
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,
836 'date': ctx.date(), 845 'date': ctx.date(),
837 'desc': ctx.description().strip(), 846 'desc': ctx.description().strip(),
844 'node': ctx.hex(), 853 'node': ctx.hex(),
845 'parents': showparents, 854 'parents': showparents,
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)
852 862
853 try: 863 try: