parameters: (
      node, source, destination, replace_message, replace_repeated)
docstring: Merge all fields specified by a sub-tree from source to destination.
docstring_summary: Merge all fields specified by a sub-tree from source to destination.
docstring_tokens: Merge all fields specified by a sub - tree from source to destination .
function: def _MergeMessage(
      node, source, destination, replace_message, replace_repeated):
    """Merge all fields specified by a sub-tree from source to destination."""
    source_descriptor = source.DESCRIPTOR
    for name in node:
      child = node[name]
      field = source_descriptor.fields_by_name[name]
      if field is None:
        raise ValueError('Error: Can\'t find field {0} in message {1}.'.format(
            name, source_descriptor.full_name))
      if child:
        # Sub-paths are only allowed for singular message fields.
        if (field.label == FieldDescriptor.LABEL_REPEATED or
            field.cpp_type != FieldDescriptor.CPPTYPE_MESSAGE):
          raise ValueError('Error: Field {0} in message {1} is not a singular '
                           'message field and cannot have sub-fields.'.format(
                               name, source_descriptor.full_name))
        if source.HasField(name):
          _MergeMessage(
              child, getattr(source, name), getattr(destination, name),
              replace_message, replace_repeated)
        continue
      if field.label == FieldDescriptor.LABEL_REPEATED:
        if replace_repeated:
          destination.ClearField(_StrConvert(name))
        repeated_source = getattr(source, name)
        repeated_destination = getattr(destination, name)
        repeated_destination.MergeFrom(repeated_source)
      else:
        if field.cpp_type == FieldDescriptor.CPPTYPE_MESSAGE:
          if replace_message:
            destination.ClearField(_StrConvert(name))
          if source.HasField(name):
            getattr(destination, name).MergeFrom(getattr(source, name))
        else:
          setattr(destination, name, getattr(source, name))
function_tokens: def _MergeMessage ( node , source , destination , replace_message , replace_repeated ) : source_descriptor = source . DESCRIPTOR for name in node : child = node [ name ] field = source_descriptor . fields_by_name [ name ] if field is None : raise ValueError ( 'Error: Can\'t find field {0} in message {1}.' . format ( name , source_descriptor . full_name ) ) if child : # Sub-paths are only allowed for singular message fields. if ( field . label == FieldDescriptor . LABEL_REPEATED or field . cpp_type != FieldDescriptor . CPPTYPE_MESSAGE ) : raise ValueError ( 'Error: Field {0} in message {1} is not a singular ' 'message field and cannot have sub-fields.' . format ( name , source_descriptor . full_name ) ) if source . HasField ( name ) : _MergeMessage ( child , getattr ( source , name ) , getattr ( destination , name ) , replace_message , replace_repeated ) continue if field . label == FieldDescriptor . LABEL_REPEATED : if replace_repeated : destination . ClearField ( _StrConvert ( name ) ) repeated_source = getattr ( source , name ) repeated_destination = getattr ( destination , name ) repeated_destination . MergeFrom ( repeated_source ) else : if field . cpp_type == FieldDescriptor . CPPTYPE_MESSAGE : if replace_message : destination . ClearField ( _StrConvert ( name ) ) if source . HasField ( name ) : getattr ( destination , name ) . MergeFrom ( getattr ( source , name ) ) else : setattr ( destination , name , getattr ( source , name ) )