Skip to content

Commit

Permalink
Check the sub rules are also valid
Browse files Browse the repository at this point in the history
refs CORE-6641

Checking the sub rules are also valid we allow to check for different
positions in the chain for the BAG message we need to migrate, because
we don't really know where it should go, and the 'lazy' check for valid
in the make_update_rule method makes the suggested rules pass almost
always, so we can easily get a rule in the wrong place that later would
fail because there are no rules for the sub fields.
  • Loading branch information
Enrique Fernandez authored and sputnick1124 committed Jul 30, 2017
1 parent 8e86473 commit f1c99b0
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions tools/rosbag/src/rosbag/migration.py
Original file line number Diff line number Diff line change
Expand Up @@ -968,7 +968,7 @@ def find_path(self, old_class, new_class):
found_stop = True
break

# Next see if we can create a valid rule
# Next see if we can create a valid rule, including the sub rules
if not found_stop:
for (ind, tmp_sn) in reversed(list(zip(range(len(sn_range)), sn_range))):
if (tmp_sn.new_class._type != new_class._type):
Expand All @@ -977,12 +977,13 @@ def find_path(self, old_class, new_class):
R = new_rule(self, 'GENERATED.' + new_rule.__name__)
if R.valid:
R.find_sub_paths()
sn = ScaffoldNode(tmp_sn.new_class, new_class, R)
self.extra_nodes.append(sn)
sn_range = sn_range[:ind+1]
sn_range.append(sn)
found_stop = True
break
if R.sub_rules_valid:
sn = ScaffoldNode(tmp_sn.new_class, new_class, R)
self.extra_nodes.append(sn)
sn_range = sn_range[:ind+1]
sn_range.append(sn)
found_stop = True
break

# If there were no valid implicit rules, we suggest a new one from to the end
if not found_stop:
Expand Down Expand Up @@ -1018,7 +1019,7 @@ def find_path(self, old_class, new_class):
self.found_paths[key] = [sn]
return [sn]

# Next see if we can create a valid rule
# Next see if we can create a valid rule, including the sub rules
if not found_start:
for (ind, tmp_sn) in reversed(list(zip(range(len(sn_range)), sn_range))):
if (tmp_sn.old_class._type != old_class._type):
Expand All @@ -1027,12 +1028,13 @@ def find_path(self, old_class, new_class):
R = new_rule(self, 'GENERATED.' + new_rule.__name__)
if R.valid:
R.find_sub_paths()
sn = ScaffoldNode(old_class, tmp_sn.old_class, R)
self.extra_nodes.append(sn)
sn_range = sn_range[ind:]
sn_range.insert(0,sn)
found_start = True
break
if R.sub_rules_valid:
sn = ScaffoldNode(old_class, tmp_sn.old_class, R)
self.extra_nodes.append(sn)
sn_range = sn_range[ind:]
sn_range.insert(0,sn)
found_start = True
break

# If there were no valid implicit rules, we suggest a new one from the beginning
if not found_start:
Expand Down

0 comments on commit f1c99b0

Please sign in to comment.