Mercurial > hg-stable
changeset 7860:162fd31bbd93
diffstat: use width 80 by default and avoid division by zero
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Fri, 20 Mar 2009 14:38:50 -0500 |
parents | 6af7c0e5908c |
children | 2bc14da14992 |
files | mercurial/patch.py |
diffstat | 1 files changed, 4 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/patch.py Wed Mar 18 17:49:11 2009 +0100 +++ b/mercurial/patch.py Fri Mar 20 14:38:50 2009 -0500 @@ -1359,10 +1359,9 @@ if filename: yield (filename, adds, removes) -def diffstat(lines): +def diffstat(lines, width=80): output = [] stats = list(diffstatdata(lines)) - width = util.termwidth() - 2 maxtotal, maxname = 0, 0 totaladds, totalremoves = 0, 0 @@ -1377,7 +1376,7 @@ if graphwidth < 10: graphwidth = 10 - factor = int(math.ceil(float(maxtotal) / graphwidth)) + factor = max(int(math.ceil(float(maxtotal) / graphwidth)), 1) for filename, adds, removes in stats: # If diffstat runs out of room it doesn't print anything, which @@ -1389,7 +1388,7 @@ adds+removes, pluses, minuses)) if stats: - output.append(' %d files changed, %d insertions(+), %d deletions(-)\n' % - (len(stats), totaladds, totalremoves)) + output.append(' %d files changed, %d insertions(+), %d deletions(-)\n' + % (len(stats), totaladds, totalremoves)) return ''.join(output)