Merges all the missing FactFields from oldDefinition into newDeclaration.
339488
protected void mergeTypeDeclarations(TypeDeclaration oldDeclaration,
                                       TypeDeclaration newDeclaration) {
        if (oldDeclaration == null) {
            return;
        }

        //add the missing fields (if any) to newDeclaration
        for (FieldDefinition oldFactField : oldDeclaration.getTypeClassDef().getFieldsDefinitions()) {
            FieldDefinition newFactField = newDeclaration.getTypeClassDef().getField(oldFactField.getName());
            if (newFactField == null) {
                newDeclaration.getTypeClassDef().addField(oldFactField);
            }
        }

        //copy the defined class
        newDeclaration.setTypeClass( oldDeclaration.getTypeClass() );
    }
1289775
public void mergeWith(ReturnPathType fact) {
        if (fact.isTop()) {
            // other fact is top: no change to this one
            return;
        } else if (this.isTop()) {
            // this fact is top: copy other fact
            this.copyFrom(fact);
        } else {
            // neither fact is top: as long as one of the two
            // facts represents a (possible) normal return, then the result
            // is a possible normal return
            if (fact.type == CAN_RETURN_NORMALLY) {
                this.type = CAN_RETURN_NORMALLY;
            }
        }
    }
127293
def merge_parts(self, version_id=None, **kwargs):
        """"""
        self.file.update_checksum(**kwargs)
        with db.session.begin_nested():
            obj = ObjectVersion.create(
                self.bucket,
                self.key,
                _file_id=self.file_id,
                version_id=version_id
            )
            self.delete()
        return obj
1251826
def merge_contextual(self, other):
        """"""
        # TODO: This is currently dependent on our data model? Make more robust to schema changes
        # Currently we assume all lists at Compound level, with 1 further potential nested level of lists
        for k in self.keys():
            # print('key: %s' % k)
            for item in self[k]:
                # print('item: %s' % item)
                for other_item in other.get(k, []):
                    # Skip text properties (don't merge names, labels, roles)
                    if isinstance(other_item, six.text_type):
                        continue
                    for otherk in other_item.keys():
                        if isinstance(other_item[otherk], list):
                            if len(other_item[otherk]) > 0 and len(item[otherk]) > 0:
                                other_nested_item = other_item[otherk][0]
                                for othernestedk in other_nested_item.keys():
                                    for nested_item in item[otherk]:
                                        if not nested_item[othernestedk]:
                                            nested_item[othernestedk] = other_nested_item[othernestedk]
                        elif not item[otherk]:
                            item[otherk] = other_item[otherk]
        log.debug('Result: %s' % self.serialize())
        return self
1293648
function mergeNewAndOldMeta(old, updated) {
  const merged = {
    firstPublishTime: old.firstPublishTime || updated.publishTime
  };

  if (!Object.keys(old).length) {
    return updated;
  }

  if (old.history && updated.history) {
    merged.history = old.history.concat(updated.history);
  }

  return Object.assign(old, updated, merged);
}
553741
def merge!(errors)
      if errors
        errors.each_pair do |field, messages|
          messages.each do |message|
            add(field, message)
          end
        end
      end
    end
437990
def merge(cls, *others):
        
        for other in others:
            for k, v in other:
                setattr(cls, k, BoundValue(cls, k, v.value))
1276016
def _AddMergeFromStringMethod(message_descriptor, cls):
  """"""
  def MergeFromString(self, serialized):
    length = len(serialized)
    try:
      if self._InternalParse(serialized, 0, length) != length:
        # The only reason _InternalParse would return early is if it
        # encountered an end-group tag.
        raise message_mod.DecodeError('Unexpected end-group tag.')
    except (IndexError, TypeError):
      # Now ord(buf[p:p+1]) == ord('') gets TypeError.
      raise message_mod.DecodeError('Truncated message.')
    except struct.error as e:
      raise message_mod.DecodeError(e)
    return length   # Return this for legacy reasons.
  cls.MergeFromString = MergeFromString

  local_ReadTag = decoder.ReadTag
  local_SkipField = decoder.SkipField
  decoders_by_tag = cls._decoders_by_tag
  is_proto3 = message_descriptor.syntax == "proto3"

  def InternalParse(self, buffer, pos, end):
    self._Modified()
    field_dict = self._fields
    unknown_field_list = self._unknown_fields
    while pos != end:
      (tag_bytes, new_pos) = local_ReadTag(buffer, pos)
      field_decoder, field_desc = decoders_by_tag.get(tag_bytes, (None, None))
      if field_decoder is None:
        value_start_pos = new_pos
        new_pos = local_SkipField(buffer, new_pos, end, tag_bytes)
        if new_pos == -1:
          return pos
        if not is_proto3:
          if not unknown_field_list:
            unknown_field_list = self._unknown_fields = []
          unknown_field_list.append(
              (tag_bytes, buffer[value_start_pos:new_pos]))
        pos = new_pos
      else:
        pos = field_decoder(buffer, new_pos, end, self, field_dict)
        if field_desc:
          self._UpdateOneofState(field_desc)
    return pos
  cls._InternalParse = InternalParse
1204958
private void migrateTenantDefinitions() {
        DBService dbservice = DBService.instance();
        List<String> keyspaces = null;
        if (dbservice instanceof ThriftService) {
            keyspaces = ((ThriftService)dbservice).getDoradusKeyspaces();
        } else if (dbservice instanceof CQLService) {
            keyspaces = ((CQLService)dbservice).getDoradusKeyspaces();
        } else {
            return;
        }
        for (String keyspace : keyspaces) {
            migrateTenantDefinition(keyspace);
        }
    }
32698
void mergeFields() {
        for (int k = 0; k < fields.size(); ++k) {
            HashMap fd = ((AcroFields)fields.get(k)).getFields();
            mergeWithMaster(fd);
        }
    }
20492
public UpdateDescription merge(@Nullable final UpdateDescription otherDescription) {
    if (otherDescription != null) {
      for (final Map.Entry<String, BsonValue> entry : this.updatedFields.entrySet()) {
        if (otherDescription.removedFields.contains(entry.getKey())) {
          this.updatedFields.remove(entry.getKey());
        }
      }
      for (final String removedField : this.removedFields) {
        if (otherDescription.updatedFields.containsKey(removedField)) {
          this.removedFields.remove(removedField);
        }
      }

      this.removedFields.addAll(otherDescription.removedFields);
      this.updatedFields.putAll(otherDescription.updatedFields);
    }

    return this;
  }
612017
public void mergeSourceData(Record recSource, Record recDest, boolean bFound)
    {
        for (int iFieldSeq = 0; iFieldSeq < recSource.getFieldCount(); iFieldSeq++)
        {
            BaseField fldSource = recSource.getField(iFieldSeq);
            BaseField fldDest = recDest.getField(fldSource.getFieldName());
            if (fldDest != null)
                if (!fldSource.isNull())
                    fldDest.moveFieldToThis(fldSource);
        }
    }
78655
private void mergeCounters(Map<String, Map<Integer, MetricSnapshot>> newCounters,
                               Map<String, Map<Integer, MetricSnapshot>> oldCounters) {
        for (Map.Entry<String, Map<Integer, MetricSnapshot>> entry : newCounters.entrySet()) {
            String metricName = entry.getKey();
            Map<Integer, MetricSnapshot> snapshots = entry.getValue();
            Map<Integer, MetricSnapshot> oldSnapshots = oldCounters.get(metricName);
            if (oldSnapshots != null && oldSnapshots.size() > 0) {
                for (Map.Entry<Integer, MetricSnapshot> snapshotEntry : snapshots.entrySet()) {
                    Integer win = snapshotEntry.getKey();
                    MetricSnapshot snapshot = snapshotEntry.getValue();
                    MetricSnapshot oldSnapshot = oldSnapshots.get(win);
                    if (oldSnapshot != null) {
                        snapshot.set_longValue(snapshot.get_longValue() + oldSnapshot.get_longValue());
                    }
                }
            }
        }
    }
407279
void merge(Archetype flatParent, Archetype specialized) {
        expandAttributeNodes(specialized.getDefinition());

        flattenCObject(RmPath.ROOT, null, flatParent.getDefinition(), specialized.getDefinition());


        mergeOntologies(flatParent.getTerminology(), specialized.getTerminology());
        if (flatParent.getAnnotations() != null) {
            if (specialized.getAnnotations() == null) {
                specialized.setAnnotations(new ResourceAnnotations());
            }
            annotationsMerger.merge(flatParent.getAnnotations().getItems(), specialized.getAnnotations().getItems());
        }
    }
994183
def duplicate(self, template_fact, **modifiers):
        """"""

        newfact = template_fact.copy()
        newfact.update(dict(self._get_real_modifiers(**modifiers)))

        return self.declare(newfact)
222463
function merge(defaultObject, objectToMerge) {
		var key;
		if (!objectToMerge) {
			return defaultObject;
		}

		for (key in objectToMerge) {
			defaultObject[key] = objectToMerge[key];
		}

		return defaultObject;
	}
339986
def Append(self, desc):
    """"""
    if desc not in self.descriptors:
      self.descriptors.append(desc)
      self.descriptor_map[desc.name] = desc
      self.descriptor_names.append(desc.name)