� J�gb����ddlmZddlZddlZddlmZddlmZddlmZddlmZddlm Z ddlm Z dd lm Z dd lm Z dd lm Z dd lmZdd lmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZerddlmZeeeeeedffZeee eee efZ eeeedfdfZ!edefZ"edZ#e edfZ$e edeedfedfZ%ed��Z&edee"� ��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-��Z0Gd-�d.e-��Z1Gd/�d0e1��Z2Gd1�d2e1��Z3Gd3�d4e2e3��Z4Gd5�d6��Z5Gd7�d��Z6edDd;���Z7edEd>���Z7dFdA�Z7dGdC�Z8dS)H�)� annotationsN)�Any)�Callable)�cast)� Collection)�Deque)�Dict)� FrozenSet)�Iterable)�Iterator)�List)�Optional)�overload)�Protocol)�Sequence)�Set)�Tuple)� TYPE_CHECKING)�TypeVar)�Union)�util�)�not_none)�Literal.�Revision)rzLiteral['base']��_T�_TR)�boundz(?:(.+?)@)?(\w+)?((?:\+|-)\d+))�@�-�+c��eZdZd d �Zd S) �_CollectRevisionsProtocol�upper�_RevisionIdentifierType�lower� inclusive�bool� implicit_base�assert_relative_length�return�;Tuple[Set[Revision], Tuple[Optional[_RevisionOrBase], ...]]c��dS�Nr)�selfr%r'r(r*r+s �g/home/asafur/pinokio/api/open-webui.git/app/env/lib/python3.11/site-packages/alembic/script/revision.py�__call__z"_CollectRevisionsProtocol.__call__4s ��GJ�c�N� r%r&r'r&r(r)r*r)r+r)r,r-)�__name__� __module__� __qualname__r2rr3r1r$r$3s.������J�J�J�J�J�Jr3r$c��eZdZdS)� RevisionErrorN)r5r6r7rr3r1r9r9>s�������Dr3r9c� ��eZdZd�fd� Z�xZS)�RangeNotAncestorErrorr'r&r%r,�Nonec�z��||_||_t���d|pd�d|pd����dS)N� Revision �basez is not an ancestor of revision )r'r%�super�__init__)r0r'r%� __class__s �r1rAzRangeNotAncestorError.__init__CsT����� ��� � ��������������� 1� � � � � r3)r'r&r%r&r,r<�r5r6r7rA� __classcell__�rBs@r1r;r;Bs=������� � � � � � � � � � r3r;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'; �, )rHrJr@rA�join)r0rHrJrBs �r1rAzMultipleHeads.__init__OsW����� � �� � �������H�H�d�i�i��.�.�.� 0� � � � � r3)rHrIrJrKr,r<rCrEs@r1rGrGNs=������� � � � � � � � � � r3rGc� ��eZdZd�fd� Z�xZS)�ResolutionError�message�strrJr,r<c�X��t���|��||_dSr/)r@rArJ)r0rQrJrBs �r1rAzResolutionError.__init__Ys&��� ������!�!�!� �� � � r3)rQrRrJrRr,r<rCrEs@r1rPrPXs=�������!�!�!�!�!�!�!�!�!�!r3rPc�$��eZdZdZd�fd� Z�xZS)� CycleDetected�Cycle� revisionsrIr,r<c���||_t���|j�dd�|���d���dS)Nz is detected in revisions (rM�))rWr@rA�kindrN�r0rWrBs �r1rAzCycleDetected.__init__asR���"��� ������y�y�y�$�)�)�I�.�.�.�.� 0� � � � � r3�rWrIr,r<�r5r6r7rZrArDrEs@r1rUrU^sB������� �D� � � � � � � � � � r3rUc�$��eZdZdZd�fd� Z�xZS)�DependencyCycleDetectedzDependency cyclerWrIr,r<c�J��t���|��dSr/�r@rAr[s �r1rAz DependencyCycleDetected.__init__ls!��� ������#�#�#�#�#r3r\r]rEs@r1r_r_isB������� �D�$�$�$�$�$�$�$�$�$�$r3r_c�$��eZdZdZd�fd� Z�xZS)� LoopDetectedz Self-loop�revisionrRr,r<c�L��t���|g��dSr/ra�r0rdrBs �r1rAzLoopDetected.__init__ss#��� �����(��$�$�$�$�$r3�rdrRr,r<r]rEs@r1rcrcpsB������� �D�%�%�%�%�%�%�%�%�%�%r3rcc�$��eZdZdZd�fd� Z�xZS)�DependencyLoopDetectedzDependency self-looprdrIr,r<c�J��t���|��dSr/rarfs �r1rAzDependencyLoopDetected.__init__zs!��� ������"�"�"�"�"r3)rdrIr,r<r]rEs@r1ririwsB������� !�D�#�#�#�#�#�#�#�#�#�#r3ric���eZdZdZdmd�Zejdnd���Zejdnd ���Zejdnd ���Z ejdnd ���Z ejdod ���Z dpd�Z dqd�Z dqd�Zdqd�Zdqd�Zdrdsd#�Z dtdud'�Zdvd*�Zdwd.�Zdxd0�Zdyd1�Z dtdzd5�Zd{d9�Z drd|d>�Z drd}dC�Zd~dE�Z dd�dO�Z d�d�dU�Z d�d�dV�Z drd�dY�Zd�d\�Z d�d�dc�Z!d�df�Z"d�dg�Z#d�di�Z$d�dk�Z%d�dl�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)r0rms r1rAzRevisionMap.__init__�s��$����r3�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_maprH�r0s r1rHzRevisionMap.heads���� ����z�r3c��|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. )rs�basesrts r1rwzRevisionMap.bases�rur3c��|j|jS)zeAll "real" head revisions as strings. :return: a tuple of string revision numbers. )rs� _real_headsrts r1ryzRevisionMap._real_heads���� �����r3c��|j|jS)zeAll "real" base revisions as strings. :return: a tuple of string revision numbers. )rs� _real_basesrts r1r|zRevisionMap._real_bases�rzr3�_RevisionMapTypec ��tj��}tj��}tj��}d}d}t��}t��}|���D]�}|�|��|j|vrtjd|jz��|||j<|j r|�|��|�|��|�|��|j r||fz }|j r||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 oncer>� referenced from � is not presentNc3�$K�|] }|jV�� dSr/�rd��.0�revs r1� <genexpr>z,RevisionMap._revision_map.<locals>.<genexpr>�$����9�9�C�3�<�9�9�9�9�9�9r3c3�$K�|] }|jV�� dSr/r�r�s r1r�z,RevisionMap._revision_map.<locals>.<genexpr>�$���� E� E�#��� E� E� E� E� E� Er3c3�$K�|] }|jV�� dSr/r�r�s r1r�z,RevisionMap._revision_map.<locals>.<genexpr>r�r3c3�$K�|] }|jV�� dSr/r�r�s r1r�z,RevisionMap._revision_map.<locals>.<genexpr>r�r3) �sqlautil� OrderedDict� OrderedSet�setrp�addrdr�warn� branch_labels�is_base� _is_real_base�copy�_map_branch_labelsrr}�_add_depends_on�values�_all_down_revisions� add_nextrev�_versioned_down_revisions�discard�_normalize_depends_on�_detect_cycles�dict�items�tuplerHryrwr|� _add_branches)r0�map_rHryrwr|�has_branch_labels� all_revisionsrd�rev_mapr��downrev� down_revision� revision_maps r1rszRevisionMap._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�;�;�;��r3r��_InterimRevisionMapTyperH� Set[Revision]rw�Tuple[Revision, ...]ryr|c ��|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�� Srr�r�s r1� <setcomp>z-RevisionMap._detect_cycles.<locals>.<setcomp>�*�� � � �� �L� � � r3c��|jSr/�r���rs r1�<lambda>z,RevisionMap._detect_cycles.<locals>.<lambda>s ��!�5�r3)r�c3�$K�|] }|jV�� dSr/r�r�s r1r�z-RevisionMap._detect_cycles.<locals>.<genexpr>�8���� � �� �L� � � � � � r3c��|jSr/��nextrevr�s r1r�z,RevisionMap._detect_cycles.<locals>.<lambda>!s��!�)�r3c��h|] }|j�� Srr�r�s r1r�z-RevisionMap._detect_cycles.<locals>.<setcomp>,r�r3c��|jSr/)r�r�s r1r�z,RevisionMap._detect_cycles.<locals>.<lambda>/s ��!�/�r3c3�$K�|] }|jV�� dSr/r�r�s r1r�z-RevisionMap._detect_cycles.<locals>.<genexpr>3r�r3c��|jSr/�� _all_nextrevr�s r1r�z,RevisionMap._detect_cycles.<locals>.<lambda>6s��!�.�r3) rU�list�_iterate_related_revisionsrr}� intersectionr��keys�sortedr_)r0r�rHrwryr|� total_space� deleted_revss r1r�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� � � @�)�&��*>�*>�?�?� ?� @� @r3rW�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_labelsr9rd)r0rWr�rd� branch_label�map_revs r1r�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� 2r3c��|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�)r0rWr�rd�node�parents r1r�zRevisionMap._add_branchesTs��"� � �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� �� � r3c���|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)r��depr�s �r1� <listcomp>z/RevisionMap._add_depends_on.<locals>.<listcomp>ys*������"%�D��I���r3c� �g|] }|�|j�� Sr/r��r��ds r1r�z/RevisionMap._add_depends_on.<locals>.<listcomp>}s��?�?�?�A���Q�Z���r3rN)� dependenciesr�to_tupler��_resolved_dependencies)r0rWr�rd�depss ` r1r�zRevisionMap._add_depends_onks����"� 5� 5�H��$� 5�����)-��x�7L�)M�)M�����38�?�?��?�?�?�3�3��/�/�35��/�/� 5� 5r3c��|D]{}|jrkt|j��}|�|gd|���D](}||ur�|jr|�|j���)t |��|_�td|_�|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_nodes�difference_updater��!_normalized_resolved_dependencies)r0rWr�rd�normalized_resolvedr�s r1r�z!RevisionMap._normalize_depends_on�s���&"� @� @�H��.� @�&)�(�*I�&J�&J�#��3�3��J�).��4��� � �C� �h��� ��3��+�=�=��6�����>C�'�>�>��:�:�>@��:�:�' @� @r3Frdr�_replacer)c�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. rzrevision %s not in mapr>r�r�c3�z�K�|]5}|t�j����jg��v�1|V��6dSr/)r�r��unionrd�r��headrds �r1r�z+RevisionMap.add_revision.<locals>.<genexpr>�sk�����%�%����8�7�8�8�>�>��&�'����������%�%r3c3�z�K�|]5}|t�j����jg��v�1|V��6dSr/)r�r�r�rdr�s �r1r�z+RevisionMap.add_revision.<locals>.<genexpr>�sk����������8�=�>�>�D�D��&�'�����������r3N)rsrdrr�� Exceptionr�r�r�r�rwr�r|r�rr�r�� _is_real_headr�ry�is_headrH)r0rdr�r�rWr�s ` r1� 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� %� %r3Nr�rKc��|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)rH�filter_for_lineage�lenrG)r0r�� current_headss r1�get_current_headzRevisionMap.get_current_head�s���((,�z� � � � �3�3��|���M� �}� � �� !� !���,8�D� �L�(�(�f��� � � � ��#� #��4r3� identifierrRc�8�|�|j|��Sr/)r�rw)r0r�s r1�_get_base_revisionszRevisionMap._get_base_revisionss���&�&�t�z�:�>�>�>r3�id_�Optional[_GetRevArg]�%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)r��id_elemr0s �r1r�z-RevisionMap.get_revisions.<locals>.<listcomp>s'���G�G�G���*�*�7�3�3�G�G�Gr3rr�rrHNc3�H�K�|]}�t|��jv�|V��dSr/)� is_revisionr�)r�r�r�s �r1r�z,RevisionMap.get_revisions.<locals>.<genexpr>(sX�����1�1�$(�#/�#.�t�#4�#4�#B�$C�$C�!%�$C�$C�$C�$C�1�1r3c3�F�K�|]}��|����V��dS))�stepsN)�_walk)r�r��rintr0s ��r1r�z,RevisionMap.get_revisions.<locals>.<genexpr>.sG�����%�%� $�!�J�J�t�4�J�8�8�%�%�%�%�%�%r3c3�D�K�|]}��|���V��dSr/)�_revision_for_ident)r��rev_idr�r0s ��r1r�z,RevisionMap.get_revisions.<locals>.<genexpr>5sG���������(�(���>�>������r3) � isinstancer�r�r�� frozenset�sum�_resolve_revision_numberr��intr� ValueError)r0r�� resolved_id� select_headsr�rs` @@r1rzRevisionMap.get_revisions s������( �c�D�%��i�8� 9� 9� ��G�G�G�G�3�G�G�G��L�L� L�(,�(E�(E�c�(J�(J� %�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�rGr )r0r�rr��resolveds r1� get_revisionzRevisionMap.get_revision:sg��%)�$A�$A�#�$F�$F�!� �\� �{� � �a� � �� �S�1�1� 1�<G�*O�+�a�.�.�R���'�'��,�?�?�?r3c�� |j|}|S#t$rA |�|��}|cYS#t$r}td|z|��|�d}~wwxYwwxYw)NzNo such branch: '%s')rs�KeyErrorr rP)r0r�� branch_rev� nonbranch_rev�res r1�_resolve_branchzRevisionMap._resolve_branchOs��� ��+�L�9�J�� ��� %� %� %� %� $� 8� 8�� F� F� �%�$�$�$�� #� � � �%�*�\�9�<��������� ���� %���s(� � A�5�A� A�A�A�Ar�Union[str, Tuple[()], None]� 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)r��xrs �r1r�z3RevisionMap._revision_for_ident.<locals>.<listcomp>tsJ����������Q���!���� � �[�(A�(A���#��r3zNo such revision or branch '�'�z\; please ensure at least four characters are present for partial revision identifier matches�r�zMultiple revisions start with 'z': rMc3� K�|] }d|zV�� dS)z'%s'Nr�r�r�s r1r�z2RevisionMap._revision_for_ident.<locals>.<genexpr>�s&����-L�-L�Q�f�q�j�-L�-L�-L�-L�-L�-Lr3rr"z...r>z is not a member of branch ') rrsrr�rPr�rN�_shares_lineagerd)r0rrrrd�revss ` r1r zRevisionMap._revision_for_ident_s��� � ��-�-�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�)r0r,r�s r1�_filter_into_branch_headsz%RevisionMap._filter_into_branch_heads�s����g�,�,����=�=� %� %�C��J�J�3��#�#��*�*�C�5�u�*�M�M����j�#���� %�����$�$�$���r3� Iterable[_TR]� check_againstr��Tuple[_TR, ...]c��������|��\}}g�|r��|��|r��|��t���fd�|D����S)Nc3�L�K�|]}��|������|V��dS)r�N)r*)r��tgr�r0�sharess ���r1r�z1RevisionMap.filter_for_lineage.<locals>.<genexpr>�sZ����� � ���#�#��F�1E�$��� � � � � � � � r3)r�append�extendr�)r0r,r3r�r�r�r8s` ` @r1r�zRevisionMap.filter_for_lineage�s������ !�9�9�-�H�H���\��� � (� �M�M�,� '� '� '� � � �M�M�#� � � �� � � � � � �� � � � � � r3�target�Optional[_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)r rr )r��test_against_revr0s �r1r�z/RevisionMap._shares_lineage.<locals>.<listcomp>�sR��� & � & � & � !�"�"2�H�=�=�&��(�(�)9�:�:�:�%� & � & � & r3r��defaultr�) r rrr rr�r)r�r�r�r�r�)r0r;r=r��resolved_target�resolved_test_against_revss` r1r*zRevisionMap._shares_lineage�s ��� !� ��4��&�(�+�+� %�&�t�'?�'?��'G�'G�H�H�O�O�$�O� & � & � & � & � %)�M�!�2�%�%�%� & � & � & �"�� ��*�*�$�%�)=�+��� � � �U��(�(�$�%�)=�)����� �\�4� 5� 5� � � r3�%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) Nr r�rzrevision identifier z= is not a string; ensure database driver settings are correctrHr�rr?rB) r rR�splitr�r9rsr�rHryr�rr�)r0r�r�� current_heads r1rz$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� Ar3Tr%r&r'r*r(r+�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*r+N)�_collect_downgrade_revisions�_collect_upgrade_revisions�_topological_sortrr) r0r%r'r*r(r+rJ�fnrWrHr�s r1�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� 4r3�%Collection[Optional[_RevisionOrBase]]�Optional[_RevisionMapType]�check�omit_immediate_dependencies� Iterator[Any]c�^��|rd �fd� }n |rd d�}nd d�}|�|�||���S) Nr�rr,� Iterable[str]c�(��|�vr|jS|jSr/)r�r�)r�r,s �r1rPz-RevisionMap._get_descendant_nodes.<locals>.fnCs����g�%�%��+�+��;�&r3c��|jSr/r��r�s r1rPz-RevisionMap._get_descendant_nodes.<locals>.fnKs ���'�'r3c��|jSr/r�r[s r1rPz-RevisionMap._get_descendant_nodes.<locals>.fnPs ���{�"r3�r�rT�r�rr,rX�r�)r0r,r�rTrUr�rPs ` r1r�z!RevisionMap._get_descendant_nodes9s���� '� #� '� '� '� '� '� '� '� "� #� (� (� (� (� (�  #� #� #� #��.�.� ��d�%�/� � � r3c�J�|rdd�}ndd�}|�||||���S) Nr�rr,rXc��|jSr/��_normalized_down_revisionsr[s r1rPz+RevisionMap._get_ancestor_nodes.<locals>.fn`s ���5�5r3c��|jSr/r�r[s r1rPz+RevisionMap._get_ancestor_nodes.<locals>.fnes ���4�4r3r]r^r_)r0r,r�rTr�rPs r1r�zRevisionMap._get_ancestor_nodesWsa�� � 5� 6� 6� 6� 6� 6�  5� 5� 5� 5��.�.� ��d�%�/� � � r3rP�#Callable[[Revision], Iterable[str]]c #��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 rMc3�$K�|] }|jV�� dSr/r�r)s r1r�z9RevisionMap._iterate_related_revisions.<locals>.<genexpr>�s$����%C�%C�Q�a�j�%C�%C�%C�%C�%C�%Cr3) rsr�� collections�dequerr9�popr�rdr9r�r0rN)r0rPr,r�rT�seen�todo� target_forr;� per_targetr�r �next_rev�overlapss r1r�z&RevisionMap._iterate_related_revisionsls����� �<��%�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� �����;$ �$ r3r� List[str]c��� � ����j�d��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. r rRr,�Set[str]c�P��d����|g��D��S)Nc��h|] }|j�� Srr�r)s r1r�zGRevisionMap._topological_sort.<locals>.get_ancestors.<locals>.<setcomp>�s*������� ���r3)r�)r � id_to_revr0s ��r1� get_ancestorsz4RevisionMap._topological_sort.<locals>.get_ancestors�s:������1�1�9�V�3D�2E�F�F���� r3c��h|] }|j�� Srr�r�s r1r�z0RevisionMap._topological_sort.<locals>.<setcomp>�s��.�.�.�q�� �.�.�.r3c�0��h|]}|j�v� |j��Srr�)r�r�rls �r1r�z0RevisionMap._topological_sort.<locals>.<setcomp>�s'���A�A�A��a�j�D�.@�.@���.@�.@�.@r3)�keyc�&��g|] }�|����Srr)r�r rws �r1r�z1RevisionMap._topological_sort.<locals>.<listcomp>�s#���N�N�N�f�M�M�&�1�1�N�N�Nr3rNc�$��g|] }|�v�|�v� |�� Srr)r�r�r�rls ��r1r�z1RevisionMap._topological_sort.<locals>.<listcomp>�s6��� � � ���D�y�y�Q�m�%;�%;��%;�%;�%;r3r�c3�.�K�|]}�|��V��dSr/r)r�r�rws �r1r�z0RevisionMap._topological_sort.<locals>.<genexpr>�s>�����0�0�48�M�M�$�/�/�0�0�0�0�0�0r3)r rRr,rs)rsr�r��index� enumerater9�removerc�maxr�r�r�r�r:)r0rWrH�inserted_order�ancestors_by_idx�output�current_candidate_idx� candidate�check_head_index� ancestors� candidate_rev� heads_to_addr�rwrvrls` @@@@r1rOzRevisionMap._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�/�:�:�)�)>�?�)�/�/�0�0�0�0�<H����<L�0�0�0����{�? �B���x�� r3�start�Optional[Union[str, Revision]]rr� 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. rr?c�,�g|]}t|����Sr�rr�s r1r�z%RevisionMap._walk.<locals>.<listcomp>$s0������ ��$�$���r3Nr)r?r�zAmbiguous walk) r rRr�range�absrrwr�r�rHr�r�r9) r0r�rr�r��initial�_�walk_up�children�rets r1rzRevisionMap._walksk��( �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��r3�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) aX Parse downgrade command syntax :target to retrieve the target revision and branch label (if any) given the :current_revisions 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_revisions 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|��Srr�r)s r1r�z7RevisionMap._parse_downgrade_target.<locals>.<listcomp>�s3��+�+�+�$%�/0� 6�� � �Q�+�+�+r3r�zadowngrade -1 from multiple heads is ambiguous; this usage will be disallowed in a future release.r �r�rr�)r rR�_relative_destination�match�groupsrr9r�rrr�r�rrr�_get_all_currentr�r�r�r� rpartition)r0r�r;r+r�r��symbol�relative�rel_intr��relative_revision�cr_tuple� symbol_list� all_current�sl_all_currentr�s r1�_parse_downgrade_targetz#RevisionMap._parse_downgrade_targetEsS��$ �>��:�� �C� � � 6� 6� 5� 6� 6� �&�+�+�F�3�3�� �X )�-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�(�/��)�)�&�1�1�1�!�.�.�'3�|�|�V�V�<���"� 6�!� � ���;�(�>�+�4�7?��W���6N�O���� ,�,<�=�=�=�#�S�(�(�#)�"3�"3�C�"8�"8�� �a��� ��L��T�.�.�v�6�6�6�6r3c�N�t|t��rt�|��}nd}|s|�|��St j|��}|���\}}}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) aJ Parse upgrade command syntax :target to retrieve the target revision and given the :current_revisions 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. Nrr/c��h|] }|j�� Srr�r�s r1r�z4RevisionMap._parse_upgrade_target.<locals>.<setcomp>�s��F�F�F�c�S�\�F�F�Fr3c�&�h|]}|jD]}|���Srrb)r�r��downs r1r�z4RevisionMap._parse_upgrade_target.<locals>.<setcomp>�sB�����$'�,/�,J���%)�!%����r3r�z1Ambiguous upgrade from multiple current revisions)r�rr�r�r�r r�)r rRr�r�rrr�r�rr�r�r�r�r9rr�r) r0r�r;r+r��current_revisions_tupr�r�� relative_strr�� start_revs�active_on_branchr�s r1�_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���� � � �(�/��)�)�&�1�1�1�!�.�.�'3�|�|�V�V�<���#� 6�� � � � r3r-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�r;r+r?Nc�$�g|] }|�|j� |��Sr/�r�r�s r1r�z<RevisionMap._collect_downgrade_revisions.<locals>.<listcomp>Hs/�������?�s�'8�'@��'@�'@�'@r3c�,�g|]}t|����Srr�r�s r1r�z<RevisionMap._collect_downgrade_revisions.<locals>.<listcomp>Rs0�������C� � ���r3r�c��h|] }|j�� Srr�r�s r1r�z;RevisionMap._collect_downgrade_revisions.<locals>.<setcomp>Ys*������� ���r3Fr�c�,�g|]}t|����Srr�r�s r1r�z<RevisionMap._collect_downgrade_revisions.<locals>.<listcomp>bs0�������C� � ���r3c��h|] }|j�� Srr�r�s r1r�z;RevisionMap._collect_downgrade_revisions.<locals>.<setcomp>es��3�3�3�c�S�\�3�3�3r3rz/Not a valid downgrade target from current headsT)r�rUzNothing to drop)r�r rrsr�rr�r�r�rr�r9r�r��intersection_updater�r0r;) r0r%r'r(r*r+r��target_revision�rootsr�rH�downgrade_revisions�active_revisionss r1rMz(RevisionMap._collect_downgrade_revisions+s��� )-�(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�)�)r3�*Tuple[Set[Revision], Tuple[Revision, ...]]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�r�s r1r�z:RevisionMap._collect_upgrade_revisions.<locals>.<listcomp>�s0��) �) �) �� �� � �) �) �) r3r�r Nr�c�&��h|] }�|jv� |��Sr)r�)r��need�branchs �r1r�z9RevisionMap._collect_upgrade_revisions.<locals>.<setcomp>�s-�������F�d�6H�,H�,H��,H�,H�,Hr3T)rTr�c3�$�K�|] }|�|�vV�� dSr/r)r�r��required_node_sets �r1r�z9RevisionMap._collect_upgrade_revisions.<locals>.<genexpr>�s7�����% �% ���� �(� (�����% �% r3z#current_revisions should be a tuplerr?c3�4K�|]}t|��V��dSr/r�r�s r1r�z9RevisionMap._collect_upgrade_revisions.<locals>.<genexpr>�s*����O�O�c��S�)�)�O�O�O�O�O�Or3c�,�g|]}t|����Srr�r�s r1r�z:RevisionMap._collect_upgrade_revisions.<locals>.<listcomp>�s ��?�?�?�c��S�!�!�?�?�?r3F)r�r rR� partitionrrdr�r��next�iterr�r�r�r�anyr;�typer�r�r0r�r�r�)r0r%r'r(r*r+r,r�rr�r��current_node_set�needs�lower_descendentsr�r�s @@r1rNz&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�$�$r3c���t|�|����}|�|�t |��d�����|�|��S)NTr�)r�rr�r�r�r1)r0r��top_revss r1r�zRevisionMap._get_all_current�sg���t�)�)�#�.�.�/�/����� � $� $�T�(�^�^�$� $� O� O� � � ��-�-�h�7�7�7r3)rmrnr,r<�r,rq)r,r}) r�r�rHr�rwr�ryr�r|r�r,r<)rWr�r�r}r,r<)F)rdrr�r)r,r<r/)r�rKr,rK)r�rRr,rq)r�r�r,r�)r�rKr,r)r�rRr,r)rrrrKr,r)r,r-r,r.)r,r2r3rKr�r)r,r4)r;r<r=r>r�r)r,r))r�r�r,rF)FFTF)r%r&r'r&r*r)r(r)r+r)rJr)r,rK)NFFT) r,rRr�rSrTr)rUr)r�r)r,rV)NFT) r,rRr�rSrTr)r�r)r,rK) rPrer,rRr�rSrTr)r,rK)rWr�rHrr,rq)NT) r�r�rrr�rKr�r)r,r�)r�r&r;r&r+r)r,r�)r�r&r;r&r+r)r,r�r4) r%r&r'r&r(r)r*r)r+r)r,r�)r�rqr,r.)'r5r6r7�__doc__rAr�memoized_propertyrHrwryr|rsr�r�r�r�r�r�r�r�rrrr r1r�r*rrQr�r�r�rOrr�r�rMrNr�rr3r1rlrl~s���������$�$�$�$� �� � � ��� � �� � � ��� � �� � � ��� � �� � � ��� � ��I�I�I���I�V2@�2@�2@�2@�h2�2�2�2�*����.5�5�5�5�.&@�&@�&@�&@�P6%�6%�6%�6%�6%�r-1�"�"�"�"�"�H?�?�?�?�/�/�/�/�b@�@�@�@�*����&'+�@�@�@�@�@�D � � � �"&+�  � � � � �4&+� & �& �& �& �& �P&B�&B�&B�&B�X$��'+�%*�#4�#4�#4�#4�#4�P,0��,1�%)�  � � � � �B,0��%)�  � � � � �4� 0�0�0�0�0�df�f�f�f�X'+� � =�=�=�=�=�~v7�v7�v7�v7�pl�l�l�l�\e*�e*�e*�e*�Nc%�c%�c%�c%�J8�8�8�8�8�8r3rlc���eZdZUdZe��Zded< e��Zded<dZded< dZ ded < dZ ded < dZ d ed < 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�NrRrdzOptional[_RevIdType]r�r�rsr�rqr�r�r,r<c���t|���t��}|r6tdd�t |�����d|�d����dS)NzCharacter(s) 'rMz&' not allowed in revision identifier 'r%)r�r��_revision_illegal_charsr9rNr�)�clsrd� illegal_charss r1� verify_rev_idzRevision.verify_rev_id.sj���H� � �2�2�3J�K�K� � � ��-��9�9�V�M�2�2�3�3�3�3�X�X�X�?��� � � r3�%Optional[Union[str, Tuple[str, ...]]]c���|r%|tj|��vrt|���|�%|tj|��vrt|���|�|��||_t tj|����|_t tj|����|_tj|d���|_ t|j ��|_ dS�NrrB) rr�rcrir�rd�tuple_rev_as_scalarr�r�r�r�r�)r0rdr�r�r�s r1rAzRevision.__init__7s��� � 3�X���}�)E�)E�E�E��x�(�(� (� � %�(�d�m� �7 �7 �+ �+ �)��2�2� 2� ���8�$�$�$� �� �0���}�1M�1M�N�N���/�� �l�0K�0K�L�L���#'�=���#K�#K�#K�� � ��!9�:�:����r3c�,�t|j��t|j��g}|jr|�d|j����|jr|�d|j����|jj�dd�|���d�S)Nz dependencies=zbranch_labels=�(rMrY) �reprrdr�r�r9r�rBr5rN)r0�argss r1�__repr__zRevision.__repr__Ls����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�Dr3c��|j�|jg��|_|j|jvr'|j�|jg��|_dSdSr/)r�r�rdr�r�)r0rds r1r�zRevision.add_nextrevTsZ�� �-�3�3�X�5F�4G�H�H��� �=�H�>� >� >��<�-�-�x�/@�.A�B�B�D�L�L�L� ?� >r3c�l�tjtj|jd���|jz��Sr�)r� dedupe_tupler�r�r�rts r1r�zRevision._all_down_revisionsYs7��� � �M�$�,�b� 9� 9� 9��)� *� � � r3c�l�tjtj|jd���|jz��S)z|return immediate down revisions for a rev, omitting dependencies that are still dependencies of ancestors. rrB)rr�r�r�r�rts r1rcz#Revision._normalized_down_revisions`s9�� � � �M�$�,�b� 9� 9� 9��4� 5� � � r3c�8�tj|jd���Sr�)rr�r�rts r1r�z"Revision._versioned_down_revisionsks���}�T�/��<�<�<�<r3r)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�rts r1r�zRevision.is_heados���� �%�%�%�%r3c�,�t|j�� Sr/)r)r�rts r1r�zRevision._is_real_headzs����)�*�*�*�*r3c��|jduS)z<Return True if this :class:`.Revision` is a 'base' revision.Nr�rts r1r�zRevision.is_base~s���!�T�)�)r3c�&�|jduo|jduS)zrReturn True if this :class:`.Revision` is a "real" base revision, e.g. that it has no dependencies either.N)r�r�rts r1r�zRevision._is_real_base�s���!�T�)�G�d�.?�4�.G�Gr3c�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�rts r1�is_branch_pointzRevision.is_branch_point�s���4�<� � �1�$�$r3c�2�t|j��dkS)zzReturn True if this :class:`.Script` is a 'real' branch point, taking into account dependencies as well. r�)r�r�rts r1r�zRevision._is_real_branch_point�s�� �4�$�%�%��)�)r3c�2�t|j��dkS)z6Return True if this :class:`.Script` is a merge point.r�)r�r�rts r1r�zRevision.is_merge_point�s���4�1�2�2�Q�6�6r3rgr�) rdrRr�r�r�r�r�r�r,r<)r,rR)rdrr,r<r�)r,r))r5r6r7r�r r��__annotations__r�rdr�r�r�� classmethodr�rAr�r��propertyr�rcr�r�r�r�r�r�r�r�rr3r1rrs{���������(�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�7r3r�r<r,c��dSr/rr[s r1r�r��s��,/�Cr3�Union[Tuple[_T, ...], List[_T]]�#Union[_T, Tuple[_T, ...], List[_T]]c��dSr/rr[s r1r�r��s ��+.�#r3�Optional[Sequence[_T]]�Union[_T, Sequence[_T], None]c�D�|sdSt|��dkr|dS|S)Nr�r)r�r[s r1r�r��s.�� ���t� �S���Q����1�v� �� r3rc�4�t|t��sJ�|Sr/)r rr[s r1rr�s�� �c�8� $� $�$�$� $� �Jr3)r�r<r,r<)r�r�r,r�)r�r�r,r�)r�rr,r)9� __future__rrhr�typingrrrrrr r r r r rrrrrrrrr� sqlalchemyrr�r'rrrR� _RevIdType� _GetRevArgr&�_RevisionOrStr�_RevisionOrBaser�r}rr�compiler�r�r$r�r9r;rGrPrUr_rcrirlrr�rrr3r1�<module>r s��"�"�"�"�"�"����� � � � ������������������������������������������������������������������������������������������������� � � � � � �������������'�'�'�'�'�'��������������������� �3��S� �5��c��?�2� 3� � �� �X�c�]�� �S�M��� �  ��U�3��8�_�d� :�;���z�3��'���5�6���s�J��/����d�C��r��2�3�X�j�5I�I�J�� �W�T�]�]�� �g�e�8�N�3�4�4�4��"�� �#D�E�E��)�/�/��J�J�J�J�J��J�J�J� � � � � �I� � � �  �  �  �  �  �M�  �  �  � � � � � �M� � � �!�!�!�!�!�m�!�!�!�  � � � � �M� � � �$�$�$�$�$�m�$�$�$�%�%�%�%�%�=�%�%�%�#�#�#�#�#�4�l�#�#�#�A8�A8�A8�A8�A8�A8�A8�A8�H,d7�d7�d7�d7�d7�d7�d7�d7�N �/�/�/� ��/� �.�.�.� ��.� ���������r3
Memory