Show More
@@ -1721,22 +1721,9 b' def diffstatdata(lines):' | |||
|
1721 | 1721 | |
|
1722 | 1722 | def diffstat(lines, width=80, git=False): |
|
1723 | 1723 | output = [] |
|
1724 |
stats = |
|
|
1725 | ||
|
1726 | maxtotal, maxname = 0, 0 | |
|
1727 | totaladds, totalremoves = 0, 0 | |
|
1728 | hasbinary = False | |
|
1729 | ||
|
1730 | sized = [(filename, adds, removes, isbinary, encoding.colwidth(filename)) | |
|
1731 | for filename, adds, removes, isbinary in stats] | |
|
1732 | ||
|
1733 | for filename, adds, removes, isbinary, namewidth in sized: | |
|
1734 | totaladds += adds | |
|
1735 | totalremoves += removes | |
|
1736 | maxname = max(maxname, namewidth) | |
|
1737 | maxtotal = max(maxtotal, adds + removes) | |
|
1738 | if isbinary: | |
|
1739 | hasbinary = True | |
|
1724 | stats = diffstatdata(lines) | |
|
1725 | maxname, totaladds, totalremoves, hasbinary = diffstatsum(stats) | |
|
1726 | maxtotal = totaladds + totalremoves | |
|
1740 | 1727 | |
|
1741 | 1728 | countwidth = len(str(maxtotal)) |
|
1742 | 1729 | if hasbinary and countwidth < 3: |
@@ -1753,7 +1740,7 b' def diffstat(lines, width=80, git=False)' | |||
|
1753 | 1740 | # if there were at least some changes. |
|
1754 | 1741 | return max(i * graphwidth // maxtotal, int(bool(i))) |
|
1755 | 1742 | |
|
1756 |
for filename, adds, removes, isbinary |
|
|
1743 | for filename, adds, removes, isbinary in stats: | |
|
1757 | 1744 | if git and isbinary: |
|
1758 | 1745 | count = 'Bin' |
|
1759 | 1746 | else: |
@@ -1761,9 +1748,8 b' def diffstat(lines, width=80, git=False)' | |||
|
1761 | 1748 | pluses = '+' * scale(adds) |
|
1762 | 1749 | minuses = '-' * scale(removes) |
|
1763 | 1750 | output.append(' %s%s | %*s %s%s\n' % |
|
1764 |
(filename, ' ' * (maxname - |
|
|
1765 | countwidth, count, | |
|
1766 | pluses, minuses)) | |
|
1751 | (filename, ' ' * (maxname - encoding.colwidth(filename)), | |
|
1752 | countwidth, count, pluses, minuses)) | |
|
1767 | 1753 | |
|
1768 | 1754 | if stats: |
|
1769 | 1755 | output.append(_(' %d files changed, %d insertions(+), %d deletions(-)\n') |
General Comments 0
You need to be logged in to leave comments.
Login now