--- 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)