Deltarepo: Use contenthash element instead of repoid
authorTomas Mlcoch <tmlcoch@redhat.com>
Mon, 16 Dec 2013 15:14:19 +0000 (16:14 +0100)
committerTomas Mlcoch <tmlcoch@redhat.com>
Mon, 16 Dec 2013 15:15:19 +0000 (16:15 +0100)
deltarepo/acceptance_tests/test.sh
deltarepo/deltarepo.py
deltarepo/deltarepo/applicator.py
deltarepo/deltarepo/generator.py

index a2180b5..daa0611 100755 (executable)
@@ -66,7 +66,7 @@ function compare_repos {
 
     diff -r $1/repodata $2/repodata \
         -I "<timestamp>[0-9]*</timestamp>" \
-        -I "<repoid .*>.*</repoid>" \
+        -I "<contenthash .*>.*</contenthash>" \
         $OTHERARGUMENTS
     echo
 
index 29f9f39..37af03e 100755 (executable)
@@ -119,7 +119,7 @@ def main(args, logger):
                                           args.path2,
                                           out_path=args.outputdir,
                                           logger=logger,
-                                          repoid_type=args.id_type,
+                                          contenthash_type=args.id_type,
                                           force_database=args.database,
                                           ignore_missing=args.ignore_missing)
         dg.gen()
index 4688a58..6fd23e8 100644 (file)
@@ -33,7 +33,7 @@ class DeltaRepoApplicator(LoggingInterface):
 
         LoggingInterface.__init__(self, logger)
 
-        self.repoid_type = None
+        self.contenthash_type = None
         self.unique_md_filenames = False
         self.force_database = force_database
         self.ignore_missing = ignore_missing
@@ -61,24 +61,24 @@ class DeltaRepoApplicator(LoggingInterface):
         self.new_repomd = cr.Repomd()
 
         # Check if delta repo id correspond with the old repo id
-        if not self.delta_repomd.repoid or \
-                len(self.delta_repomd.repoid.split('-')) != 2:
-            raise DeltaRepoError("Bad DeltaRepoId")
+        if not self.delta_repomd.contenthash or \
+                len(self.delta_repomd.contenthash.split('-')) != 2:
+            raise DeltaRepoError("Bad content hash")
 
-        self.contenthash_type_str = self.delta_repomd.repoid_type
-        res = self.delta_repomd.repoid.split('-')
+        self.contenthash_type_str = self.delta_repomd.contenthash_type
+        res = self.delta_repomd.contenthash.split('-')
         self.old_contenthash, self.new_contenthash = res
         self._debug("Delta %s -> %s" % (self.old_contenthash,
                                         self.new_contenthash))
 
-        if self.old_repomd.repoid_type == self.delta_repomd.repoid_type:
-            if self.old_repomd.repoid and self.old_repomd.repoid != self.old_contenthash:
+        if self.old_repomd.contenthash_type == self.delta_repomd.contenthash_type:
+            if self.old_repomd.contenthash and self.old_repomd.contenthash != self.old_contenthash:
                 raise DeltaRepoError("Not suitable delta for current repo " \
                         "(Expected: {0} Real: {1})".format(
-                            self.old_contenthash, self.old_repomd.repoid))
+                            self.old_contenthash, self.old_repomd.contenthash))
         else:
-            self._debug("Different repoid types repo: {0} vs delta: {1}".format(
-                    self.old_repomd.repoid_type, self.delta_repomd.repoid_type))
+            self._debug("Different contenthash types repo: {0} vs delta: {1}".format(
+                    self.old_repomd.contenthash_type, self.delta_repomd.contenthash_type))
 
         # Use revision and tags
         self.new_repomd.set_revision(self.delta_repomd.revision)
@@ -341,12 +341,12 @@ class DeltaRepoApplicator(LoggingInterface):
                 self._debug(" - {0}".format(rec.type))
                 self.new_repomd.set_record(rec)
 
-        # Check if calculated repoids match
+        # Check if calculated contenthashes match
         self.check_content_hashes(primary_metadata_object)
 
         # Prepare and write out the new repomd.xml
         self._debug("Preparing repomd.xml ...")
-        self.new_repomd.set_repoid(self.new_contenthash, self.contenthash_type_str)
+        self.new_repomd.set_contenthash(self.new_contenthash, self.contenthash_type_str)
         self.new_repomd.sort_records()
         new_repomd_xml = self.new_repomd.xml_dump()
 
index 073c373..f4e0295 100644 (file)
@@ -26,7 +26,7 @@ class DeltaRepoGenerator(LoggingInterface):
                  new_repo_path,
                  out_path=None,
                  logger=None,
-                 repoid_type="sha256",
+                 contenthash_type="sha256",
                  compression_type="xz",
                  force_database=False,
                  ignore_missing=False):
@@ -53,8 +53,8 @@ class DeltaRepoGenerator(LoggingInterface):
         self.delta_repodata_path = os.path.join(self.delta_repo_path, ".repodata/")
         self.delta_repomd_path = os.path.join(self.delta_repodata_path, "repomd.xml")
 
-        # Repoid type
-        self.contenthash_type_str = repoid_type or "sha256"
+        # contenthash type
+        self.contenthash_type_str = contenthash_type or "sha256"
         self.compression_type_str = compression_type or "xz"
         self.compression_type = cr.compression_type(self.compression_type_str)
 
@@ -106,8 +106,8 @@ class DeltaRepoGenerator(LoggingInterface):
         if self.new_records["primary"].location_href.split("primary")[0] != "":
             self.unique_md_filenames = True
 
-        self.old_contenthash = self.old_repomd.repoid
-        self.new_contenthash = self.new_repomd.repoid
+        self.old_contenthash = self.old_repomd.contenthash
+        self.new_contenthash = self.new_repomd.contenthash
 
         self.deltametadata = DeltaMetadata()
 
@@ -329,14 +329,14 @@ class DeltaRepoGenerator(LoggingInterface):
             deltametadata_rec.rename_file()
         self.delta_repomd.set_record(deltametadata_rec)
 
-        # Check if calculated repoids match
+        # Check if calculated contenthashes match
         self.check_content_hashes()
 
         # Prepare and write out the new repomd.xml
         self._debug("Preparing repomd.xml ...")
-        deltarepoid = "{0}-{1}".format(self.globalbundle.calculated_old_contenthash,
+        deltacontenthash = "{0}-{1}".format(self.globalbundle.calculated_old_contenthash,
                                        self.globalbundle.calculated_new_contenthash)
-        self.delta_repomd.set_repoid(deltarepoid, self.contenthash_type_str)
+        self.delta_repomd.set_contenthash(deltacontenthash, self.contenthash_type_str)
         self.delta_repomd.sort_records()
         delta_repomd_xml = self.delta_repomd.xml_dump()