From 7ff6f25edeccd29da6c761bd2c4a176b30fd3a7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fatih=20A=C5=9F=C4=B1c=C4=B1?= Date: Sun, 3 Apr 2011 14:21:24 +0000 Subject: [PATCH] delta: Change the way in previous commit No need to use an exception. Comparing the size of changed files and the new files is enough. --- pisi/operations/delta.py | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/pisi/operations/delta.py b/pisi/operations/delta.py index 45128b0f..c6fa5acf 100644 --- a/pisi/operations/delta.py +++ b/pisi/operations/delta.py @@ -21,10 +21,6 @@ import pisi.util as util import pisi.archive as archive -class AllFilesChangedException(Exception): - pass - - # FIXME Reduce code duplication def create_delta_packages_from_obj(old_packages, new_package_obj, specdir): new_pkg_info = new_package_obj.metadata.package @@ -58,9 +54,9 @@ def create_delta_packages_from_obj(old_packages, new_package_obj, specdir): old_pkg_files = old_pkg.get_files() - try: - files_delta = find_delta(old_pkg_files, new_pkg_files) - except AllFilesChangedException: + files_delta = find_delta(old_pkg_files, new_pkg_files) + + if len(files_delta) == len(new_pkg_files.list): ctx.ui.warning(_("All files in the package '%s' are different " "from the files in the new package. Skipping " "it...") % old_package) @@ -162,9 +158,9 @@ def create_delta_packages(old_packages, new_package): old_pkg_files = old_pkg.get_files() - try: - files_delta = find_delta(old_pkg_files, new_pkg_files) - except AllFilesChangedException: + files_delta = find_delta(old_pkg_files, new_pkg_files) + + if len(files_delta) == len(new_pkg_files.list): ctx.ui.warning(_("All files in the package '%s' are different " "from the files in the new package. Skipping " "it...") % old_package) @@ -226,9 +222,6 @@ def find_delta(old_files, new_files): old_hashes = set([f.hash for f in old_files.list]) hashes_delta = new_hashes - old_hashes - if hashes_delta == new_hashes: - raise AllFilesChangedException - deltas = [] for h in hashes_delta: deltas.extend(hashto_files[h])