[StGit PATCH 5/7] Add diffstat of whole patch series to cover mail

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Note: The diffstat is computed from the bottom of the first patch to
the top of the last, which gives a correct result if and only if the
series is contiguous. This is often the case, and handling anything
but this case is nontrivial, as it would involve creating a temporary
series of commits that are contiguous, with all the performance and
merge problems that would entail.

Signed-off-by: Karl Hasselström <kha@xxxxxxxxxxx>

---

 stgit/commands/mail.py   |   17 ++++++++++-------
 templates/covermail.tmpl |    1 +
 2 files changed, 11 insertions(+), 7 deletions(-)


diff --git a/stgit/commands/mail.py b/stgit/commands/mail.py
index 6202fc5..c223665 100644
--- a/stgit/commands/mail.py
+++ b/stgit/commands/mail.py
@@ -78,8 +78,8 @@ The patch e-mail template accepts the following variables:
   %(commname)s     - committer's name
   %(commemail)s    - committer's e-mail
 
-For the preamble e-mail template, only the %(sender)s, %(version)s,
-%(patchnr)s, %(totalnr)s and %(number)s variables are supported."""
+For the preamble e-mail template, only the %(diffstat)s, %(sender)s,
+%(version)s, %(patchnr)s, %(totalnr)s and %(number)s variables are supported."""
 
 options = [make_option('-a', '--all',
                        help = 'e-mail all the applied patches',
@@ -301,7 +301,7 @@ def __edit_message(msg):
 
     return msg
 
-def __build_cover(tmpl, total_nr, msg_id, options):
+def __build_cover(tmpl, patches, msg_id, options):
     """Build the cover message (series description) to be sent via SMTP
     """
     sender = __get_sender()
@@ -320,9 +320,9 @@ def __build_cover(tmpl, total_nr, msg_id, options):
         else:
             prefix_str = ''
         
-    total_nr_str = str(total_nr)
+    total_nr_str = str(len(patches))
     patch_nr_str = '0'.zfill(len(total_nr_str))
-    if total_nr > 1:
+    if len(patches) > 1:
         number_str = ' %s/%s' % (patch_nr_str, total_nr_str)
     else:
         number_str = ''
@@ -338,7 +338,10 @@ def __build_cover(tmpl, total_nr, msg_id, options):
                  'prefix':	 prefix_str,
                  'patchnr':      patch_nr_str,
                  'totalnr':      total_nr_str,
-                 'number':       number_str}
+                 'number':       number_str,
+                 'diffstat':     git.diffstat(
+                                     rev1 = git_id('%s//bottom' % patches[0]),
+                                     rev2 = git_id('%s//top' % patches[-1]))}
 
     try:
         msg_string = tmpl % tmpl_dict
@@ -529,7 +532,7 @@ def func(parser, options, args):
                 raise CmdException, 'No cover message template file found'
 
         msg_id = email.Utils.make_msgid('stgit')
-        msg = __build_cover(tmpl, total_nr, msg_id, options)
+        msg = __build_cover(tmpl, patches, msg_id, options)
         from_addr, to_addr_list = __parse_addresses(msg)
 
         msg_string = msg.as_string(options.mbox)
diff --git a/templates/covermail.tmpl b/templates/covermail.tmpl
index c8e012a..adc0b92 100644
--- a/templates/covermail.tmpl
+++ b/templates/covermail.tmpl
@@ -3,5 +3,6 @@ Subject: [%(prefix)sPATCH%(version)s%(number)s] Series short description
 
 The following series implements...
 
+%(diffstat)s
 -- 
 Signature

-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux