Skip to content

Commit

Permalink
Merge bug 414560 to hg repositories (force file support for patcher f…
Browse files Browse the repository at this point in the history
…astmode), originally p=rhelmer, r=bsmedberg,bhearsum NPOTB
  • Loading branch information
nthomas-mozilla committed Feb 2, 2009
1 parent f1b1a53 commit 5bd1913
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions tools/update-packaging/make_incremental_updates.py
Expand Up @@ -256,24 +256,31 @@ def process_explicit_remove_files(dir_path, patch_info):
if line and not line.endswith("/"):
patch_info.append_remove_instruction(os.path.join(prefix,line))

def create_partial_patch(from_dir_path, to_dir_path, patch_filename, shas, patch_info):
def create_partial_patch(from_dir_path, to_dir_path, patch_filename, shas, patch_info, forced_updates):
""" Builds a partial patch by comparing the files in from_dir_path to thoes of to_dir_path"""
# Cannocolize the paths for safey
from_dir_path = os.path.abspath(from_dir_path)
to_dir_path = os.path.abspath(to_dir_path)
# First create a hashtable of the from and to directories
from_dir_hash,from_dir_set = patch_info.build_marfile_entry_hash(from_dir_path)
to_dir_hash,to_dir_set = patch_info.build_marfile_entry_hash(to_dir_path)
# Create a list of the forced updates
forced_list = forced_updates.strip().split('|')

# Files which exist in both sets need to be patched
patch_filenames = list(from_dir_set.intersection(to_dir_set))
patch_filenames.sort()
for filename in patch_filenames:
from_marfile_entry = from_dir_hash[filename]
to_marfile_entry = to_dir_hash[filename]
if from_marfile_entry.sha() != to_marfile_entry.sha():
# Not the same - calculate a patch
create_partial_patch_for_file(from_marfile_entry, to_marfile_entry, shas, patch_info)
if filename in forced_list:
print "Forcing "+ filename
# This filename is in the forced list, explicitly add
create_add_patch_for_file(to_dir_hash[filename], patch_info)
else:
if from_marfile_entry.sha() != to_marfile_entry.sha():
# Not the same - calculate a patch
create_partial_patch_for_file(from_marfile_entry, to_marfile_entry, shas, patch_info)

# files in from_dir not in to_dir need to be removed
remove_filenames = list(from_dir_set - to_dir_set)
Expand Down Expand Up @@ -387,7 +394,7 @@ def create_partial_patches(patches):

mar_extract_time = time.time()

partial_filename = create_partial_patch(work_dir_from, work_dir_to, patch_filename, shas, PatchInfo(work_dir, ['channel-prefs.js','update.manifest','removed-files'],['/readme.txt']))
partial_filename = create_partial_patch(work_dir_from, work_dir_to, patch_filename, shas, PatchInfo(work_dir, ['channel-prefs.js','update.manifest','removed-files'],['/readme.txt']),forced_updates)
partial_buildid = to_buildid
partial_shasum = sha.sha(open(partial_filename).read()).hexdigest()
partial_size = str(os.path.getsize(partial_filename))
Expand Down

0 comments on commit 5bd1913

Please sign in to comment.