Blame SOURCES/BZ-1194915-add-logging-for-bad-notice-dupes.patch

d2a170
diff -up yum-3.4.3/yum/update_md.py.org yum-3.4.3/yum/update_md.py
d2a170
--- yum-3.4.3/yum/update_md.py.org	2017-01-24 18:55:03.529842775 +0100
d2a170
+++ yum-3.4.3/yum/update_md.py	2017-01-24 18:55:57.213511475 +0100
d2a170
@@ -58,7 +58,7 @@ class UpdateNotice(object):
d2a170
     A single update notice (for instance, a security fix).
d2a170
     """
d2a170
 
d2a170
-    def __init__(self, elem=None):
d2a170
+    def __init__(self, elem=None, repoid=None, vlogger=None):
d2a170
         self._md = {
d2a170
             'from'             : '',
d2a170
             'type'             : '',
d2a170
@@ -83,6 +83,9 @@ class UpdateNotice(object):
d2a170
         if elem:
d2a170
             self._parse(elem)
d2a170
 
d2a170
+        self._repoid = repoid
d2a170
+        self._vlogger = vlogger
d2a170
+
d2a170
     def __getitem__(self, item):
d2a170
         """ Allows scriptable metadata access (ie: un['update_id']). """
d2a170
         if type(item) is int:
d2a170
@@ -103,6 +106,24 @@ class UpdateNotice(object):
d2a170
         #  Tests to see if it's "the same data", which means that the
d2a170
         # packages can be different (see add_notice).
d2a170
 
d2a170
+        def _rid(un):
d2a170
+            if hasattr(un, '_repoid') and un._repoid is not None:
d2a170
+                return un._repoid
d2a170
+            else:
d2a170
+                return '<unknown>'
d2a170
+
d2a170
+        def _log_failure(data):
d2a170
+            """Log the mismatched data similarly to conflict markers in git."""
d2a170
+            if self._vlogger is None:
d2a170
+                return
d2a170
+            msg = _('Duplicate of %s differs in some fields:\n')
d2a170
+            msg %= other._md['update_id']
d2a170
+            msg += '<<<<<<< %s:%s\n' % (_rid(other), data)
d2a170
+            msg += '%r\n=======\n%r\n' % (other._md[data], self._md[data])
d2a170
+            msg += '>>>>>>> %s:%s' % (_rid(self), data)
d2a170
+            # --verbose mode enables this
d2a170
+            self._vlogger.log(logginglevels.DEBUG_3, msg)
d2a170
+
d2a170
         if not other or not hasattr(other, '_md'):
d2a170
             return False
d2a170
 
d2a170
@@ -113,6 +134,7 @@ class UpdateNotice(object):
d2a170
             if data == 'status': # FIXME: See below...
d2a170
                 continue
d2a170
             if self._md[data] != other._md[data]:
d2a170
+                _log_failure(data)
d2a170
                 return False
d2a170
         # FIXME: Massive hack, Fedora is really broken and gives status=stable
d2a170
         # and status=testing for updateinfo notices, just depending on which
d2a170
@@ -120,8 +142,10 @@ class UpdateNotice(object):
d2a170
         data = 'status'
d2a170
         if self._md[data] != other._md[data]:
d2a170
             if self._md[data]  not in ('stable', 'testing'):
d2a170
+                _log_failure(data)
d2a170
                 return False
d2a170
             if other._md[data] not in ('stable', 'testing'):
d2a170
+                _log_failure(data)
d2a170
                 return False
d2a170
             # They are both really "stable" ...
d2a170
             self._md[data]  = 'stable'
d2a170
@@ -574,7 +598,7 @@ class UpdateMetadata(object):
d2a170
         for event, elem in safe_iterparse(infile, logger=self._logger):
d2a170
             if elem.tag == 'update':
d2a170
                 try:
d2a170
-                    un = UpdateNotice(elem)
d2a170
+                    un = UpdateNotice(elem, repoid, self._vlogger)
d2a170
                 except UpdateNoticeException, e:
d2a170
                     msg = _("An update notice%s is broken, skipping.") % _rid(repoid)
d2a170
                     if self._vlogger:
d2a170
@@ -587,6 +611,8 @@ class UpdateMetadata(object):
d2a170
                     msg = _("Update notice %s%s is broken, or a bad duplicate, skipping.") % (un['update_id'], _rid(repoid))
d2a170
                     if not have_dup:
d2a170
                         msg += _('\nYou should report this problem to the owner of the %srepository.') % _rid(repoid, "%s ")
d2a170
+                        msg += _('\nIf you are the owner, consider re-running the same command with --verbose to see the '
d2a170
+                                 'exact data that caused the conflict.')
d2a170
                     have_dup = True
d2a170
                     if self._vlogger:
d2a170
                         self._vlogger.warn("%s", msg)