Show More
@@ -9,7 +9,7 b'' | |||
|
9 | 9 | from i18n import _ |
|
10 | 10 | from node import hex, nullid, short |
|
11 | 11 | import base85, cmdutil, mdiff, util, diffhelpers, copies |
|
12 |
import cStringIO, email.Parser, os, re |
|
|
12 | import cStringIO, email.Parser, os, re | |
|
13 | 13 | import sys, tempfile, zlib |
|
14 | 14 | |
|
15 | 15 | gitre = re.compile('diff --git a/(.*) b/(.*)') |
@@ -1429,18 +1429,21 b' def diffstat(lines, width=80):' | |||
|
1429 | 1429 | maxtotal = max(maxtotal, adds+removes) |
|
1430 | 1430 | |
|
1431 | 1431 | countwidth = len(str(maxtotal)) |
|
1432 | graphwidth = width - countwidth - maxname | |
|
1432 | graphwidth = width - countwidth - maxname - 6 | |
|
1433 | 1433 | if graphwidth < 10: |
|
1434 | 1434 | graphwidth = 10 |
|
1435 | 1435 | |
|
1436 | factor = max(int(math.ceil(float(maxtotal) / graphwidth)), 1) | |
|
1436 | def scale(i): | |
|
1437 | if maxtotal <= graphwidth: | |
|
1438 | return i | |
|
1439 | # If diffstat runs out of room it doesn't print anything, | |
|
1440 | # which isn't very useful, so always print at least one + or - | |
|
1441 | # if there were at least some changes. | |
|
1442 | return max(i * graphwidth // maxtotal, int(bool(i))) | |
|
1437 | 1443 | |
|
1438 | 1444 | for filename, adds, removes in stats: |
|
1439 | # If diffstat runs out of room it doesn't print anything, which | |
|
1440 | # isn't very useful, so always print at least one + or - if there | |
|
1441 | # were at least some changes | |
|
1442 | pluses = '+' * max(adds // factor, int(bool(adds))) | |
|
1443 | minuses = '-' * max(removes // factor, int(bool(removes))) | |
|
1445 | pluses = '+' * scale(adds) | |
|
1446 | minuses = '-' * scale(removes) | |
|
1444 | 1447 | output.append(' %-*s | %*.d %s%s\n' % (maxname, filename, countwidth, |
|
1445 | 1448 | adds+removes, pluses, minuses)) |
|
1446 | 1449 |
General Comments 0
You need to be logged in to leave comments.
Login now