[PATCH] Prevent type exception on concatination if diffstat returns None

Sean Dague sean at dague.net
Tue Jan 30 08:38:43 CST 2007


# HG changeset patch
# User Sean Dague <sean at dague.net>
# Date 1170171325 18000
# Node ID 7a16078f83386217e23405898ebad805dd6e7d70
# Parent  cc08d2543593a0d17e5bddd7c40b1544acbabe55
Prevent type exception on concatination if diffstat returns None.
This will most often occur if diffstat is not installed in the
target platform, though may also happen in other cases where
diffstat fails to execute.

Signed-off-by: Sean Dague <sean at dague.net>

diff -r cc08d2543593 -r 7a16078f8338 hgext/notify.py
--- a/hgext/notify.py	Tue Jan 23 17:41:53 2007 -0600
+++ b/hgext/notify.py	Tue Jan 30 10:35:25 2007 -0500
@@ -240,7 +240,9 @@ class notifier(object):
         difflines = self.ui.popbuffer().splitlines(1)
         if self.ui.configbool('notify', 'diffstat', True):
             s = patch.diffstat(difflines)
-            self.ui.write('\ndiffstat:\n\n' + s)
+            # s may be nil, don't include the header if it is
+            if s:
+                self.ui.write('\ndiffstat:\n\n%s' % s)
         if maxdiff > 0 and len(difflines) > maxdiff:
             self.ui.write(_('\ndiffs (truncated from %d to %d lines):\n\n') %
                           (len(difflines), maxdiff))


More information about the Mercurial-devel mailing list