def _merge_chains(chain_model_a, chain_model_b):
    """Merge two chains.

    For use when it becomes known that two chains that were created separately
    actually are separate sections of the same chain

    E.g.:

    - A obsoleted by X is created. A has no SID. X does not exist yet. A chain is
      created for A.
    - B obsoleting Y is created. B has SID. Y does not exist yet. A chain is created
      for B.
    - C obsoleting X, obsoleted by Y is created. C tells us that X and Y are in the
      same chain, which means that A and B are in the same chain. At this point, the
      two chains need to be merged. Merging the chains causes A to take on the SID of
      B.

    """
    _set_chain_sid(
        chain_model_a, d1_gmn.app.did.get_did_by_foreign_key(chain_model_b.sid)
    )
    for member_model in _get_all_chain_member_queryset_by_chain(chain_model_b):
        member_model.chain = chain_model_a
        member_model.save()
    chain_model_b.delete()
def _merge_chains ( chain_model_a , chain_model_b ) : _set_chain_sid ( chain_model_a , d1_gmn . app . did . get_did_by_foreign_key ( chain_model_b . sid ) ) for member_model in _get_all_chain_member_queryset_by_chain ( chain_model_b ) : member_model . chain = chain_model_a member_model . save ( ) chain_model_b . delete ( )
Merge two chains.

    For use when it becomes known that two chains that were created separately
    actually are separate sections of the same chain

    E.g.:

    - A obsoleted by X is created. A has no SID. X does not exist yet. A chain is
      created for A.
    - B obsoleting Y is created. B has SID. Y does not exist yet. A chain is created
      for B.
    - C obsoleting X, obsoleted by Y is created. C tells us that X and Y are in the
      same chain, which means that A and B are in the same chain. At this point, the
      two chains need to be merged. Merging the chains causes A to take on the SID of
      B.