##// END OF EJS Templates
diffstat: use width 80 by default and avoid division by zero
Matt Mackall -
r7860:162fd31b default
parent child Browse files
Show More
@@ -1359,10 +1359,9 b' def diffstatdata(lines):'
1359 if filename:
1359 if filename:
1360 yield (filename, adds, removes)
1360 yield (filename, adds, removes)
1361
1361
1362 def diffstat(lines):
1362 def diffstat(lines, width=80):
1363 output = []
1363 output = []
1364 stats = list(diffstatdata(lines))
1364 stats = list(diffstatdata(lines))
1365 width = util.termwidth() - 2
1366
1365
1367 maxtotal, maxname = 0, 0
1366 maxtotal, maxname = 0, 0
1368 totaladds, totalremoves = 0, 0
1367 totaladds, totalremoves = 0, 0
@@ -1377,7 +1376,7 b' def diffstat(lines):'
1377 if graphwidth < 10:
1376 if graphwidth < 10:
1378 graphwidth = 10
1377 graphwidth = 10
1379
1378
1380 factor = int(math.ceil(float(maxtotal) / graphwidth))
1379 factor = max(int(math.ceil(float(maxtotal) / graphwidth)), 1)
1381
1380
1382 for filename, adds, removes in stats:
1381 for filename, adds, removes in stats:
1383 # If diffstat runs out of room it doesn't print anything, which
1382 # If diffstat runs out of room it doesn't print anything, which
@@ -1389,7 +1388,7 b' def diffstat(lines):'
1389 adds+removes, pluses, minuses))
1388 adds+removes, pluses, minuses))
1390
1389
1391 if stats:
1390 if stats:
1392 output.append(' %d files changed, %d insertions(+), %d deletions(-)\n' %
1391 output.append(' %d files changed, %d insertions(+), %d deletions(-)\n'
1393 (len(stats), totaladds, totalremoves))
1392 % (len(stats), totaladds, totalremoves))
1394
1393
1395 return ''.join(output)
1394 return ''.join(output)
General Comments 0
You need to be logged in to leave comments. Login now