This patch fixes wrong "added/removed" results where they actually
should be "modified" instead. Only occurs using --compare-arch.
>From 95542f455d707b9203447ab7396b616f1c1d6853 Mon Sep 17 00:00:00 2001
From: Stefan Reimer <[email protected]>
Date: Wed, 14 Mar 2012 15:17:36 -0700
Subject: Fix wrong results using --compare-arch

---
 repodiff.py |   32 +++++++++++++++++++++-----------
 1 files changed, 21 insertions(+), 11 deletions(-)

diff --git a/repodiff.py b/repodiff.py
index e504e0f..9748e93 100755
--- a/repodiff.py
+++ b/repodiff.py
@@ -89,10 +89,7 @@ class DiffYum(yum.YumBase):
             last = None
             npkg = opkg = None
             for pkg in sorted(pkgs):
-                if compare_arch:
-                    key = (pkg.name, pkg.arch)
-                else:
-                    key = pkg.name
+                key = pkg.name
 
                 if last is None:
                     last = key
@@ -109,13 +106,26 @@ class DiffYum(yum.YumBase):
             if opkg is not None or npkg is not None: 
                 yield opkg, npkg
 
-        for opkg, npkg in _next_old_new(self.pkgSack.returnPackages()):
-            if opkg is None:
-                add.append(npkg)
-            elif npkg is None:
-                remove.append(opkg)
-            elif not npkg.verEQ(opkg):
-                modified.append((npkg, opkg))
+        pkgs_by_arch ={}
+        if compare_arch:
+            # We have to split pkgs by arch, otherwise
+            # we yield wrong "removed, added" instead of modified,updated 
+            # e.g. pkgs_by_arch['x86_64'] = ['pkg1', 'pkg2']
+            for p in self.pkgSack.returnPackages():
+                if p.arch not in pkgs_by_arch:
+                   pkgs_by_arch[p.arch] = []
+                pkgs_by_arch[p.arch].append(p)
+        else:
+            pkgs_by_arch['all'] = self.pkgSack.returnPackages()
+
+        for arch,pkgs in pkgs_by_arch.iteritems():
+            for opkg, npkg in _next_old_new(pkgs):
+                if opkg is None:
+                    add.append(npkg)
+                elif npkg is None:
+                    remove.append(opkg)
+                elif not npkg.verEQ(opkg):
+                    modified.append((npkg, opkg))
 
         ao = {}
         for pkg in add:
-- 
1.7.1

_______________________________________________
Yum-devel mailing list
[email protected]
http://lists.baseurl.org/mailman/listinfo/yum-devel

Reply via email to