When reparsing, show both header and body changes
authorMagnus Hagander <magnus@hagander.net>
Fri, 19 Oct 2018 15:50:58 +0000 (17:50 +0200)
committerMagnus Hagander <magnus@hagander.net>
Tue, 20 Nov 2018 14:18:46 +0000 (15:18 +0100)
Previously, only the body changes would show up in the diff, but we'd
actually make updates on the headers as well.

loader/lib/storage.py

index 4eaf33d4b2477fb500d9c8481a93671fe4251aee..b2bc7031369b600033f68c13ccda500e8a0b9ae2 100644 (file)
@@ -246,7 +246,7 @@ class ArchivesParserStorage(ArchivesParser):
                        'msgid': self.msgid,
                        })
                try:
-                       id, _from, _to, cc, subject, date, has_attachment, bodytxt = curs.fetchone()
+                       id, _from, to, cc, subject, date, has_attachment, bodytxt = curs.fetchone()
                except TypeError, e:
                        f.write("---- %s ----\n" % self.msgid)
                        f.write("Could not re-find in archives (old id was %s): %s\n" % (oldid, e))
@@ -254,8 +254,23 @@ class ArchivesParserStorage(ArchivesParser):
                        return
 
 
+               _from = _from.decode('utf8')
+               to = to.decode('utf8')
+               cc = cc.decode('utf8')
+               subject = subject.decode('utf8')
+               if (_from, to, cc, subject) != (self._from, self.to, self.cc, self.subject):
+                       log.status("Message %s has header changes " % self.msgid)
+                       f.write("==== %s ====\n" % self.msgid)
+                       for fn in ['_from', 'to', 'cc', 'subject']:
+                               if getattr(self, fn) != eval(fn):
+                                       d = u"- {0}: {1}\n".format(fn, eval(fn))
+                                       s = u"+ {0}: {1}\n".format(fn, getattr(self, fn))
+                                       f.write(s)
+                                       f.write(d)
+                       f.write("\n\n")
+
                if bodytxt.decode('utf8') != self.bodytxt:
-                       log.status("Message %s has changes " % self.msgid)
+                       log.status("Message %s has body changes " % self.msgid)
                        tempdiff = list(difflib.unified_diff(bodytxt.decode('utf8').splitlines(),
                                                                                                 self.bodytxt.splitlines(),
                                                                                                 fromfile='old',