[yum-commits] 2 commits - docs/repodiff.1 repodiff.py
James Antill
james at osuosl.org
Tue Apr 13 22:19:41 UTC 2010
docs/repodiff.1 | 2 +
repodiff.py | 82 +++++++++++++++++++++++++++++++++++---------------------
2 files changed, 54 insertions(+), 30 deletions(-)
New commits:
commit 99cbe8d6dad9ca8543dedcc5c12bc0f9fdde200e
Author: James Antill <james at and.org>
Date: Tue Apr 13 18:16:03 2010 -0400
Add message about archlist usage, to stop people being confused.
diff --git a/docs/repodiff.1 b/docs/repodiff.1
index e1ffc3b..640b023 100644
--- a/docs/repodiff.1
+++ b/docs/repodiff.1
@@ -16,6 +16,8 @@ Add a repo. as an old repo.
Add a repo. as an new repo.
.IP "\fB\-\-archlist, -a\fP"
Add architectures to change the default from just comparing source packages.
+Note that if you want the same as a native
+"x86_64" architecture machine you need: x86_64,athlon,i686,i586,i486,i386,noarch
.IP "\fB\-\-size, -s\fP"
Ouput additional data about the size of the changes.
.SH "EXAMPLES"
diff --git a/repodiff.py b/repodiff.py
index 475f599..0a1c42f 100755
--- a/repodiff.py
+++ b/repodiff.py
@@ -239,6 +239,10 @@ def main(args):
print msg
+ if (not ygh.add and not ygh.remove and not ygh.modified and
+ not my.pkgSack.searchNevra(arch='src')):
+ print "** No 'src' pkgs in any repo. maybe see docs. on --archlist?"
+
print 'Summary:'
print 'Added Packages: %s' % len(ygh.add)
print 'Removed Packages: %s' % len(ygh.remove)
commit cb745dcbca766c7b1a185b938e8eff9792a1317a
Author: James Antill <james at and.org>
Date: Tue Apr 13 18:05:05 2010 -0400
Fix obsoletes processing in repodiff, also giant speedup. Compared output
both before and after and it was identical:
1. Original with 3.2.27: 8 minutes 27 seconds
2. Original with returnNewestByName() speedup: 1 minute 50 seconds.
3. New repodiff with 3.2.27: 11 seconds.
...tested with Updates/11 vs. Updates/12 on 2010-04-13.
diff --git a/repodiff.py b/repodiff.py
index 5f3d5b1..475f599 100755
--- a/repodiff.py
+++ b/repodiff.py
@@ -20,6 +20,7 @@ import datetime
import os
import locale
from yum.i18n import to_unicode
+import time
from optparse import OptionParser
@@ -59,42 +60,59 @@ class DiffYum(yum.YumBase):
remove = []
modified = []
obsoleted = {} # obsoleted = by
- newsack = yum.packageSack.ListPackageSack()
- for repoid in self.dy_repos['new']:
- newsack.addList(self.pkgSack.returnPackages(repoid=repoid))
-
- oldsack = yum.packageSack.ListPackageSack()
- for repoid in self.dy_repos['old']:
- oldsack.addList(self.pkgSack.returnPackages(repoid=repoid))
-
- for pkg in newsack.returnNewestByName():
- tot = self.pkgSack.searchNevra(name=pkg.name)
- if len(tot) == 1: # it's only in new
- add.append(pkg)
- if len(tot) > 1:
- if oldsack.contains(name=pkg.name):
- newest_old = oldsack.returnNewestByName(name=pkg.name)[0]
- if newest_old.EVR != pkg.EVR:
- modified.append((pkg, newest_old))
+
+ # Originally we did this by setting up old and new repos. ... but as
+ # a faster way, we can just go through all the pkgs once getting the
+ # newest pkg with a repoid prefix of "old", dito. "new", and then
+ # compare those directly.
+ def _next_old_new(pkgs):
+ """ Returns latest pair of (oldpkg, newpkg) for each package
+ name. If that name doesn't exist, then it returns None for
+ that package. """
+ lastname = None
+ npkg = opkg = None
+ for pkg in sorted(pkgs):
+ if lastname is None:
+ lastname = pkg.name
+ if lastname != pkg.name:
+ yield opkg, npkg
+ opkg = npkg = None
+ lastname = pkg.name
+
+ if pkg.repo.id.startswith('old'):
+ opkg = pkg
else:
- add.append(pkg)
+ assert pkg.repo.id.startswith('new')
+ npkg = pkg
+ if opkg is not None or npkg is not None:
+ yield opkg, npkg
- for pkg in oldsack.returnNewestByName():
- if len(newsack.searchNevra(name=pkg.name)) == 0:
- remove.append(pkg)
+ 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))
+ ao = []
+ for pkg in add:
+ if not pkg.obsoletes:
+ continue
+ ao.append(pkg)
+ # Note that this _only_ shows something when you have an additional
+ # package obsoleting a removed package. If the obsoleted package is
+ # still there (somewhat "common") or the obsoleter is an update (dito)
+ # you get get hits here.
for po in remove:
- for newpo in add:
- foundit = 0
- for obs in newpo.obsoletes:
- if po.inPrcoRange('provides', obs):
- foundit = 1
- obsoleted[po] = newpo
- break
- if foundit:
+ # Remember: Obsoletes are for package names only.
+ poprovtup = (po.name, 'EQ', (po.epoch, po.ver, po.release))
+ for newpo in ao:
+ if po.inPrcoRange('obsoletes', poprovtup):
+ obsoleted[po] = newpo
break
-
+
ygh = yum.misc.GenericHolder()
ygh.add = add
ygh.remove = remove
More information about the Yum-commits
mailing list