sapling/hgext3rd/stat.py
Saurabh Singh f86c1f069f stat: template which outputs diffstat-style summary of changes
Summary:
There is an existing template "diffstat" which gives a minimal and not
very useful output containing the overall number of files that changed, total
number of lines inserted for all associated files, and total number of lines
deleted for all associated files.

On the other hand, the output from the command line option "stat" is much more
descriptive. Therefore, users end up using commands of the form



  hg log -r . -T '{author}{date}' --stat



When they would have preferred something like



    hg log -r . -T '{author}{date}{stat}'



This change adds the template "stat" which will allow for the desired behavior.

Test Plan:
  # Added a new test test-template-stat.t
  # Ran arc unit

Reviewers: #sourcecontrol, quark

Reviewed By: quark

Subscribers: akushner, medson, mjpieters, quark, rmerizalde

Differential Revision: https://phabricator.intern.facebook.com/D5521665

Tasks: 12422741

Signature: t1:5521665:1501287682:2afaea56b3dc863c52e6300c6bc482ae132a6a61
2017-07-31 11:09:50 -07:00

21 lines
534 B
Python

# stat.py
#
# Copyright 2017 Facebook, Inc.
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2 or any later version.
from mercurial import (
patch,
registrar,
util,
)
templatekeyword = registrar.templatekeyword()
@templatekeyword('stat')
def showdiffstat(repo, ctx, templ, **args):
"""String. Return diffstat-style summary of changes."""
width = repo.ui.termwidth()
return patch.diffstat(util.iterlines(ctx.diff(noprefix=False)), width=width)