[csw-devel] SF.net SVN: gar:[13341] csw/mgar/gar/v2/lib/python

wahwah at users.sourceforge.net wahwah at users.sourceforge.net
Wed Feb 16 18:39:22 CET 2011


Revision: 13341
          http://gar.svn.sourceforge.net/gar/?rev=13341&view=rev
Author:   wahwah
Date:     2011-02-16 17:39:21 +0000 (Wed, 16 Feb 2011)

Log Message:
-----------
csw-upload-pkg: Implicitly overwrite 5.9 packages

A suggestion from Peter Felecan: When uploading a 5.10 package, implicitly
overwrite existing 5.9 packages in the 5.10 and 5.11 catalogs.

Modified Paths:
--------------
    csw/mgar/gar/v2/lib/python/csw_upload_pkg.py
    csw/mgar/gar/v2/lib/python/csw_upload_pkg_test.py

Modified: csw/mgar/gar/v2/lib/python/csw_upload_pkg.py
===================================================================
--- csw/mgar/gar/v2/lib/python/csw_upload_pkg.py	2011-02-16 16:38:48 UTC (rev 13340)
+++ csw/mgar/gar/v2/lib/python/csw_upload_pkg.py	2011-02-16 17:39:21 UTC (rev 13341)
@@ -154,9 +154,11 @@
       archs = (srv4_arch,)
     catalogname = parsed_basename["catalogname"]
     catalogs = []
+    first_cat_osrel_seen = None
     for arch in archs:
       for osrel in osrels:
         logging.debug("%s %s %s", catrel, arch, osrel)
+        cat_key = (catrel, arch, osrel)
         srv4_in_catalog = self._rest_client.Srv4ByCatalogAndCatalogname(
             catrel, arch, osrel, catalogname)
         if srv4_in_catalog:
@@ -166,23 +168,27 @@
           logging.debug(
               "Catalog %a %s does not contain any version of the % package.",
               arch, osrel, catalogname)
-        if not srv4_in_catalog or srv4_in_catalog["osrel"] == srv4_osrel:
+        if srv4_in_catalog and not first_cat_osrel_seen:
+          first_cat_osrel_seen = srv4_in_catalog["osrel"]
+        if (not srv4_in_catalog
+            or srv4_in_catalog["osrel"] == srv4_osrel
+            or srv4_in_catalog["osrel"] == first_cat_osrel_seen):
           # The same architecture as our package, meaning that we can insert
           # the same architecture into the catalog.
           if (not self.os_release
               or (self.os_release and osrel == self.os_release)):
-            catalogs.append((catrel, arch, osrel))
+            catalogs.append(cat_key)
         else:
-          logging.debug(
-              "Catalog %s %s %s has another version of %s.",
-              catrel, arch, osrel, catalogname)
           if self.os_release and osrel == self.os_release:
             logging.debug("OS release specified and matches %s.", osrel)
-            catalogs.append((catrel, arch, osrel))
+            catalogs.append(cat_key)
           else:
             logging.info(
                 "Not inserting %s package into %s containing a %s package",
                 srv4_osrel, osrel, srv4_in_catalog["osrel"])
+          logging.debug(
+              "Catalog %s %s %s has another version of %s.",
+              catrel, arch, osrel, catalogname)
     return tuple(catalogs)
 
   def _UploadFile(self, filename):

Modified: csw/mgar/gar/v2/lib/python/csw_upload_pkg_test.py
===================================================================
--- csw/mgar/gar/v2/lib/python/csw_upload_pkg_test.py	2011-02-16 16:38:48 UTC (rev 13340)
+++ csw/mgar/gar/v2/lib/python/csw_upload_pkg_test.py	2011-02-16 17:39:21 UTC (rev 13341)
@@ -83,6 +83,28 @@
     )
     self.assertEquals(expected, result)
 
+  def test_MatchSrv4ToCatalogsNewerPackage(self):
+    # A scenario in which a 5.9 package exists in the catalog, and we're
+    # uploading a 5.10 package.
+    rest_client_mock = self.mox.CreateMock(rest.RestClient)
+    self.mox.StubOutWithMock(rest, "RestClient")
+    rest.RestClient().AndReturn(rest_client_mock)
+    rest_client_mock.Srv4ByCatalogAndCatalogname(
+        'unstable', 'sparc', u'SunOS5.10', 'gdb').AndReturn(GDB_STRUCT_9)
+    rest_client_mock.Srv4ByCatalogAndCatalogname(
+        'unstable', 'sparc', u'SunOS5.11', 'gdb').AndReturn(GDB_STRUCT_9)
+    self.mox.ReplayAll()
+    su = csw_upload_pkg.Srv4Uploader(None)
+    result = su._MatchSrv4ToCatalogs(
+        "gdb-7.2,REV=2011.01.21-SunOS5.10-sparc-CSW.pkg.gz",
+        "unstable", "sparc", "SunOS5.10",
+        "deadbeef61b53638d7813407fab4765b")
+    expected = (
+        ("unstable", "sparc", "SunOS5.10"),
+        ("unstable", "sparc", "SunOS5.11"),
+    )
+    self.assertEquals(expected, result)
+
   def test_MatchSrv4ToCatalogsSameSpecificOsrel(self):
     rest_client_mock = self.mox.CreateMock(rest.RestClient)
     self.mox.StubOutWithMock(rest, "RestClient")


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.


More information about the devel mailing list