def update(entry1, entry2):
    """Create a merged BibTeX entry with the data from entry2 taking precedence.
    """
    out = entry1
    if entry2 is not None:
        if entry2.type:
            out.type = entry2.type
        if entry2.persons:
            for key, value in entry2.persons.items():
                if value:
                    out.persons[key] = value
        for key, value in entry2.fields.items():
            if value:
                out.fields[key] = value
    return out
