Hacked By AnonymousFox

Current Path : /opt/cloudlinux/venv/lib/python3.11/site-packages/alembic/script/__pycache__/
Upload File :
Current File : //opt/cloudlinux/venv/lib/python3.11/site-packages/alembic/script/__pycache__/revision.cpython-311.pyc

�

�܋f�����ddlmZddlZddlZddlmZddlmZddlmZddlmZddlm	Z	ddlm
Z
dd	lmZdd
lmZddlm
Z
ddlmZdd
lmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZerddlmZeeeefZeeeedfdfZedefZ edZ!e
edfZ"e
edeedfedfZ#edeedf���Z$ej%d��Z&gd �Z'Gd!�d"e(��Z)Gd#�d$e)��Z*Gd%�d&e)��Z+Gd'�d(e)��Z,Gd)�d*e)��Z-Gd+�d,e-��Z.Gd-�d.e-��Z/Gd/�d0e.e/��Z0Gd1�d2��Z1Gd3�d��Z2ed?d8���Z3ed@d;���Z3d<�Z3dAd>�Z4dS)B�)�annotationsN)�Any)�Callable)�cast)�
Collection)�Deque)�Dict)�	FrozenSet)�Iterable)�Iterator)�List)�Optional)�overload)�Sequence)�Set)�Tuple)�
TYPE_CHECKING)�TypeVar)�Union)�util�)�not_none)�Literal.�Revision)rzLiteral['base']��_T)�boundz(?:(.+?)@)?(\w+)?((?:\+|-)\d+))�@�-�+c��eZdZdS)�
RevisionErrorN)�__name__�
__module__�__qualname__r��N/opt/cloudlinux/venv/lib64/python3.11/site-packages/alembic/script/revision.pyr"r",s�������Dr&r"c� ��eZdZd�fd�Z�xZS)�RangeNotAncestorError�lower�_RevisionIdentifierType�upper�return�Nonec�z��||_||_t���d|pd�d|pd����dS)N�	Revision �basez  is not an ancestor of revision )r*r,�super�__init__)�selfr*r,�	__class__s   �r'r3zRangeNotAncestorError.__init__1sT�����
���
�
���������������
1�	
�	
�	
�	
�	
r&)r*r+r,r+r-r.�r#r$r%r3�
__classcell__�r5s@r'r)r)0s=�������
�
�
�
�
�
�
�
�
�
r&r)c� ��eZdZd�fd�Z�xZS)	�
MultipleHeads�heads�
Sequence[str]�argument�
Optional[str]r-r.c���||_||_t���d|�dd�|������dS)Nz/Multiple heads are present for given argument 'z'; �, )r;r=r2r3�join)r4r;r=r5s   �r'r3zMultipleHeads.__init__=sW�����
� ��
�
�������H�H�d�i�i��.�.�.�
0�	
�	
�	
�	
�	
r&)r;r<r=r>r-r.r6r8s@r'r:r:<s=�������
�
�
�
�
�
�
�
�
�
r&r:c� ��eZdZd�fd�Z�xZS)�ResolutionError�message�strr=r-r.c�X��t���|��||_dS�N)r2r3r=)r4rDr=r5s   �r'r3zResolutionError.__init__Gs&���
������!�!�!� ��
�
�
r&)rDrEr=rEr-r.r6r8s@r'rCrCFs=�������!�!�!�!�!�!�!�!�!�!r&rCc�$��eZdZdZd�fd�Z�xZS)�
CycleDetected�Cycle�	revisionsr<r-r.c���||_t���|j�dd�|���d���dS)Nz is detected in revisions (r@�))rKr2r3�kindrA�r4rKr5s  �r'r3zCycleDetected.__init__OsR���"���
������y�y�y�$�)�)�I�.�.�.�.�
0�	
�	
�	
�	
�	
r&�rKr<r-r.�r#r$r%rNr3r7r8s@r'rIrILsB��������D�
�
�
�
�
�
�
�
�
�
r&rIc�$��eZdZdZd�fd�Z�xZS)�DependencyCycleDetectedzDependency cyclerKr<r-r.c�J��t���|��dSrG�r2r3rOs  �r'r3z DependencyCycleDetected.__init__Zs!���
������#�#�#�#�#r&rPrQr8s@r'rSrSWsB��������D�$�$�$�$�$�$�$�$�$�$r&rSc�$��eZdZdZd�fd�Z�xZS)�LoopDetectedz	Self-loop�revisionrEr-r.c�L��t���|g��dSrGrU�r4rXr5s  �r'r3zLoopDetected.__init__as#���
�����(��$�$�$�$�$r&�rXrEr-r.rQr8s@r'rWrW^sB��������D�%�%�%�%�%�%�%�%�%�%r&rWc�$��eZdZdZd�fd�Z�xZS)�DependencyLoopDetectedzDependency self-looprXr<r-r.c�J��t���|��dSrGrUrZs  �r'r3zDependencyLoopDetected.__init__hs!���
������"�"�"�"�"r&)rXr<r-r.rQr8s@r'r]r]esB�������!�D�#�#�#�#�#�#�#�#�#�#r&r]c���eZdZdZdld�Zejdmd���Zejdmd	���Zejdmd
���Z	ejdmd���Z
ejdnd
���Zdod�Zdpd�Z
dpd�Zdpd�Zdpd�Zdqdrd#�Z	dsdtd'�Zdud*�Zdvd.�Zdwd0�Zdxd1�Z	dsdyd5�Zdzd9�Z	dqd{d>�Z	dqd|dC�Zd}dE�Z				d~ddO�Z				d�d�dU�Z			d�d�dV�Z	dqd�dY�Zd�d\�Z 		d�d�dc�Z!d�df�Z"d�dg�Z#d�dh�Z$d�dj�Z%d�dk�Z&d$S)��RevisionMapz�Maintains a map of :class:`.Revision` objects.

    :class:`.RevisionMap` is used by :class:`.ScriptDirectory` to maintain
    and traverse the collection of :class:`.Script` objects, which are
    themselves instances of :class:`.Revision`.

    �	generator� Callable[[], Iterable[Revision]]r-r.c��||_dS)a
Construct a new :class:`.RevisionMap`.

        :param generator: a zero-arg callable that will generate an iterable
         of :class:`.Revision` instances to be used.   These are typically
         :class:`.Script` subclasses within regular Alembic use.

        N)�
_generator)r4ras  r'r3zRevisionMap.__init__us��$����r&�Tuple[str, ...]c��|j|jS)z�All "head" revisions as strings.

        This is normally a tuple of length one,
        unless unmerged branches are present.

        :return: a tuple of string revision numbers.

        )�
_revision_mapr;�r4s r'r;zRevisionMap.heads���	
����z�r&c��|j|jS)z�All "base" revisions as strings.

        These are revisions that have a ``down_revision`` of None,
        or empty tuple.

        :return: a tuple of string revision numbers.

        )rg�basesrhs r'rkzRevisionMap.bases�rir&c��|j|jS)zeAll "real" head revisions as strings.

        :return: a tuple of string revision numbers.

        )rg�_real_headsrhs r'rmzRevisionMap._real_heads����	
�����r&c��|j|jS)zeAll "real" base revisions as strings.

        :return: a tuple of string revision numbers.

        )rg�_real_basesrhs r'rpzRevisionMap._real_bases�rnr&�_RevisionMapTypec	��tj��}tj��}tj��}d}d}t��}t��}|���D]�}|�|��|j|vrtjd|jz��|||j<|j	r|�|��|�|��|�|��|j
r||fz
}|jr||fz
}��|���}	|�
|tt|����|�|tt|����|���D]{}
|
jD]q}||vrtjd|�d|
�d���||}|�|
��||
jvr|�|��|�|���r�||�|tt|����|�|	||||��t1|�����}
dx|
d<|
d<t5d�|D����|_t5d�|D����|_t5d	�|D����|_t5d
�|D����|_|�||
��|
S)z_memoized attribute, initializes the revision map from the
        initial collection.

        r�%Revision %s is present more than oncer0� referenced from � is not presentNc3�$K�|]}|jV��dSrG�rX��.0�revs  r'�	<genexpr>z,RevisionMap._revision_map.<locals>.<genexpr>��$����9�9�C�3�<�9�9�9�9�9�9r&c3�$K�|]}|jV��dSrGrwrxs  r'r{z,RevisionMap._revision_map.<locals>.<genexpr>��$���� E� E�#��� E� E� E� E� E� Er&c3�$K�|]}|jV��dSrGrwrxs  r'r{z,RevisionMap._revision_map.<locals>.<genexpr>�r|r&c3�$K�|]}|jV��dSrGrwrxs  r'r{z,RevisionMap._revision_map.<locals>.<genexpr>�r~r&) �sqlautil�OrderedDict�
OrderedSet�setrd�addrXr�warn�
branch_labels�is_base�
_is_real_base�copy�_map_branch_labelsrrq�_add_depends_on�values�_all_down_revisions�add_nextrev�_versioned_down_revisions�discard�_normalize_depends_on�_detect_cycles�dict�items�tupler;rmrkrp�
_add_branches)r4�map_r;rmrkrp�has_branch_labels�
all_revisionsrX�rev_maprz�downrev�
down_revision�revision_maps              r'rgzRevisionMap._revision_map�s6��)1�(<�(>�(>��'�2�4�4��%-�%8�%:�%:��&(��,.���E�E�����
����)�)�	+�	+�H����h�'�'�'�� �D�(�(��	�;�h�>O�O����'/�D��"�#��%�
0�!�%�%�h�/�/�/��I�I�h�����O�O�H�%�%�%���
%��(��$���%�
+���{�*����)�)�+�+������t�$4�d�;�;�	
�	
�	
�	
���]�D�1A�4�,H�,H�I�I�I��;�;�=�=�	3�	3�C��2�

3�

3���$�&�&��I�I�"�7�7�C�C�C�)����!%�W�
�
��)�)�#�.�.�.��c�;�;�;��M�M�-�0�0�0��#�#�M�2�2�2�2�

3�	
�"�"�=�$�7G��2N�2N�O�O�O����G�U�E�;��L�L�L�)-�d�j�j�l�l�);�);��04�4��T��\�"�-��9�9�5�9�9�9�9�9��
� � E� E�� E� E� E�E�E����9�9�5�9�9�9�9�9��
� � E� E�� E� E� E�E�E������,�l�;�;�;��r&r��_InterimRevisionMapTyper;�
Set[Revision]rk�Tuple[Revision, ...]rmrpc��|sdS|r|stt|�����d�|�d�|tt|�����D���d�|�d�|tt|�����D����}t
|�����|z
}|rtt|�����|r|stt|�����d�|�d�|tt|�����D���d�|�d	�|tt|�����D����}t
|�����|z
}|rtt|�����dS)
Nc��h|]	}|j��
Srrwrxs  r'�	<setcomp>z-RevisionMap._detect_cycles.<locals>.<setcomp>�*��
�
�
��
�L�
�
�
r&c��|jSrG�r���rs r'�<lambda>z,RevisionMap._detect_cycles.<locals>.<lambda>s	��!�5�r&)r�c3�$K�|]}|jV��dSrGrwrxs  r'r{z-RevisionMap._detect_cycles.<locals>.<genexpr>�8����
�
��
�L�
�
�
�
�
�
r&c��|jSrG��nextrevr�s r'r�z,RevisionMap._detect_cycles.<locals>.<lambda>s��!�)�r&c��h|]	}|j��
Srrwrxs  r'r�z-RevisionMap._detect_cycles.<locals>.<setcomp>r�r&c��|jSrG)r�r�s r'r�z,RevisionMap._detect_cycles.<locals>.<lambda>s	��!�/�r&c3�$K�|]}|jV��dSrGrwrxs  r'r{z-RevisionMap._detect_cycles.<locals>.<genexpr>!r�r&c��|jSrG��_all_nextrevr�s r'r�z,RevisionMap._detect_cycles.<locals>.<lambda>$s��!�.�r&)
rI�list�_iterate_related_revisionsrrq�intersectionr��keys�sortedrS)r4r�r;rkrmrp�total_space�deleted_revss        r'r�zRevisionMap._detect_cycles�s$���	��F��	/�E�	/���W�
�
�.�.�.�
�
��6�6�5�5���*�G�4�4�7���
�
�
��,�
�
��6�6�#�#���*�G�4�4�7���
�
�
�
�
�	��7�<�<�>�>�*�*�[�8���	6���|� 4� 4�5�5�5��	9�+�	9�)�$�w�-�-�8�8�8�
�
��6�6�/�/���*�G�4�4�7���
�
�
��,�
�
��6�6�(�(���*�G�4�4�7���
�
�
�
�
�	��7�<�<�>�>�*�*�[�8���	@�)�&��*>�*>�?�?�?�	@�	@r&rK�Collection[Revision]r�c
��|D]S}|jrJ|j�J�|jD]9}||vr.||}|�J�td|�d|j�d|j�����|||<�:�TdS)Nz
Branch name 'z' in revision z already used by revision )r��_orig_branch_labelsr"rX)r4rKr�rX�branch_label�map_revs      r'r�zRevisionMap._map_branch_labels-s���"�	2�	2�H��%�
2��3�?�?�?�$,�$@�
2�
2�L�#�t�+�+�"&�|�"4��&�2�2�2�+�m�!-��� (� 1� 1� 1� '� 0� 0�����*2�D��&�&��!	2�	2r&c��|D]�}|jr�|j�|j��|�|g|d���D]!}|j�|j���"|}|rS|jsL|jsE|j�|j��|jr||j}nn|r|js|j�E��dS�NF��include_dependencies)r��update�_get_descendant_nodes�_is_real_branch_point�is_merge_pointr�)r4rKr�rX�node�parents      r'r�zRevisionMap._add_branchesBs��"�	�	�H��%�
��&�-�-�h�.D�E�E�E� �6�6��J��5�7���F�F�D��&�-�-�h�.D�E�E�E�E����
�"�8�
�#�1�
��(�/�/��0F�G�G�G��+��!%�f�&:�!;�����
�"�8�
�#�1�
��	�	r&c���|D]T}|jrD�fd�tj|j��D��}td�|D����|_�Md|_�UdS)aResolve the 'dependencies' for each revision in a collection
        in terms of actual revision ids, as opposed to branch labels or other
        symbolic names.

        The collection is then assigned to the _resolved_dependencies
        attribute on each revision object.

        c� ��g|]
}�|��Srr)ry�depr�s  �r'�
<listcomp>z/RevisionMap._add_depends_on.<locals>.<listcomp>hs*������"%�D��I���r&c� �g|]}|�|j��SrGrw�ry�ds  r'r�z/RevisionMap._add_depends_on.<locals>.<listcomp>ls��?�?�?�A���Q�Z���r&rN)�dependenciesr�to_tupler��_resolved_dependencies)r4rKr�rX�depss  `  r'r�zRevisionMap._add_depends_onZs����"�		5�		5�H��$�
5�����)-��x�7L�)M�)M�����38�?�?��?�?�?�3�3��/�/�35��/�/�		5�		5r&c	�(�|D]�}|jr~t|j��}|�|gdtt|�����D](}||ur�|jr|�|j���)t
|��|_��d|_��dS)a�Create a collection of "dependencies" that omits dependencies
        that are already ancestor nodes for each revision in a given
        collection.

        This builds upon the _resolved_dependencies collection created in the
        _add_depends_on() method, looking in the fully populated revision map
        for ancestors, and omitting them as the _resolved_dependencies
        collection as it is copied to a new collection. The new collection is
        then assigned to the _normalized_resolved_dependencies attribute on
        each revision object.

        The collection is then used to determine the immediate "down revision"
        identifiers for this revision.

        F)r�r�rN)r�r��_get_ancestor_nodesrrq�difference_updater��!_normalized_resolved_dependencies)r4rKr�rX�normalized_resolvedrzs      r'r�z!RevisionMap._normalize_depends_onqs���&"�	@�	@�H��.�
@�&)�(�*I�&J�&J�#��3�3��J�).��.��5�5�4���
�
�C�
�h��� ��3��+�=�=��6�����>C�'�>�>��:�:�>@��:�:�'	@�	@r&FrXr�_replace�boolc�b��|j}|s&�j|vrtjd�jz��n"|r �j|vrt	d�jz����|�j<�g}|�||��|�||��|�||���jr|xj	�jfz
c_	�j
r|xj�jfz
c_�jD]I}||vrtjd|�d��d���t||�������J|�||���jr.t#�fd�|jD�����jfz|_�jr0t#�fd�|jD�����jfz|_dSdS)	z�add a single revision to an existing map.

        This method is for single-revision use cases, it's not
        appropriate for fully populating an entire revision map.

        rszrevision %s not in mapr0rtruc3�z�K�|]5}|t�j����jg��v�1|V��6dSrG)r�r��unionrX�ry�headrXs  �r'r{z+RevisionMap.add_revision.<locals>.<genexpr>�sk�����%�%����8�7�8�8�>�>��&�'����������%�%r&c3�z�K�|]5}|t�j����jg��v�1|V��6dSrG)r�r�r�rXr�s  �r'r{z+RevisionMap.add_revision.<locals>.<genexpr>�sk����������8�=�>�>�D�D��&�'�����������r&N)rgrXrr��	Exceptionr�r�r�r�rkr�rpr�rr�r��
_is_real_headr�rm�is_headr;)r4rXr�r�rKr�s `    r'�add_revisionzRevisionMap.add_revision�sL����!���	J�H�-��5�5��I�7�(�:K�K�
�
�
�
��	J�(�+�4�7�7��4�x�7H�H�I�I�I�"*��X�
���J�	����9�d�+�+�+����	�4�0�0�0����Y��-�-�-���	/��J�J�8�,�.�.�J�J��!�	5�����!2� 4�4����3�	:�	:�G��d�"�"��	�	��w�w����*����
�T�'�]�#�#�/�/��9�9�9�9��"�"�9�d�3�3�3��!�	%�$�%�%�%�%� �,�%�%�%� � ��"�$� %�D����	%������ �J�������"�$�%�D�J�J�J�	%�	%r&Nr�r>c��|j}|r|�||��}t|��dkrt||rd|znd���|r|dSdS)a�Return the current head revision.

        If the script directory has multiple heads
        due to branching, an error is raised;
        :meth:`.ScriptDirectory.get_heads` should be
        preferred.

        :param branch_label: optional branch name which will limit the
         heads considered to those which include that branch_label.

        :return: a string revision number.

        .. seealso::

            :meth:`.ScriptDirectory.get_heads`

        �z%s@headr�rN)r;�filter_for_lineage�lenr:)r4r��
current_headss   r'�get_current_headzRevisionMap.get_current_head�s���((,�z�
��	� �3�3��|���M��}����!�!���,8�D�	�L�(�(�f���
�
�	� ��#�#��4r&�
identifierrEc�8�|�|j|��SrG)r�rk)r4r�s  r'�_get_base_revisionszRevisionMap._get_base_revisions�s���&�&�t�z�:�>�>�>r&�id_�+Union[str, Collection[Optional[str]], None]�%Tuple[Optional[_RevisionOrBase], ...]c�����t|ttttf��rt�fd�|D��d��S��|��\}�t|��dkr{	t|d����dkrN��	d��}��t�fd�|D����}t��fd�|D����Sn#t$rYnwxYwt��fd	�|D����S)
a�Return the :class:`.Revision` instances with the given rev id
        or identifiers.

        May be given a single identifier, a sequence of identifiers, or the
        special symbols "head" or "base".  The result is a tuple of one
        or more identifiers, or an empty tuple in the case of "base".

        In the cases where 'head', 'heads' is requested and the
        revision map is empty, returns an empty tuple.

        Supports partial identifiers, where the given identifier
        is matched against all identifiers that start with the given
        characters; if there is exactly one match, that determines the
        full revision.

        c�:��g|]}��|����Sr)�
get_revisions)ry�id_elemr4s  �r'r�z-RevisionMap.get_revisions.<locals>.<listcomp>
s'���G�G�G���*�*�7�3�3�G�G�Gr&rr�rr;Nc3�H�K�|]}�t|��jv�|V��dSrG)�is_revisionr�)ryr�r�s  �r'r{z,RevisionMap.get_revisions.<locals>.<genexpr>sX�����1�1�$(�#/�#.�t�#4�#4�#B�$C�$C�!%�$C�$C�$C�$C�1�1r&c3�F�K�|]}��|����V��dS))�stepsN)�_walk)ryr��rintr4s  ��r'r{z,RevisionMap.get_revisions.<locals>.<genexpr>sG�����%�%� $�!�J�J�t�4�J�8�8�%�%�%�%�%�%r&c3�D�K�|]}��|���V��dSrG)�_revision_for_ident)ry�rev_idr�r4s  ��r'r{z,RevisionMap.get_revisions.<locals>.<genexpr>&sG���������(�(���>�>������r&)�
isinstancer�r�r��	frozenset�sum�_resolve_revision_numberr��intr��
ValueError)r4r��resolved_id�select_headsr�r�s`   @@r'r�zRevisionMap.get_revisions�s������(�c�D�%��i�8�9�9�	��G�G�G�G�3�G�G�G��L�L�L�(,�(E�(E��)�)�%�K���;���1�$�$���{�1�~�.�.�D��a�x�x�'+�'9�'9�'�'B�'B��'�3�+0�1�1�1�1�,8�1�1�1�,�,�L� %�%�%�%�%�%�(4�%�%�%� � �� ��"�����D�����������)������
s�4A(C�
C+�*C+�Optional[Revision]c��|�|��\}}t|��dkrt||���|r|dnd}|�||��S)a	Return the :class:`.Revision` instance with the given rev id.

        If a symbolic name such as "head" or "base" is given, resolves
        the identifier into the current head or base revision.  If the symbolic
        name refers to multiples, :class:`.MultipleHeads` is raised.

        Supports partial identifiers, where the given identifier
        is matched against all identifiers that start with the given
        characters; if there is exactly one match, that determines the
        full revision.

        r�rr)rr�r:r�)r4r�rr��resolveds     r'�get_revisionzRevisionMap.get_revision+sg��%)�$A�$A�#�$F�$F�!��\��{���a�����S�1�1�1�<G�*O�+�a�.�.�R���'�'��,�?�?�?r&c��	|j|}|S#t$rA	|�|��}|cYS#t$r}td|z|��|�d}~wwxYwwxYw)NzNo such branch: '%s')rg�KeyErrorr�rC)r4r��
branch_rev�
nonbranch_rev�res     r'�_resolve_branchzRevisionMap._resolve_branch@s���
	��+�L�9�J�����		%�		%�		%�
%� $� 8� 8�� F� F�
�%�$�$�$��
#�
�
�
�%�*�\�9�<���������
����		%���s(�
�
A�5�A�
A�A�A�Ar�Union[str, Tuple[()]]�check_branchc���|r|�|��}nd}	|j�}n#t$rd}YnwxYw|dur��sJ��fd�|jD��}|r|�||��}|s+t	d��dt���dkrdnd������t|��dkr<t	d	��d
d�d�|d
d�D�����d�����|j|d
}|rF|�D|�J��sJ�|�|j|j��st	d|j�d|�d�����|S)NFc�h��g|].}|r*t|��dk�|�����,|��/S)�)r��
startswith)ry�xrs  �r'r�z3RevisionMap._revision_for_ident.<locals>.<listcomp>esJ����������Q���!������[�(A�(A���#��r&zNo such revision or branch '�'�z\; please ensure at least four characters are present for partial revision identifier matches�r�zMultiple revisions start with 'z': r@c3� K�|]	}d|zV��
dS)z'%s'Nr�ryr�s  r'r{z2RevisionMap._revision_for_ident.<locals>.<genexpr>s&����-L�-L�Q�f�q�j�-L�-L�-L�-L�-L�-Lr&rrz...r0z is not a member of branch ')	rrgrr�rCr�rA�_shares_lineagerX)r4rrrrX�revss `    r'r�zRevisionMap._revision_for_identPs����	��-�-�l�;�;�J�J��J�	��)�+�6�H�H���	�	�	��H�H�H�	�����u������;������+����D��
C��.�.�t�\�B�B���
7�%�o�$��� #�;�/�/�!�3�3�N�N�"$�$�		� �����T���Q���%�o�#�{�{�D�I�I�-L�-L�$�q��s�)�-L�-L�-L�$L�$L�$L�$L�N� �	��� �-�d�1�g�6���
	�H�0��)�)�)����;��'�'��!�:�#6���
�&�o��(�(�(�,�,�,�8�����
�s�
+�:�:�targets�#Iterable[Optional[_RevisionOrBase]]�Set[Optional[_RevisionOrBase]]c��t|��}t|��D]Z}|sJ�|�|�|gd������|g��r|�|���[|Sr�)r�r�r�r��
differencer�)r4r!rzs   r'�_filter_into_branch_headsz%RevisionMap._filter_into_branch_heads�s����g�,�,����=�=�	%�	%�C��J�J�3��#�#��*�*�C�5�u�*�M�M����j�#����
%�����$�$�$���r&�Iterable[_T]�
check_againstr��Tuple[_T, ...]c��������|��\}}g�|r��|��|r��|��t���fd�|D����S)Nc3�L�K�|]}��|������|V��dS)r�N)r)ry�tgr�r4�sharess  ���r'r{z1RevisionMap.filter_for_lineage.<locals>.<genexpr>�sZ�����
�
���#�#��F�1E�$���
��
�
�
�
�
�
r&)r�append�extendr�)r4r!r(r�r�r�r-s`  `  @r'r�zRevisionMap.filter_for_lineage�s������!�9�9�-�H�H���\����	(��M�M�,�'�'�'��	��M�M�#�����
�
�
�
�
�
��
�
�
�
�
�	
r&�target�_RevisionOrStr�test_against_revs�Sequence[_RevisionOrStr]c���|sdSt|t��s#t��|����}n|}�fd�t	j|d���D��}t
t��|g|������	��
|g|������|����S)NTc�h��g|].}t|t��s��|��n|��/Sr)rrr�)ry�test_against_revr4s  �r'r�z/RevisionMap._shares_lineage.<locals>.<listcomp>�sR���&
�&
�&
�!��.��9�9�
"�D�$�$�%5�6�6�6�!�&
�&
�&
r&r��defaultr�)rrrr�rr�r�r�r�r�r�r�)r4r0r2r��resolved_target�resolved_test_against_revss`     r'rzRevisionMap._shares_lineage�s���!�	��4��&�(�+�+�	%�&�t�'?�'?��'G�'G�H�H�O�O�$�O�&
�&
�&
�&
�%)�M�!�2�%�%�%�	&
�&
�&
�"����*�*�$�%�)=�+���
�
��U��(�(�$�%�)=�)������\�4�
5�
5�
�
�	
r&�%Tuple[Tuple[str, ...], Optional[str]]c�0�t|t��rd|vr|�dd��\}}ne|�at|t��r|rt|dt��rt|ttf��st	d|�d����d}|j|dkr(|r|�|j|��|fS|j|fS|dkr |�	|��}|r|f|fSd|fS|d	ks|�d|fStj|d�
��|fS)Nrr�rzrevision identifier z= is not a string; ensure database driver settings are correctr;r�rr1r7)rrE�splitr�r"rgr�r;rmr�rr�)r4r�r��current_heads    r'rz$RevisionMap._resolve_revision_number�sh���c�3���
	 �C�3�J�J� #�	�	�#�q� 1� 1��L�#�#�
�_�
��U�
#�
#��(+��4>�s�1�v�s�4K�4K���c�C��<�0�0�� �-�14���7���
� �L�	
����'�>�>��
6��+�+�D�J��E�E� ���
�'��5�5�
�F�]�]��0�0��>�>�L��
(�$���4�4��<�'�'�
�F�]�]�c�k��|�#�#��=��d�3�3�3�\�A�Ar&Tr,r+r*�
implicit_base�	inclusive�assert_relative_length�select_for_downgrade�Iterator[Revision]c#��K�|r|j}n|j}||||||���\}}	|�||	��D]&}
t|�|
����V��'dS)auIterate through script revisions, starting at the given
        upper revision identifier and ending at the lower.

        The traversal uses strictly the `down_revision`
        marker inside each migration script, so
        it is a requirement that upper >= lower,
        else you'll get nothing back.

        The iterator yields :class:`.Revision` objects.

        )r@r?rAN)�_collect_downgrade_revisions�_collect_upgrade_revisions�_topological_sortrr)r4r,r*r?r@rArB�fnrKr;r�s           r'�iterate_revisionszRevisionMap.iterate_revisionss�����* �	1��2�B�B��0�B��2����'�#9�
�
�
��	�5��*�*�9�e�<�<�	4�	4�D��4�,�,�T�2�2�3�3�3�3�3�3�	4�	4r&�%Collection[Optional[_RevisionOrBase]]�Optional[_RevisionMapType]�check�omit_immediate_dependencies�
Iterator[Any]c�X��|r�fd�}n	|rd�}nd�}|�|�||���S)Nc�(��|�vr|jS|jSrG)r�r�)rzr!s �r'rHz-RevisionMap._get_descendant_nodes.<locals>.fn3s����g�%�%��+�+��;�&r&c��|jSrGr��rzs r'rHz-RevisionMap._get_descendant_nodes.<locals>.fn;s���'�'r&c��|jSrGr�rRs r'rHz-RevisionMap._get_descendant_nodes.<locals>.fn@s
���{�"r&�r�rL�r�)r4r!r�rLrMr�rHs `     r'r�z!RevisionMap._get_descendant_nodes(s����'�	#�
'�
'�
'�
'�
'�
'�"�	#�
(�
(�
(�
(�

#�
#�
#��.�.���d�%�/�
�
�	
r&c�F�|rd�}nd�}|�||||���S)Nc��|jSrG��_normalized_down_revisionsrRs r'rHz+RevisionMap._get_ancestor_nodes.<locals>.fnQs���5�5r&c��|jSrGr�rRs r'rHz+RevisionMap._get_ancestor_nodes.<locals>.fnVs���4�4r&rTrU)r4r!r�rLr�rHs      r'r�zRevisionMap._get_ancestor_nodesGsW�� �	5�
6�
6�
6�
6�

5�
5�
5��.�.���d�%�/�
�
�	
r&rHrc
#��K�|�|j}t��}tj��}|D�]1}t	|��}|�|��|rt��}	|r�|���}
|r|	�|
��|
|vr�2|�|
��||
��D]=}||}|�J�|j|krtd���|�|���>|
V�|��|rb|	�
|���|g��}
|
r7td|j�dd�d�|
D�����������3dS)Nz(Dependency resolution failed; broken mapzRequested revision z) overlaps with other requested revisions r@c3�$K�|]}|jV��dSrGrwrs  r'r{z9RevisionMap._iterate_related_revisions.<locals>.<genexpr>�s$����%C�%C�Q�a�j�%C�%C�%C�%C�%C�%Cr&)
rgr��collections�dequer�r.�popr�rXr"r�r%rA)r4rHr!r�rL�seen�todo�
target_forr0�
per_targetrzr�next_rev�overlapss              r'r�z&RevisionMap._iterate_related_revisions]s������<��%�D��u�u�� +� 1� 3� 3��!�$	�$	�J� ��,�,�F��K�K������
#� �U�U�
��
��h�h�j�j���(��N�N�3�'�'�'��$�;�;������
�
�
� �b��g�g�*�*�F�#�F�|�H�#�/�/�/��(�F�2�2�+�F�����K�K��)�)�)�)��	�	�	�#�
�$�
�%�2�2�7�;�;�F�F��H������'�-�#�O�O�O� �I�I�%C�%C�(�%C�%C�%C�C�C�C�	�����;$	�$	r&r�	List[str]c����
����j���fd��
d�|D���t�j��}tt�fd�|D��|j�������
fd��D��}g}d}��rD�|}t	|��D]\}}	||kr	||	vr|}�n�|�vr*|�|����|���|}
|
�J���fd�|
jD��}|s�|=||=t|d	z
d��}n�|
j	s?t|
j��d	kr'|d�|<||�|��ne|d�|<��
|d	d����
|d��||<|�
�
fd
�|d	d�D�������D�rJ�|S)z�Yield revision ids of a collection of Revision objects in
        topological sorted order (i.e. revisions always come after their
        down_revisions and dependencies). Uses the order of keys in
        _revision_map to sort.

        c�P��d����|g��D��S)Nc��h|]	}|j��
Srrwrs  r'r�zGRevisionMap._topological_sort.<locals>.get_ancestors.<locals>.<setcomp>�s*�������
���r&)r�)r�	id_to_revr4s ��r'�
get_ancestorsz4RevisionMap._topological_sort.<locals>.get_ancestors�s:������1�1�9�V�3D�2E�F�F����
r&c��h|]	}|j��
Srrwr�s  r'r�z0RevisionMap._topological_sort.<locals>.<setcomp>�s��.�.�.�q��
�.�.�.r&c�0��h|]}|j�v�|j��Srrw)ryr�ras  �r'r�z0RevisionMap._topological_sort.<locals>.<setcomp>�s'���A�A�A��a�j�D�.@�.@���.@�.@�.@r&)�keyc�&��g|]
}�|����Srr)ryrrks  �r'r�z1RevisionMap._topological_sort.<locals>.<listcomp>�s#���N�N�N�f�M�M�&�1�1�N�N�Nr&rNc�$��g|]}|�v�|�v�
|��
Srr)ryr�r�ras  ��r'r�z1RevisionMap._topological_sort.<locals>.<listcomp>�s6��� � � ���D�y�y�Q�m�%;�%;��%;�%;�%;r&r�c3�.�K�|]}�|��V��dSrGr)ryr�rks  �r'r{z0RevisionMap._topological_sort.<locals>.<genexpr>�s>�����0�0�48�M�M�$�/�/�0�0�0�0�0�0r&)rgr�r��index�	enumerater.�removerY�maxr�r�r�r�r/)r4rKr;�inserted_order�ancestors_by_idx�output�current_candidate_idx�	candidate�check_head_index�	ancestors�
candidate_rev�heads_to_addr�rkrjras`           @@@@r'rGzRevisionMap._topological_sort�s���������&�	�	�	�	�	�	�	�/�.�I�.�.�.���d�0�1�1����A�A�A�A�U�A�A�A�"�(�
�
�
�
�
�
�O�N�N�N�
�N�N�N���� !���@	�%�&;�<�I�/8�9I�/J�/J�<
�<
�+� �)�%�(=�=�=�!�Y�.�.�,<�)��E����$�$��M�M�)�,�,�,��K�K�	�*�*�*�!*�)� 4�
�$�0�0�0� � � � � �*�E� � � ��$� �%�&;�<�(�)>�?�,/�0E��0I�1�,M�,M�)�)�*�K���
� G�H�H�A�M�M�?K�A��
�&;�<�)�)>�?�G�G�%�����@L�A��
�&;�<�%�,�,�\�!�"�"�-=�>�>�>�*�M�,�q�/�:�:�)�1��)�/�/�0�0�0�0�<H����<L�0�0�0����}�@	�D���x��
r&�start�Optional[Union[str, Revision]]r�r�no_overwalk�Optional[_RevisionOrBase]c��t|t��r|�|��}n|}tt	|����D]�}|dkrQ|dksJ�d�|�|�|jn|j��D��}|r|�||��}n3|}n0|dkrd}n'|�|�|j	n|j
��}|sd}|s
|rdn|}	|	cSt|��dkrtd���|d}��|S)	a�
        Walk the requested number of :steps up (steps > 0) or down (steps < 0)
        the revision tree.

        :branch_label is used to select branches only when walking up.

        If the walk goes past the boundaries of the tree and :no_overwalk is
        True, None is returned, otherwise the walk terminates early.

        A RevisionError is raised if there is no unambiguous revision to
        walk to.
        rr1c�,�g|]}t|����Sr�r�rxs  r'r�z%RevisionMap._walk.<locals>.<listcomp>s0������ ��$�$���r&Nr)r1r�zAmbiguous walk)
rrEr�range�absr�rkr�r�r;r�r�r")
r4rr�r�r��initial�_�walk_up�children�rets
          r'r�zRevisionMap._walk�sk��(�e�S�!�!�	��'�'��.�.�G�G��G��s�5�z�z�"�"�!	"�!	"�A��q�y�y��&�(�(�(�(���#�1�1�&-�o��
�
�7�?� � ����� �'�#�6�6�w��M�M�H�H�&�H�H��f�$�$�!�H�H�#�1�1�"�?��
�
�$�2� � �H�
$�-�#,���
6�*�6�d�d�w���
�
�
��X����"�"�#�$4�5�5�5��q�k�G�G��r&�current_revisions�/Tuple[Optional[str], Optional[_RevisionOrBase]]c��|�dSt|t��s
Jd���t�|��}|�r|���\}}}t|��}|dkrQ|�!t
d|t|��fz���|�||||���}	|	�t
d���||	fS|du}
|
�r|r�tj
|��}|�||��}|sUttt|�|����}
|�|
|��}d�|D��}t!|��d	ksJ�|d}nutj
|��}|s!t
d|t|��fz���t!t#|����d	krtjd
��|d}|}|�|�|�|��n|�|�d|����||���}	|	�2|
r!t
d|t|��fz���t
d���||	fS|�d��\}}}|sd}||�|��fS)
aV
        Parse downgrade command syntax :target to retrieve the target revision
        and branch label (if any) given the :current_revisons stamp of the
        database.

        Returns a tuple (branch_label, target_revision) where branch_label
        is a string from the command specifying the branch to consider (or
        None if no branch given), and target_revision is a Revision object
        which the command refers to. target_revsions is None if the command
        refers to 'base'. The target may be specified in absolute form, or
        relative to :current_revisions.
        N�NNz(Expected downgrade target in string formr�1Relative revision %s didn't produce %d migrations)r�zWalked too farc�$�g|]
}|r|jn|��Srrwrs  r'r�z7RevisionMap._parse_downgrade_target.<locals>.<listcomp>xs3��+�+�+�$%�/0� 6��
�
�Q�+�+�+r&r�zadowngrade -1 from multiple heads is ambiguous; this usage will be disallowed in a future release.r�rr�r�)rrE�_relative_destination�match�groupsrr"r�r�rr�r�rrr�_get_all_currentr�r�r�r�
rpartition)r4r�r0rAr�r��symbol�relative�rel_intrz�relative_revision�cr_tuple�symbol_list�all_current�sl_all_currentr�s                r'�_parse_downgrade_targetz#RevisionMap._parse_downgrade_target7sJ��$�>��:���C�
�
�	6�	6�5�	6�	6�
�&�+�+�F�3�3���T	)�-2�\�\�^�^�*�L�&�(��(�m�m�G��!�|�|��>�'�0�3;�S��\�\�2J�K����
�j�j��� � 6�	!�����;�'�(8�9�9�9�#�S�(�(�$*�d�N�!�$�-.�#�+.�#'�=�1B�#C�#C��&*�&=�&=�$�l�'�'�� +��
+/� #�H�
�t�/D�/D�X�/N�/N�+�+�K�.2�-D�-D� +�\�.�.�N�+�+�)7�+�+�+�K�
 #�;�/�/�1�4�4�4�4�!,�Q����,0�M�:K�,L�,L�)�0��"/�!8�#+�S��\�\�":�!;�#�#���s�#4�5�5�6�6��:�:� �I�!+����"3�1�!5��(.���j�j�#�+��+�+�F�3�3�3��*�*�l�l�l�F�F�+K�L�L�!� 6�!�����;�(�>�+�4�7?��W���6N�O����
,�,<�=�=�=�#�S�(�(�#)�"3�"3�C�"8�"8���a���	 ��L��T�.�.�v�6�6�6�6r&c�N�t|t��rt�|��}nd}|s|�|��Stj|��}|���\}}}t|��}	|	dk�r0|��|sd}|}
|r�|�	|�|��|��}
|
sf|�	|�
|�|����|��}td�|D��d�|D��z
��}
|
sd}
t|
��dkrtd���|�|
d|	||���}|�!td	|t|	��fz���|fS|�|�|��|	||���fS|�!td	|	t|	��fz���|�|�|�|��n|�|�d
|����|	|���fS)aI
        Parse upgrade command syntax :target to retrieve the target revision
        and given the :current_revisons stamp of the database.

        Returns a tuple of Revision objects which should be iterated/upgraded
        to. The target may be specified in absolute form, or relative to
        :current_revisions.
        NrrGc��h|]	}|j��
Srrwrxs  r'r�z4RevisionMap._parse_upgrade_target.<locals>.<setcomp>�s��F�F�F�c�S�\�F�F�Fr&c�&�h|]}|jD]}|���SrrX)ryrz�downs   r'r�z4RevisionMap._parse_upgrade_target.<locals>.<setcomp>�sB�����$'�,/�,J���%)�!%����r&r�z1Ambiguous upgrade from multiple current revisions)rr�r�r�r�rr�)rrEr�r�r�rr�r�rr�r�r�r�r"r�r�r)
r4r�r0rAr��current_revisions_tupr�r��relative_strr��
start_revs�active_on_branchrzs
             r'�_parse_upgrade_targetz!RevisionMap._parse_upgrade_target�s����f�c�"�"�	�)�/�/��7�7�E�E��E��	.��%�%�f�-�-�-�!%�
�.?� @� @��-2�\�\�^�^�*��f�l��|�$�$���a�<�<��~�,�4�,3�)�2�
��1�!%�!8�!8��*�*�+@�A�A�<�"�"�J�&�1�,0�+B�+B� �4�4� $� 2� 2�3H� I� I���)�	,�,�(�&+�F�F�5E�F�F�F���+;�����&�&�
� *�1�*1�J��z�?�?�Q�&�&�'�K�����j�j�$�Q�-�"�!-� 6�	!�����;�'�0�3?��X���2O�P�����v�
��J�J�"�/�/��7�7�&�%1�$:�	������~�#�,�/7��X���.G�H����
�
�
�#�+��+�+�F�3�3�3��*�*�l�l�l�F�F�+K�L�L�"� 6�����
r&c��|�|||���\}}|dkrd}|�t|t��sJ�|�$d�|j���D��}n*|r|g}n$d�|�|j��D��}|r�t|��dkr�d�|�|�	|��gd�	��D��}	d
�|�d�|D���
|	����D��}t|��dkrtd
���|�|��}
t|�
|dd�����}t|�|
d�	����}|�|��|r;|�|�|�|������|�|s||
vrt#d|���||
fS)a
        Compute the set of current revisions specified by :upper, and the
        downgrade target specified by :target. Return all dependents of target
        which are currently active.

        :inclusive=True includes the target revision in the set
        �r�r0rAr1Nc�$�g|]
}|�|j�|��SrG�r�rxs  r'r�z<RevisionMap._collect_downgrade_revisions.<locals>.<listcomp>1s/�������?�s�'8�'@��'@�'@�'@r&c�,�g|]}t|����Srr�rxs  r'r�z<RevisionMap._collect_downgrade_revisions.<locals>.<listcomp>;s0�������C� � ���r&r�c��h|]	}|j��
Srrwrxs  r'r�z;RevisionMap._collect_downgrade_revisions.<locals>.<setcomp>Bs*����������r&Fr�c�,�g|]}t|����Srr�rxs  r'r�z<RevisionMap._collect_downgrade_revisions.<locals>.<listcomp>Ks0�������C� � ���r&c��h|]	}|j��
Srrwrxs  r'r�z;RevisionMap._collect_downgrade_revisions.<locals>.<setcomp>Ns��3�3�3�c�S�\�3�3�3r&rz/Not a valid downgrade target from current headsT)r�rMzNothing to drop)r�rrrgr�r�r�r�r�rr�r"r�r��intersection_updater�r%r))
r4r,r0r@r?rAr��target_revision�rootsr|r;�downgrade_revisions�active_revisionss
             r'rEz(RevisionMap._collect_downgrade_revisionss��� )-�(D�(D�#��#9�)E�)
�)
�%��o�
�f�$�$�"�O��&�*�_�h�*O�*O�&�&�O��"����-�4�4�6�6����E�E�
�	�$�%�E�E����-�-�o�.E�F�F����E�
�	�C��J�J��N�N����3�3��)�)�,�7�7�8�).�4������I����-�-�3�3�U�3�3�3�@�@��K�K������E��5�z�z�Q���#�E�����"�"�5�)�)��"��&�&��%)�,1�
'�
�
�
�
����$�$�U��$�F�F�
�
��
	�/�/�0@�A�A�A��	��&�&� �+�+�D�,D�,D�U�,K�,K�L�L�
�
�
�

�'�'�
(��u�,�,�(�(9�5�A�A�A�"�E�)�)r&�6Tuple[Set[Revision], Tuple[Optional[_RevisionOrBase]]]c�����d�|�|||���D��}t|t��r�d|vr�|�d��\�}}|����}|�F|j�kr;t
|j��dksJ�tt|j������fd�|D��}t|�|dd������|���|�
|��}	|s+t�fd	�|	D����rt||���t!|	��t"us
Jd
���|	rH|	d�@|�|||���\}}
|
sJ�|
dkrt#��}	d}n
|
f}	|
j}t|�|	dd������|	��}��|��}|r2|�d
�|�
|��D����|	r9|s7|�d�|	D��dd���}
|�|
��|t#|��fS)a�
        Compute the set of required revisions specified by :upper, and the
        current set of active revisions specified by :lower. Find the
        difference between the two to compute the required upgrades.

        :inclusive=True includes the current/lower revisions in the set

        :implicit_base=False only returns revisions which are downstream
        of the current/lower revisions. Dependencies from branches with
        different bases will not be included.
        c�,�g|]}t|����Srr�rxs  r'r�z:RevisionMap._collect_upgrade_revisions.<locals>.<listcomp>�s0��)
�)
�)
��
����)
�)
�)
r&r�rNr�c�&��h|]
}�|jv�|��Sr)r�)ry�need�branchs  �r'r�z9RevisionMap._collect_upgrade_revisions.<locals>.<setcomp>�s-�������F�d�6H�,H�,H��,H�,H�,Hr&T)rLr�c3�$�K�|]
}|�|�vV��dSrGr)ryrz�required_node_sets  �r'r{z9RevisionMap._collect_upgrade_revisions.<locals>.<genexpr>�s7�����%
�%
����
�(�(�����%
�%
r&z#current_revisions should be a tuplerr1c3�4K�|]}t|��V��dSrGr�rxs  r'r{z9RevisionMap._collect_upgrade_revisions.<locals>.<genexpr>�s*����O�O�c��S�)�)�O�O�O�O�O�Or&c�,�g|]}t|����Srr�rxs  r'r�z:RevisionMap._collect_upgrade_revisions.<locals>.<listcomp>�s ��?�?�?�c��S�!�!�?�?�?r&F)r�rrE�	partitionrrXr�r��next�iterr�r�r�r��anyr)�typer�r�r%r�r�r�)r4r,r*r@r?rAr!r�rr�rz�current_node_set�needs�lower_descendentsr�r�s              @@r'rFz&RevisionMap._collect_upgrade_revisions{s.����&)
�)
��1�1�"'��'=�2���)
�)
�)
���e�S�!�!�		�c�U�l�l� �?�?�3�/�/�L�F�A�q��*�*�6�2�2�J��%�*�*=��*G�*G��:�3�4�4��9�9�9�9��d�:�#;�<�<�=�=������!(����G� ��$�$��t�$�
%�
�
�
�
��%��.�.�		�!�.�.�u�5�5���	6��%
�%
�%
�%
�(�%
�%
�%
�"
�"
�	6�
(��u�5�5�5��"�#�#�u�,�,�,�0�
-�,�,�
�	%�!2�1�!5�!=��1�1�"'��'=�2���F�A�s�
�J�J�3��f�}�}�$)�G�G�!����%(�F�!������$�$�!��D�
%�
�
�
�
��%�!�
"�
"�		�"�,�,�-=�>�>���	P��L�L�O�O�T�5G�5G��5N�5N�O�O�O�O�O�O�
�	9�]�	9� $� :� :�?�?�->�?�?�?��%*�!;�!�!��

�%�%�&7�8�8�8��e�G�n�n�$�$r&c���t|�|����}|�|�t	|��d�����|�|��S)NTr�)r�r�r�r�r�r&)r4r��top_revss   r'r�zRevisionMap._get_all_current�sg���t�)�)�#�.�.�/�/������$�$�T�(�^�^�$�$�O�O�	
�	
�	
��-�-�h�7�7�7r&)rarbr-r.�r-re)r-rq)r�r�r;r�rkr�rmr�rpr�r-r.)rKr�r�rqr-r.)F)rXrr�r�r-r.rG)r�r>r-r>)r�rEr-re)r�r�r-r�)r�r>r-r	)r�rEr-r	)rrrr>r-r	)r!r"r-r#)r!r'r(r>r�r�r-r))r0r1r2r3r�r�r-r�)r�r>r-r;)FFTF)r,r+r*r+r?r�r@r�rAr�rBr�r-rC)NFFT)r!rJr�rKrLr�rMr�r�r�r-rN)NFT)
r!rJr�rKrLr�r�r�r-rC)
rHrr!rJr�rKrLr�r-rC)rKr�r;rr-rf)NT)
rr�r�rr�r>r�r�r-r�)r�r+r0r+rAr�r-r�)r�r+r0r+rAr�r-r�)r,r+r0r+r@r�r?r�rAr�r-r)r,r+r*r+r@r�r?r�rAr�r-r�)r�rer-r#)'r#r$r%�__doc__r3r�memoized_propertyr;rkrmrprgr�r�r�r�r�r�r�r�r�rrr�r&r�rrrIr�r�r�rGr�r�r�rErFr�rr&r'r`r`ls���������$�$�$�$�
��
�
�
���
�
��
�
�
���
�
�� � � ��� �
�� � � ��� �
��I�I�I���I�V2@�2@�2@�2@�h2�2�2�2�*����05�5�5�5�.&@�&@�&@�&@�P6%�6%�6%�6%�6%�r-1�"�"�"�"�"�H?�?�?�?�1�1�1�1�f@�@�@�@�*����&'+�@�@�@�@�@�D����"&+�	
�
�
�
�
�4&+�	$
�$
�$
�$
�$
�L&B�&B�&B�&B�X$��'+�%*�#4�#4�#4�#4�#4�P,0��,1�%)�

�
�
�
�
�D,0��%)�
�
�
�
�
�6�0�0�0�0�0�dg�g�g�g�Z'+� �=�=�=�=�=�~r7�r7�r7�r7�hg�g�g�g�Re*�e*�e*�e*�Nc%�c%�c%�c%�J8�8�8�8�8�8r&r`c���eZdZUdZe��Zded<	e��Zded<dZded<	dZ	ded	<	dZ
ded
<	dZded<	d
ed<d
ed<ed"d���Z
		d#d$d�Zd%d�Zd&d�Zed'd���Zed'd���Zed'd���Zed(d���Zed(d���Zed(d���Zed(d���Zed(d���Zed(d ���Zed(d!���ZdS))raoBase class for revisioned objects.

    The :class:`.Revision` class is the base of the more public-facing
    :class:`.Script` object, which represents a migration script.
    The mechanics of revision management and traversal are encapsulated
    within :class:`.Revision`, while :class:`.Script` applies this logic
    to Python files in a version directory.

    zFrozenSet[str]r�r�NrErXzOptional[_RevIdType]r�r�zSet[str]r�rer�r�r-r.c���t|���t��}|r6tdd�t|�����d|�d����dS)NzCharacter(s) 'r@z&' not allowed in revision identifier 'r)r�r��_revision_illegal_charsr"rAr�)�clsrX�
illegal_charss   r'�
verify_rev_idzRevision.verify_rev_idsj���H�
�
�2�2�3J�K�K�
��	��-��9�9�V�M�2�2�3�3�3�3�X�X�X�?���
�	�	r&�%Optional[Union[str, Tuple[str, ...]]]c��|r%|tj|��vrt|���|�%|tj|��vrt|���|�|��||_t
|��|_t
|��|_tj|d���|_	t|j	��|_dS�Nrr7)rr�rWr]r�rX�tuple_rev_as_scalarr�r�r�r�r�)r4rXr�r�r�s     r'r3zRevision.__init__ s����	3�X���}�)E�)E�E�E��x�(�(�(�
�
%�(�d�m��7
�7
�+
�+
�)��2�2�2����8�$�$�$� ��
�0��?�?���/��=�=���#'�=���#K�#K�#K�� � ��!9�:�:����r&c�,�t|j��t|j��g}|jr|�d|j����|jr|�d|j����|jj�dd�|���d�S)Nz
dependencies=zbranch_labels=�(r@rM)	�reprrXr�r�r.r�r5r#rA)r4�argss  r'�__repr__zRevision.__repr__5s����T�]�#�#�T�$�*<�%=�%=�>����	B��K�K�K�T�->�->�@�A�A�A���	D��K�K�K�d�.@�.@�B�C�C�C��>�2�2�2�D�I�I�d�O�O�O�O�D�Dr&c��|j�|jg��|_|j|jvr'|j�|jg��|_dSdSrG)r�r�rXr�r�)r4rXs  r'r�zRevision.add_nextrev=sZ�� �-�3�3�X�5F�4G�H�H����=�H�>�>�>��<�-�-�x�/@�.A�B�B�D�L�L�L�?�>r&c�l�tjtj|jd���|jz��Sr�)r�dedupe_tupler�r�r�rhs r'r�zRevision._all_down_revisionsBs7��� ��M�$�,�b�9�9�9��)�
*�
�
�	
r&c�l�tjtj|jd���|jz��S)z|return immediate down revisions for a rev, omitting dependencies
        that are still dependencies of ancestors.

        rr7)rr�r�r�r�rhs r'rYz#Revision._normalized_down_revisionsIs9��� ��M�$�,�b�9�9�9��4�
5�
�
�	
r&c�8�tj|jd���Sr�)rr�r�rhs r'r�z"Revision._versioned_down_revisionsTs���}�T�/��<�<�<�<r&r�c�,�t|j��S)aReturn True if this :class:`.Revision` is a 'head' revision.

        This is determined based on whether any other :class:`.Script`
        within the :class:`.ScriptDirectory` refers to this
        :class:`.Script`.   Multiple heads can be present.

        )r�r�rhs r'r�zRevision.is_headXs�����%�%�%�%r&c�,�t|j��SrG)r�r�rhs r'r�zRevision._is_real_headcs����)�*�*�*�*r&c��|jduS)z<Return True if this :class:`.Revision` is a 'base' revision.Nr�rhs r'r�zRevision.is_basegs���!�T�)�)r&c�&�|jduo|jduS)zrReturn True if this :class:`.Revision` is a "real" base revision,
        e.g. that it has no dependencies either.N)r�r�rhs r'r�zRevision._is_real_basems���!�T�)�G�d�.?�4�.G�Gr&c�2�t|j��dkS)a+Return True if this :class:`.Script` is a branch point.

        A branchpoint is defined as a :class:`.Script` which is referred
        to by more than one succeeding :class:`.Script`, that is more
        than one :class:`.Script` has a `down_revision` identifier pointing
        here.

        r�)r�r�rhs r'�is_branch_pointzRevision.is_branch_pointws���4�<� � �1�$�$r&c�2�t|j��dkS)zzReturn True if this :class:`.Script` is a 'real' branch point,
        taking into account dependencies as well.

        r�)r�r�rhs r'r�zRevision._is_real_branch_point�s���4�$�%�%��)�)r&c�2�t|j��dkS)z6Return True if this :class:`.Script` is a merge point.r�)r�r�rhs r'r�zRevision.is_merge_point�s���4�1�2�2�Q�6�6r&r[r�)
rXrEr�r�r�r�r�r�r-r.)r-rE)rXrr-r.r�)r-r�)r#r$r%r�rr��__annotations__r�rXr�r�r��classmethodr�r3r�r��propertyr�rYr�r�r�r�r�r�r�r�rr&r'rr�s{���������(�i�k�k�G�)�)�)�)�;�#,�9�;�;�L�.�.�.�.��H�����%�*.�M�.�.�.�.��*.�L�-�-�-�-��#�M�"�"�"�"��,�+�+�+�6�6�6�6������[��?C�?C�;�;�;�;�;�*E�E�E�E�C�C�C�C�
�
�
�
��X�
��
�
�
��X�
��=�=�=��X�=��&�&�&��X�&��+�+�+��X�+��*�*�*��X�*�
�H�H�H��X�H��	%�	%�	%��X�	%��*�*�*��X�*��7�7�7��X�7�7�7r&rz�Optional[Sequence[str]]r-�#Optional[Union[str, Sequence[str]]]c��dSrGrrRs r'r�r���	���Cr&�!Optional[Sequence[Optional[str]]]�7Optional[Union[Optional[str], Sequence[Optional[str]]]]c��dSrGrrRs r'r�r��r�r&c�D�|sdSt|��dkr|dS|S)Nr�r)r�rRs r'r�r��s,�����t�	�S���Q����1�v�
��
r&rc�4�t|t��sJ�|SrG)rrrRs r'r�r��s���c�8�$�$�$�$�$��Jr&)rzr�r-r�)rzr�r-r�)rzrr-r)5�
__future__rr]r�typingrrrrrr	r
rrr
rrrrrrrr�
sqlalchemyrr�rrrrE�
_RevIdTyper+r1�_RevisionOrBaser�rqr�compiler�r�r�r"r)r:rCrIrSrWr]r`rr�r�rr&r'�<module>r�s���"�"�"�"�"�"�����	�	�	�	������������������������������������������������������������������������������������������� � � � � � �������������'�'�'�'�'�'���������������������
�3���
�%�
&�
���U�3��8�_�d� :�;���z�3��'���5�6���s�J��/����d�C��r��2�3�X�j�5I�I�J���W�T��s�J��/�0�0�0��"��
�#D�E�E��)�/�/��	�	�	�	�	�I�	�	�	�	
�	
�	
�	
�	
�M�	
�	
�	
�
�
�
�
�
�M�
�
�
�!�!�!�!�!�m�!�!�!�
�
�
�
�
�M�
�
�
�$�$�$�$�$�m�$�$�$�%�%�%�%�%�=�%�%�%�#�#�#�#�#�4�l�#�#�#�|8�|8�|8�|8�|8�|8�|8�|8�~+d7�d7�d7�d7�d7�d7�d7�d7�N
����
���
����
�����������r&

Hacked By AnonymousFox1.0, Coded By AnonymousFox