CreatePatch.py: Drop legacy "VERBATIM" mechanism 08/282308/1
authorAntoni Adaszkiewicz <a.adaszkiewi@samsung.com>
Thu, 29 Sep 2022 10:47:13 +0000 (12:47 +0200)
committerAntoni Adaszkiewicz <a.adaszkiewi@samsung.com>
Thu, 29 Sep 2022 10:47:13 +0000 (12:47 +0200)
Change-Id: I2def77d974733fa8708b3e806abc0c70aa2b7ae4

mk_delta/common/bin/CreatePatch.py

index f8dacb1..adf4e52 100755 (executable)
@@ -34,7 +34,6 @@ Will maintain same format of script that will be generated when we use diffutil
        5) Duplicates in the list of Deletes and News
        6) Close matching diffs even though name changes across directories. (for matching extension)
        7) Clearing empty directories after Moves or diffs under Rename.
-       8) Supporting Verbatim - Any entry under Verbatim_list.txt will be treated as NEW files instead of patch.
 
 Current Case
 1. Given two folders, from list of REMOVED and NEW files find if there
@@ -67,7 +66,6 @@ def global_paths():
        global COMMON_BIN_PATH
        global MEM_REQ
        global EMPTY
-       global VERBATIM_LIST
        global MEM_FILE
 
 
@@ -91,7 +89,6 @@ DELTA_IMAGE = "DELTA_IMAGE"
 DELTA_FS = "DELTA_FS"
 EXTRA = "EXTRA"
 LOGFILE = "Delta.log"
-VERBATIM_LIST = "Verbatim_List.txt"
 EMPTY = ""
 MEM_REQ = 0
 MEM_FILE = "NULL"
@@ -100,7 +97,6 @@ COMPRESSION_BROTLI = "brotli"
 
 SUPPORT_RENAME = "TRUE"  # Use appropriate name
 SUPPORT_CONTAINERS = "FALSE"
-SUPPORT_VERBATIM = "TRUE"
 
 TEST_MODE = "FALSE"
 
@@ -486,20 +482,6 @@ def SS_Generate_Delta(PART_NAME, BASE_OLD, Old_files, Old_dirs, BASE_NEW, New_fi
                                files_removed.append(elt)
                                files_new.append(elt)
 
-       # HANDLING VERBATIM - Remove from changed list and delete the entries on device first
-       # This script is called partition wise, So, how do u want to handle it? (specialy for delete case?)
-
-       print("Check for any verbatim under - %s" % VERBATIM_LIST)
-       if SUPPORT_VERBATIM == "TRUE" and os.path.exists(VERBATIM_LIST):
-               with open(VERBATIM_LIST, 'r') as F_News:
-                       lines = set(F_News.read().splitlines())
-               for line in lines:
-                       if line in files_changed:
-                               files_changed.remove(line)
-                               files_removed.append(line)
-                       if line in files_new:
-                               files_new.remove(line)
-
        # Currently if Version or number is the first character of the file, then we are NOT making any diffs.
        if SUPPORT_RENAME == "TRUE":
                for elt in files_removed:
@@ -552,7 +534,6 @@ def SS_Generate_Delta(PART_NAME, BASE_OLD, Old_files, Old_dirs, BASE_NEW, New_fi
        New_Cnt = 0
        Diff_Cnt = 0
        Move_Cnt = 0
-       Verbatim_Cnt = 0
        SymLinkDoc = OUT_DIR + '/' + PART_NAME + SYMLINK_DOC_NAME
        HardLinkDoc = OUT_DIR + '/' + PART_NAME + HARDLINK_DOC_NAME
        Partition_Doc = open(OUT_DIR + '/' + PART_NAME + '.txt', 'w')
@@ -739,19 +720,6 @@ def SS_Generate_Delta(PART_NAME, BASE_OLD, Old_files, Old_dirs, BASE_NEW, New_fi
                                SS_UpdateSize(src_file, dst_file)
                                Update_Attr(elt[0], "FILE", File_Attributes, Sym_Attributes)
 
-       # HANDLING VERBATIM - We Process NEWs and DELETEs for Verbatim list ONLY after processing duplicates & rename functionality.
-       # So that, the rename functionality will NOT create PATCH instead of verbatims.
-
-       if SUPPORT_VERBATIM == "TRUE" and os.path.exists(VERBATIM_LIST):
-               with open(VERBATIM_LIST, 'r') as F_News:
-                       lines = set(F_News.read().splitlines())
-               for line in lines:
-                       if line not in files_new:
-                               if os.path.exists(BASE_NEW + '/' + line):
-                                       files_new.append(line)
-                                       Verbatim_Cnt = Verbatim_Cnt + 1
-                                       logging.debug("Added to list of verbatims -%s" % BASE_NEW + '/' + line)
-
        for elt in files_removed:
                # if files are part of patches after renaming, we shd remove them as part of removed.
                src_file = BASE_OLD + '/' + elt
@@ -860,10 +828,10 @@ def SS_Generate_Delta(PART_NAME, BASE_OLD, Old_files, Old_dirs, BASE_NEW, New_fi
        logging.info('%d files NEW' % len(files_new))
        logging.info('%d File attr' % len(File_Attributes))
        logging.info('%d Sym attr' % len(Sym_Attributes))
-       logging.info('PaTcHCoUnT:Diffs-%d Moves-%d News-%d Delets-%d SymDiffs-%d SymNews-%d HardDiffs-%d HardNews-%d Verbatim -%d\n' % \
-               (Diff_Cnt, Move_Cnt, New_Cnt, Del_Cnt, Sym_Diff_Cnt, Sym_New_Cnt, Hard_Diff_Cnt, Hard_New_Cnt, Verbatim_Cnt))
-       print('PaTcHCoUnT:Diffs-%d Moves-%d News-%d Delets-%d SymDiffs-%d SymNews-%d HardDiffs-%d HardNews-%d Verbatim -%d\n' % \
-               (Diff_Cnt, Move_Cnt, New_Cnt, Del_Cnt, Sym_Diff_Cnt, Sym_New_Cnt, Hard_Diff_Cnt, Hard_New_Cnt, Verbatim_Cnt))
+       logging.info('PaTcHCoUnT:Diffs-%d Moves-%d News-%d Delets-%d SymDiffs-%d SymNews-%d HardDiffs-%d HardNews-%d\n' % \
+               (Diff_Cnt, Move_Cnt, New_Cnt, Del_Cnt, Sym_Diff_Cnt, Sym_New_Cnt, Hard_Diff_Cnt, Hard_New_Cnt))
+       print('PaTcHCoUnT:Diffs-%d Moves-%d News-%d Delets-%d SymDiffs-%d SymNews-%d HardDiffs-%d HardNews-%d\n' % \
+               (Diff_Cnt, Move_Cnt, New_Cnt, Del_Cnt, Sym_Diff_Cnt, Sym_New_Cnt, Hard_Diff_Cnt, Hard_New_Cnt))
 
        # There could be duplicates, TODO, can check before adding..
        ATTR_FILE_D = open(ATTR_FILE, 'a+')
@@ -889,7 +857,7 @@ def SS_Generate_Delta(PART_NAME, BASE_OLD, Old_files, Old_dirs, BASE_NEW, New_fi
        os.remove(SymLinkDoc)
        os.remove(HardLinkDoc)
 
-       if Diff_Cnt + Move_Cnt + New_Cnt + Del_Cnt + Sym_Diff_Cnt + Sym_New_Cnt + Verbatim_Cnt + Hard_Diff_Cnt + \
+       if Diff_Cnt + Move_Cnt + New_Cnt + Del_Cnt + Sym_Diff_Cnt + Sym_New_Cnt + Hard_Diff_Cnt + \
                Hard_New_Cnt + os.path.getsize(ATTR_FILE) == 0:
                print('No Delta Generated for %s - %s' % (PART_NAME, OUT_DIR))
                logging.info('No Delta Generated for %s' % PART_NAME)