--- a/mercurial/patch.py Fri Jul 16 16:33:55 2010 +0900
+++ b/mercurial/patch.py Sun Jul 18 01:06:50 2010 +0900
@@ -11,7 +11,7 @@
from i18n import _
from node import hex, nullid, short
-import base85, cmdutil, mdiff, util, diffhelpers, copies
+import base85, cmdutil, mdiff, util, diffhelpers, copies, encoding
gitre = re.compile('diff --git a/(.*) b/(.*)')
@@ -1644,10 +1644,14 @@
maxtotal, maxname = 0, 0
totaladds, totalremoves = 0, 0
hasbinary = False
- for filename, adds, removes, isbinary in stats:
+
+ sized = [(filename, adds, removes, isbinary, encoding.colwidth(filename))
+ for filename, adds, removes, isbinary in stats]
+
+ for filename, adds, removes, isbinary, namewidth in sized:
totaladds += adds
totalremoves += removes
- maxname = max(maxname, len(filename))
+ maxname = max(maxname, namewidth)
maxtotal = max(maxtotal, adds + removes)
if isbinary:
hasbinary = True
@@ -1667,15 +1671,17 @@
# if there were at least some changes.
return max(i * graphwidth // maxtotal, int(bool(i)))
- for filename, adds, removes, isbinary in stats:
+ for filename, adds, removes, isbinary, namewidth in sized:
if git and isbinary:
count = 'Bin'
else:
count = adds + removes
pluses = '+' * scale(adds)
minuses = '-' * scale(removes)
- output.append(' %-*s | %*s %s%s\n' % (maxname, filename, countwidth,
- count, pluses, minuses))
+ output.append(' %s%s | %*s %s%s\n' %
+ (filename, ' ' * (maxname - namewidth),
+ countwidth, count,
+ pluses, minuses))
if stats:
output.append(_(' %d files changed, %d insertions(+), %d deletions(-)\n')