[IMP] openupgrade_records: remove from analysis updating records
Given that the records need to be managed in the modules that own them rather in the modules that override them, and that we also have the noupdate data xml for every module, then we left out the lines that where indicating the override of records.pull/2417/head
parent
036c7283ca
commit
79c6c1a134
|
@ -83,16 +83,22 @@ def compare_records(dict_old, dict_new, fields):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
def search(item, item_list, fields):
|
def search(item, item_list, fields, get_all=None):
|
||||||
"""
|
"""
|
||||||
Find a match of a dictionary in a list of similar dictionaries
|
Find a match of a dictionary in a list of similar dictionaries
|
||||||
with respect to the keys in the 'fields' arguments.
|
with respect to the keys in the 'fields' arguments.
|
||||||
Return the item if found or None.
|
Return the item if found or None.
|
||||||
"""
|
"""
|
||||||
|
all_found = []
|
||||||
for other in item_list:
|
for other in item_list:
|
||||||
if not compare_records(item, other, fields):
|
if not compare_records(item, other, fields):
|
||||||
continue
|
continue
|
||||||
return other
|
if not get_all:
|
||||||
|
return other
|
||||||
|
if other["module"] != other["prefix"]:
|
||||||
|
all_found.append(other)
|
||||||
|
if get_all:
|
||||||
|
return all_found
|
||||||
# search for renamed fields
|
# search for renamed fields
|
||||||
if "field" in fields:
|
if "field" in fields:
|
||||||
for other in item_list:
|
for other in item_list:
|
||||||
|
@ -249,7 +255,7 @@ def compare_sets(old_records, new_records):
|
||||||
|
|
||||||
# other module, same operation, other type
|
# other module, same operation, other type
|
||||||
matched_other_type = match(
|
matched_other_type = match(
|
||||||
["mode", "model", "field"],
|
["module", "mode", "model", "field"],
|
||||||
[
|
[
|
||||||
"relation",
|
"relation",
|
||||||
"type",
|
"type",
|
||||||
|
@ -330,6 +336,20 @@ def compare_sets(old_records, new_records):
|
||||||
def compare_xml_sets(old_records, new_records):
|
def compare_xml_sets(old_records, new_records):
|
||||||
reprs = collections.defaultdict(list)
|
reprs = collections.defaultdict(list)
|
||||||
|
|
||||||
|
def match_updates(match_fields):
|
||||||
|
old_updated, new_updated = {}, {}
|
||||||
|
for column in copy.copy(old_records):
|
||||||
|
found_all = search(column, old_records, match_fields, True)
|
||||||
|
for found in found_all:
|
||||||
|
old_records.remove(found)
|
||||||
|
for column in copy.copy(new_records):
|
||||||
|
found_all = search(column, new_records, match_fields, True)
|
||||||
|
for found in found_all:
|
||||||
|
new_records.remove(found)
|
||||||
|
matched_records = list(old_updated.values()) + list(new_updated.values())
|
||||||
|
matched_records = [y for x in matched_records for y in x]
|
||||||
|
return matched_records
|
||||||
|
|
||||||
def match(match_fields, match_type="direct"):
|
def match(match_fields, match_type="direct"):
|
||||||
matched_records = []
|
matched_records = []
|
||||||
for column in copy.copy(old_records):
|
for column in copy.copy(old_records):
|
||||||
|
@ -362,6 +382,9 @@ def compare_xml_sets(old_records, new_records):
|
||||||
# direct match
|
# direct match
|
||||||
modified_records = match(["module", "model", "name"])
|
modified_records = match(["module", "model", "name"])
|
||||||
|
|
||||||
|
# updated records (will be excluded)
|
||||||
|
match_updates(["model", "name"])
|
||||||
|
|
||||||
# other module, same full xmlid
|
# other module, same full xmlid
|
||||||
moved_records = match(["model", "name"], "moved")
|
moved_records = match(["model", "name"], "moved")
|
||||||
|
|
||||||
|
@ -386,13 +409,13 @@ def compare_xml_sets(old_records, new_records):
|
||||||
if "old" in entry:
|
if "old" in entry:
|
||||||
content = "DEL %(model)s: %(name)s" % entry
|
content = "DEL %(model)s: %(name)s" % entry
|
||||||
if "moved" in entry:
|
if "moved" in entry:
|
||||||
content += " [potentially moved to %(moved)s module]" % entry
|
content += " [moved to %(moved)s module]" % entry
|
||||||
elif "renamed" in entry:
|
elif "renamed" in entry:
|
||||||
content += " [renamed to %(renamed)s module]" % entry
|
content += " [renamed to %(renamed)s module]" % entry
|
||||||
elif "new" in entry:
|
elif "new" in entry:
|
||||||
content = "NEW %(model)s: %(name)s" % entry
|
content = "NEW %(model)s: %(name)s" % entry
|
||||||
if "moved" in entry:
|
if "moved" in entry:
|
||||||
content += " [potentially moved from %(moved)s module]" % entry
|
content += " [moved from %(moved)s module]" % entry
|
||||||
elif "renamed" in entry:
|
elif "renamed" in entry:
|
||||||
content += " [renamed from %(renamed)s module]" % entry
|
content += " [renamed from %(renamed)s module]" % entry
|
||||||
if "old" not in entry and "new" not in entry:
|
if "old" not in entry and "new" not in entry:
|
||||||
|
|
Loading…
Reference in New Issue