[projects/pld-ftp-admin] ftptree: look up obsoleted packages by name in a dict

arekm arekm at pld-linux.org
Tue Oct 27 23:50:24 CET 2026


commit 26f6138c9b3c1bd33036705d987f4d4561f8afbd
Author: Arkadiusz Miśkiewicz <arekm at maven.pl>
Date:   Tue Oct 27 14:26:10 2026 +0100

    ftptree: look up obsoleted packages by name in a dict
    
    The obsoletes check of a test move scanned every package name of the
    destination tree for each name a moved package obsoletes, splitting each
    one again: 23 million calls and 208 s of a 531 s pfa-testmvpkg run of
    php*, sim* and vte* into PLD.  The names are now indexed once, with the
    same name rule and the same order of the packages reported.

 modules/ftptree.py | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
---
diff --git a/modules/ftptree.py b/modules/ftptree.py
index 2421860..4775cab 100644
--- a/modules/ftptree.py
+++ b/modules/ftptree.py
@@ -529,10 +529,10 @@ class FtpTree(BaseFtpTree):
         if test != True:
             return
 
-        def findbyname(name):
-            def x(nvr):
-                return '-'.join(nvr.split('-')[:-2]) == name
-            return list(filter(x, tree.pkgnames))
+        # one pass over the tree, not one per obsoleted name
+        byname = {}
+        for nvr in tree.pkgnames:
+            byname.setdefault('-'.join(nvr.split('-')[:-2]), []).append(nvr)
 
         for pkg in pkgs:
             obsoletes = pkg.obsoletes()
@@ -541,7 +541,7 @@ class FtpTree(BaseFtpTree):
 
             for pn, setlist in obsoletes.items():
                 for item in setlist:
-                    p = findbyname(item)
+                    p = byname.get(item)
                     if p:
                         pkg.warning(f'obsoletes {p} (via {pn}) in dest tree, perhaps you want rmpkg')
 
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/projects/pld-ftp-admin.git/commitdiff/dcb7070978482eea3347fd0bed77fd94e0d0de4e



More information about the pld-cvs-commit mailing list