def _rename_feature_in()

in tools/migration/legacy_fields_migration_lib.py [0:0]


def _rename_feature_in(msg, from_name, to_name):
  if from_name in msg.implies:
    msg.implies.remove(from_name)
  for requires in msg.requires:
    if from_name in requires.feature:
      requires.feature.remove(from_name)
      requires.feature.extend([to_name])
    for flag_set in msg.flag_set:
      for with_feature in flag_set.with_feature:
        if from_name in with_feature.feature:
          with_feature.feature.remove(from_name)
          with_feature.feature.extend([to_name])
        if from_name in with_feature.not_feature:
          with_feature.not_feature.remove(from_name)
          with_feature.not_feature.extend([to_name])
    for env_set in msg.env_set:
      for with_feature in env_set.with_feature:
        if from_name in with_feature.feature:
          with_feature.feature.remove(from_name)
          with_feature.feature.extend([to_name])
        if from_name in with_feature.not_feature:
          with_feature.not_feature.remove(from_name)
          with_feature.not_feature.extend([to_name])