[PATCH 1 of 4] diffstat: when there are 0 adds or removes, print 0 instead of nothing

Brodie Rao dackze at gmail.com
Tue Sep 22 09:30:52 CDT 2009


# HG changeset patch
# User Brodie Rao <me+hg at dackz.net>
# Date 1253629584 14400
# Node ID 604bc3a3ee2c861014d0f9d8760ba5db909b3aaa
# Parent  a15813fae0a8f414228f9da768c235f9d017ebfa
diffstat: when there are 0 adds or removes, print 0 instead of nothing

This is in line with how GNU diffstat behaves when processing a single diff
with no line modifications (like a binary diff).

diff --git a/mercurial/patch.py b/mercurial/patch.py
--- a/mercurial/patch.py
+++ b/mercurial/patch.py
@@ -1414,8 +1414,8 @@ def diffstat(lines, width=80):
     for filename, adds, removes in stats:
         pluses = '+' * scale(adds)
         minuses = '-' * scale(removes)
-        output.append(' %-*s |  %*.d %s%s\n' % (maxname, filename, countwidth,
-                                                adds+removes, pluses, minuses))
+        output.append(' %-*s |  %*s %s%s\n' % (maxname, filename, countwidth,
+                                               adds+removes, pluses, minuses))
 
     if stats:
         output.append(_(' %d files changed, %d insertions(+), %d deletions(-)\n')


More information about the Mercurial-devel mailing list