
    +hb                    j   d dl mZ d dlZd dlZd dlmZ d dlmZ d dlmZ d dlmZ d dlm	Z	 d dlm
Z
 d d	lmZ d d
lmZ d dlmZ d dlmZ d dlmZ d dlmZ d dlmZ d dlmZ d dlmZ d dlmZ d dlmZ d dlmZ d dlmZ d dlmZ ddlmZ ddlmZ erd dlmZ eeee   eedf   f   Zeeeee      ee   f   Z eeeedf   df   Z!edef   Z"ed   Z#e
edf   Z$e
edeed   f   ed   f   Z% ed      Z& edee"          Z' ejP                  d!      Z)g d"Z* G d# d$e      Z+ G d% d&e,      Z- G d' d(e-      Z. G d) d*e-      Z/ G d+ d,e-      Z0 G d- d.e-      Z1 G d/ d0e1      Z2 G d1 d2e1      Z3 G d3 d4e2e3      Z4 G d5 d6      Z5 G d7 d      Z6ed<d8       Z7e	 	 	 	 d=d9       Z7	 	 	 	 d>d:Z7d?d;Z8y)@    )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)r   zLiteral['base'] _T_TR)boundz(?:(.+?)@)?(\w+)?((?:\+|-)\d+))@-+c                  ,    e Zd Z	 	 	 	 	 	 	 	 	 	 	 	 ddZy)_CollectRevisionsProtocolc                     y Nr   )selfupperlower	inclusiveimplicit_baseassert_relative_lengths         J/var/www/html/venv/lib/python3.12/site-packages/alembic/script/revision.py__call__z"_CollectRevisionsProtocol.__call__4   s	     GJ    Nr(   _RevisionIdentifierTyper)   r1   r*   boolr+   r2   r,   r2   returnz;Tuple[Set[Revision], Tuple[Optional[_RevisionOrBase], ...]])__name__
__module____qualname__r.   r   r/   r-   r$   r$   3   sI    J&J 'J 	J
 J !%J 
EJr/   r$   c                      e Zd Zy)RevisionErrorN)r4   r5   r6   r   r/   r-   r8   r8   >   s    r/   r8   c                  ,     e Zd Z	 	 	 	 	 	 d fdZ xZS )RangeNotAncestorErrorc                \    || _         || _        t        |   d|xs dd|xs d       y )N	Revision basez  is not an ancestor of revision )r)   r(   super__init__)r'   r)   r(   	__class__s      r-   r?   zRangeNotAncestorError.__init__C   s6     

1	
r/   )r)   r1   r(   r1   r3   Noner4   r5   r6   r?   __classcell__r@   s   @r-   r:   r:   B   s%    
,
5L
	
 
r/   r:   c                        e Zd Zd fdZ xZS )MultipleHeadsc                j    || _         || _        t        |   d|ddj	                  |             y )Nz/Multiple heads are present for given argument 'z'; , )headsargumentr>   r?   join)r'   rI   rJ   r@   s      r-   r?   zMultipleHeads.__init__O   s1    
 dii.0	
r/   )rI   Sequence[str]rJ   Optional[str]r3   rA   rB   rD   s   @r-   rF   rF   N   s    
 
r/   rF   c                        e Zd Zd fdZ xZS )ResolutionErrorc                2    t         |   |       || _        y r&   )r>   r?   rJ   )r'   messagerJ   r@   s      r-   r?   zResolutionError.__init__Y   s    ! r/   )rQ   strrJ   rR   r3   rA   rB   rD   s   @r-   rO   rO   X   s    ! !r/   rO   c                  $     e Zd ZdZd fdZ xZS )CycleDetectedCyclec                p    || _         t        | 	  | j                  ddj	                  |      d       y )Nz is detected in revisions (rH   ))	revisionsr>   r?   kindrK   r'   rX   r@   s     r-   r?   zCycleDetected.__init__a   s.    "yy$))I.0	
r/   rX   rL   r3   rA   r4   r5   r6   rY   r?   rC   rD   s   @r-   rT   rT   ^   s    D
 
r/   rT   c                  $     e Zd ZdZd fdZ xZS )DependencyCycleDetectedzDependency cyclec                $    t         |   |       y r&   r>   r?   rZ   s     r-   r?   z DependencyCycleDetected.__init__l   s    #r/   r[   r\   rD   s   @r-   r^   r^   i   s    D$ $r/   r^   c                  $     e Zd ZdZd fdZ xZS )LoopDetectedz	Self-loopc                &    t         |   |g       y r&   r`   r'   revisionr@   s     r-   r?   zLoopDetected.__init__s   s    ($r/   re   rR   r3   rA   r\   rD   s   @r-   rb   rb   p   s    D% %r/   rb   c                  $     e Zd ZdZd fdZ xZS )DependencyLoopDetectedzDependency self-loopc                $    t         |   |       y r&   r`   rd   s     r-   r?   zDependencyLoopDetected.__init__z   s    "r/   )re   rL   r3   rA   r\   rD   s   @r-   rh   rh   w   s    !D# #r/   rh   c                  <   e Zd ZdZd$dZej                  d%d       Zej                  d%d       Zej                  d%d       Z	ej                  d%d       Z
ej                  d&d       Z	 	 	 	 	 	 	 	 	 	 	 	 d'dZ	 	 	 	 	 	 d(d	Z	 	 	 	 	 	 d(d
Z	 	 	 	 	 	 d(dZ	 	 	 	 	 	 d(dZd)d*dZ	 d+	 	 	 d,dZd-dZ	 	 	 	 d.dZd/dZd0dZ	 d+	 	 	 	 	 d1dZ	 	 	 	 d2dZ	 d)	 	 	 	 	 	 	 d3dZ	 d)	 	 	 	 	 	 	 d4dZ	 	 	 	 d5dZ	 	 	 	 d6	 	 	 	 	 	 	 	 	 	 	 	 	 d7dZ	 	 	 	 d8	 	 	 	 	 	 	 	 	 	 	 d9dZ	 	 	 d:	 	 	 	 	 	 	 	 	 d;dZ	 d)	 	 	 	 	 	 	 	 	 d<dZ	 	 	 	 	 	 d=dZ 	 	 d>	 	 	 	 	 	 	 	 	 d?dZ!	 	 	 	 	 	 	 	 d@dZ"	 	 	 	 	 	 	 	 dAd Z#	 	 	 	 	 	 	 	 	 	 	 	 dBd!Z$	 	 	 	 	 	 	 	 	 	 	 	 dCd"Z%	 	 	 	 dDd#Z&y)ERevisionMapzMaintains 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`.

    c                    || _         y)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)r'   	generators     r-   r?   zRevisionMap.__init__   s     $r/   c                2    | j                    | j                  S )zAll "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_maprI   r'   s    r-   rI   zRevisionMap.heads        	zzr/   c                2    | j                    | j                  S )zAll "base" revisions as strings.

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

        :return: a tuple of string revision numbers.

        )rp   basesrq   s    r-   rt   zRevisionMap.bases   rr   r/   c                2    | j                    | j                  S )zeAll "real" head revisions as strings.

        :return: a tuple of string revision numbers.

        )rp   _real_headsrq   s    r-   rv   zRevisionMap._real_heads        	r/   c                2    | j                    | j                  S )zeAll "real" base revisions as strings.

        :return: a tuple of string revision numbers.

        )rp   _real_basesrq   s    r-   ry   zRevisionMap._real_bases   rw   r/   c           	        t        j                         }t        j                         }t        j                         }d}d}t               }t               }| j	                         D ]  }|j                  |       |j                  |v r"t        j                  d|j                  z         |||j                  <   |j                  r|j                  |       |j                  |       |j                  |       |j                  r||fz  }|j                  s||fz  } |j                         }	| j                  |t        t        |             | j!                  |t        t        |             |j#                         D ]y  }
|
j$                  D ]h  }||vrt        j                  d|d|
d       ||   }|j'                  |
       ||
j(                  v r|j+                  |       |j+                  |       j { | j-                  |t        t        |             | j/                  |	||||       t1        |j3                               }dx|d<   |d<   t5        d |D              | _        t5        d |D              | _        t5        d	 |D              | _        t5        d
 |D              | _        | j?                  ||       |S )z_memoized attribute, initializes the revision map from the
        initial collection.

        r   %Revision %s is present more than oncer<    referenced from  is not presentNc              3  4   K   | ]  }|j                     y wr&   re   .0revs     r-   	<genexpr>z,RevisionMap._revision_map.<locals>.<genexpr>       9C3<<9   c              3  4   K   | ]  }|j                     y wr&   r   r   s     r-   r   z,RevisionMap._revision_map.<locals>.<genexpr>        E# Er   c              3  4   K   | ]  }|j                     y wr&   r   r   s     r-   r   z,RevisionMap._revision_map.<locals>.<genexpr>  r   r   c              3  4   K   | ]  }|j                     y wr&   r   r   s     r-   r   z,RevisionMap._revision_map.<locals>.<genexpr>  r   r   ) sqlautilOrderedDict
OrderedSetsetrm   addre   r   warnbranch_labelsis_base_is_real_basecopy_map_branch_labelsr   _RevisionMapType_add_depends_onvalues_all_down_revisionsadd_nextrev_versioned_down_revisionsdiscard_normalize_depends_on_detect_cyclesdictitemstuplerI   rv   rt   ry   _add_branches)r'   map_rI   rv   rt   ry   has_branch_labelsall_revisionsre   rev_mapr   downrevdown_revisionrevision_maps                 r-   rp   zRevisionMap._revision_map   s~    )1(<(<(>'224%-%8%8%:&(,.E) 	+Hh'  D(		;h>O>OO '/D""#%%!%%h/IIhOOH%($%%{*!	+( ))+t$4d;	
 	]D1A4,HI;;= 	3C22 
3$&II"C) !%W))#.c;;;MM-0##M2
3	3  	""=$7G2NOGUE;L)-djjl);044T\"-9599
  E EE9599
  E EE,l;r/   c                   |sy |r|st        t        |            | j                  d |t        t        |            D ch c]  }|j
                   c}j                  d | j                  d |t        t        |            D              }t        |j                               |z
  }|rt        t        |            |r|st        t        |            | j                  d |t        t        |            D ch c]  }|j
                   c}j                  d | j                  d |t        t        |            D              }t        |j                               |z
  }|rt        t        |            y c c}w c c}w )Nc                    | j                   S r&   r   rs    r-   <lambda>z,RevisionMap._detect_cycles.<locals>.<lambda>  s    !55 r/   )r   c              3  4   K   | ]  }|j                     y wr&   r   r   s     r-   r   z-RevisionMap._detect_cycles.<locals>.<genexpr>        
 LL
r   c                    | j                   S r&   nextrevr   s    r-   r   z,RevisionMap._detect_cycles.<locals>.<lambda>!  s
    !)) r/   c                    | j                   S r&   )r   r   s    r-   r   z,RevisionMap._detect_cycles.<locals>.<lambda>/  s    !// r/   c              3  4   K   | ]  }|j                     y wr&   r   r   s     r-   r   z-RevisionMap._detect_cycles.<locals>.<genexpr>3  r   r   c                    | j                   S r&   _all_nextrevr   s    r-   r   z,RevisionMap._detect_cycles.<locals>.<lambda>6  s
    !.. r/   )rT   list_iterate_related_revisionsr   r   re   intersectionr   keyssortedr^   )	r'   r   rI   rt   rv   ry   r   total_spacedeleted_revss	            r-   r   zRevisionMap._detect_cycles  s    EW.. 665*G4 7 
 LL
 , 
66#*G4 7 
 
 	 7<<>*[8| 455+)$w-88 66/*G4 7 
 LL
 , 
66(*G4 7 
 
 	 7<<>*[8)&*>?? K
*
s   E==Fc           
         |D ]h  }|j                   s|j                  J |j                  D ]<  }||v r1||   }|J t        d|d|j                  d|j                        |||<   > j y )NzBranch name 'z' in revision z already used by revision )r   _orig_branch_labelsr8   re   )r'   rX   r   re   branch_labelmap_revs         r-   r   zRevisionMap._map_branch_labels?  s     " 	2H%%33???$,$@$@ 2L#t+"&|"4&222+ !- ( 1 1 ' 0 0  *2D&2	2r/   c                   |D ]  }|j                   s|j                   j                  |j                          | j                  |g|d      D ]'  }|j                   j                  |j                          ) }|sy|j                  r|j                  r|j                   j                  |j                          |j
                  r||j
                     }n|s|j                  r|j                  s_ y NFinclude_dependencies)r   update_get_descendant_nodes_is_real_branch_pointis_merge_pointr   )r'   rX   r   re   nodeparents         r-   r   zRevisionMap._add_branchesT  s     " 	H%%&&--h.D.DE 66J5 7  FD &&--h.D.DEF
 "88"11((//0F0FG++!%f&:&:!; "88"11	r/   c                   |D ]p  }|j                   r[t        j                  |j                         D cg c]  }||   	 }}t        |D cg c]  }||j                   c}      |_        jd|_        r yc c}w c c}w )a  Resolve 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.

        Nr   )dependenciesr   to_tupler   re   _resolved_dependencies)r'   rX   r   re   depdepsds          r-   r   zRevisionMap._add_depends_onk  s     " 		5H$$)-x7L7L)M"%DI  38)-?AQZZ?3/ 35/		5 @s   A7
A<
A<
c                   |D ]  }|j                   rmt        |j                         }| j                  |gd|      D ]/  }||u r|j                   s|j                  |j                          1 t	        |      |_        |d|_         y)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   r   N)r   r   _get_ancestor_nodesdifference_updater   !_normalized_resolved_dependencies)r'   rX   r   re   normalized_resolvedr   s         r-   r   z!RevisionMap._normalize_depends_on  s    & " 	@H..&)(*I*I&J#33J). 4  
C
 h 33+==66
 >C'>: >@:'	@r/   c                   | j                   }|s1j                  |v r#t        j                  dj                  z         n(|r&j                  |vrt	        dj                  z        |j                  <   g}| j                  ||       | j                  ||       | j                  ||       j                  r | xj                  j                  fz  c_	        j                  r | xj                  j                  fz  c_        j                  D ]?  }||vrt        j                  d|dd       t        ||         j                         A | j                  ||       j                   r1t#        fd| j$                  D              j                  fz   | _        j&                  r2t#        fd| j(                  D              j                  fz   | _        yy)	zadd 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.

        r{   zrevision %s not in mapr<   r|   r}   c              3     K   | ]7  }|t        j                        j                  j                  g      vr| 9 y wr&   )r   r   unionre   r   headre   s     r-   r   z+RevisionMap.add_revision.<locals>.<genexpr>  sF      %8778>>&&' %   =A c              3     K   | ]7  }|t        j                        j                  j                  g      vr| 9 y wr&   )r   r   r   re   r   s     r-   r   z+RevisionMap.add_revision.<locals>.<genexpr>  sF      8==>DD&&' r   N)rp   re   r   r   	Exceptionr   r   r   r   rt   r   ry   r   r   r   r   _is_real_headr   rv   is_headrI   )r'   re   _replacer   rX   r   s    `    r-   add_revisionzRevisionMap.add_revision  s    !!H--5II7(:K:KK (++474x7H7HHII"*XJ	9d+	40Y-JJ8,,..J!!!2!2 4433 	:Gd"		* T']#//9	: 	""9d3!!$ % ,,%   ""$ %D   JJ  ""$%DJ r/   Nc                    | j                   }|r| j                  ||      }t        |      dkD  rt        ||r	d|z        d      |r|d   S y)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   r   N)rI   filter_for_lineagelenrF   )r'   r   current_headss      r-   get_current_headzRevisionMap.get_current_head  sn    ( (,zz 33|M }!,8	L( >D 
  ##r/   c                :    | j                  | j                  |      S r&   )r   rt   )r'   
identifiers     r-   _get_base_revisionszRevisionMap._get_base_revisions  s    &&tzz:>>r/   c                    t        |t        t        t        t        f      r)t        |D cg c]  } j                  |       c}d      S  j                  |      \  }t        |      dk(  rQ	 t        |d         dk  r< j                  d      }t        fd|D              }t         fd|D              S 	 t         fd|D              S c c}w # t        $ r Y %w xY w)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.

        r   r   r   rI   c              3  P   K   | ]  }t        |      j                  v r|  y wr&   )is_revisionr   )r   r   r   s     r-   r   z,RevisionMap.get_revisions.<locals>.<genexpr>(  s0      1$(#/#.t#4#B#B$C !%1s   #&c              3  D   K   | ]  }j                  |         yw))stepsN)_walk)r   r   rintr'   s     r-   r   z,RevisionMap.get_revisions.<locals>.<genexpr>.  s&      % $ !JJt4J8%s    c              3  B   K   | ]  }j                  |        y wr&   )_revision_for_ident)r   rev_idr   r'   s     r-   r   z,RevisionMap.get_revisions.<locals>.<genexpr>5  s&       ((>s   )
isinstancer   r   r   	frozensetsumget_revisions_resolve_revision_numberr   int
ValueError)r'   id_id_elemresolved_idselect_headsr   r   s   `    @@r-   r   zRevisionMap.get_revisions	  s    ( cD%i893G**73GLL(,(E(Ec(J%K;1${1~.Dax'+'9'9''B'3+0 1,81 ,L  % %(4%     "  )  / H( " s   C0AC 	C&%C&c                    | j                  |      \  }}t        |      dkD  rt        ||      |r|d   nd}| j                  ||      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   r   r   )r   r   rF   r   )r'   r   r  r   resolveds        r-   get_revisionzRevisionMap.get_revision:  sS     %)$A$A#$F!\{aS11<G+a.R'',??r/   c                    	 | j                   |   }|S # t        $ r8 	 | j                  |      }|cY S # t        $ r}t        d|z  |      |d }~ww xY ww xY w)NzNo such branch: '%s')rp   KeyErrorr   rO   )r'   r   
branch_revnonbranch_revres        r-   _resolve_branchzRevisionMap._resolve_branchO  sy    	++L9J   		%% $ 8 8 F %$ # %*\9<		%s(    	A2A	AAAAc                   |r| j                  |      }nd }	 | j                  |   }|du r|sJ | j                  D cg c]%  }|r!t        |      dkD  r|j	                  |      r|' }}|r| j                  ||      }|s"t        d|dt        |      dk  rdnd|      t        |      dkD  r,t        d	|d
dj                  d |dd D              d|      | j                  |d      }|rM|K|J |sJ | j                  |j                  |j                        st        d|j                  d|d|      |S # t        $ r d}Y %w xY wc c}w )NF   zNo such revision or branch ''   z\; please ensure at least four characters are present for partial revision identifier matches r   zMultiple revisions start with 'z': rH   c              3  &   K   | ]	  }d |z    yw)z'%s'Nr   r   r   s     r-   r   z2RevisionMap._revision_for_ident.<locals>.<genexpr>  s     -LQfqj-Ls   r   z...r<   z is not a member of branch ')
r  rp   r  r   
startswithr   rO   rK   _shares_lineagere   )r'   r  check_branchr	  re   xrevss          r-   r   zRevisionMap._revision_for_ident_  s    --l;JJ	))+6H
 u; ++Q![(A D  ..t\B% $  #;/!3N "$$		    TQ% #DII-L$q)-L$LN  	   --d1g6H0)));''!!:#6#6 &((,8 
 e  	H	s   D> *E>EEc                    t        |      }t        |      D ]K  }|sJ |j                  | j                  |gd            j	                  |g      s;|j                  |       M |S r   )r   r   r   r   
differencer   )r'   targetsr   s      r-   _filter_into_branch_headsz%RevisionMap._filter_into_branch_heads  sp     g,= 	%CJ3##**C5u*Mj#  $	% r/   c                      j                  |      \  }}g |rj                  |       |rj                  |       t         fd|D              S )Nc              3  J   K   | ]  }j                  |       r|  yw)r   N)r  )r   tgr   r'   sharess     r-   r   z1RevisionMap.filter_for_lineage.<locals>.<genexpr>  s4      
##F1E $  
s    #)r   appendextendr   )r'   r  check_againstr   r   r   r   s   `  `  @r-   r   zRevisionMap.filter_for_lineage  sW     !99-H\MM,'MM# 

 
 	
r/   c                   |syt        |t              st        | j                  |            }n|}t	        j
                  |d      D cg c]%  }t        |t              s| j                  |      n|' }}t        t        | j                  |g|            j                  | j                  |g|            j                  |            S c c}w )NTr   defaultr   )r   r   r   r   r   r   r2   r   r   r   r   r   )r'   targettest_against_revsr   resolved_targettest_against_revresolved_test_against_revss          r-   r  zRevisionMap._shares_lineage  s     !&(+&t'?'?'GHO$O %)MM!2%	&
 ! ""2H= (()9:%&	&
" 	&
 **$%)= +  U(($%)= )  \45
 	
	&
s   
*Cc                   t        |t              rd|v r|j                  dd      \  }}nN|Jt        |t              r|rt        |d   t              rt        |t        t        f      st	        d|d      d }| j
                   |dk(  r.|r| j                  | j                  |      |fS | j                  |fS |dk(  r| j                  |      }|r|f|fS d|fS |d	k(  s|d|fS t        j                  |d 
      |fS )Nr    r   r   zrevision identifier z= is not a string; ensure database driver settings are correctrI   r   r   r=   r%  )r   rR   splitr   r8   rp   r   rI   rv   r   r   r   )r'   r   r   current_heads       r-   r   z$RevisionMap._resolve_revision_number  s    c3C3J #		#q 1L#_U#Js1vs4KcC<0147   L 	'>++DJJE  
 ''55F]00>L$44<''F]ck|##==d3\AAr/   c              #     K   |r| j                   }n| j                  } ||||||      \  }}	| j                  ||	      D ]  }
t        | j	                  |
               yw)au  Iterate 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_sortr   r  )r'   r(   r)   r+   r*   r,   select_for_downgradefnrX   rI   r   s              r-   iterate_revisionszRevisionMap.iterate_revisions  ss     *  22B00B'#9
	5 **9e< 	4D4,,T233	4s   A A"c                V    |rdfd}n|rdd}ndd}| j                  |||      S )Nc                <    | vr| j                   S | j                  S r&   )r   r   )r   r  s    r-   r4  z-RevisionMap._get_descendant_nodes.<locals>.fnC  s!    g%+++;;&r/   c                    | j                   S r&   r   r   s    r-   r4  z-RevisionMap._get_descendant_nodes.<locals>.fnK  s    '''r/   c                    | j                   S r&   r   r9  s    r-   r4  z-RevisionMap._get_descendant_nodes.<locals>.fnP  s    {{"r/   r   checkr   r   r3   zIterable[str]r   )r'   r  r   r<  omit_immediate_dependenciesr   r4  s    `     r-   r   z!RevisionMap._get_descendant_nodes9  s?     '' "(
# ..d% / 
 	
r/   c                B    |rdd}ndd}| j                  ||||      S )Nc                    | j                   S r&   )_normalized_down_revisionsr9  s    r-   r4  z+RevisionMap._get_ancestor_nodes.<locals>.fn`  s    555r/   c                    | j                   S r&   r   r9  s    r-   r4  z+RevisionMap._get_ancestor_nodes.<locals>.fne  s    444r/   r;  r=  r>  )r'   r  r   r<  r   r4  s         r-   r   zRevisionMap._get_ancestor_nodesW  s4      6
5 ..d% / 
 	
r/   c           
   #  x  K   || j                   }t               }t        j                         }|D ]  }t	        |      }|j                  |       |r
t               }	|r|j                         }
|r	j                  |
       |
|v r*|j                  |
        ||
      D ]6  }||   }|J |j                  |k7  rt        d      |j                  |       8 |
 |r|s	j                  |      j                  |g      }|st        d|j                  ddj                  d |D                     y w)Nz(Dependency resolution failed; broken mapzRequested revision z) overlaps with other requested revisions rH   c              3  4   K   | ]  }|j                     y wr&   r   r  s     r-   r   z9RevisionMap._iterate_related_revisions.<locals>.<genexpr>  s     %CQajj%Cr   )rp   r   collectionsdequer   r!  popr   re   r8   r   r  rK   )r'   r4  r  r   r<  seentodo
target_forr'  
per_targetr   r   next_revoverlapss                 r-   r   z&RevisionMap._iterate_related_revisionsl  sE     <%%Du + 1 1 3! $	J ,FKK U
hhjNN3'$; g *F#F|H#///((F2+F  KK)* 	# $ %227;FFH ' #OO II%C(%CC	 ;$	s   CD: D:##D:3D:c           	          j                   d fd|D ch c]  }|j                   }}t         j                         }t        t        |D ch c]  }|j                  |v s|j                   c}|j                              }|D cg c]
  } |       }}g }	d}
|r||
   }t        |      D ]  \  }}||
k7  s||v s|}
 n ||v r"|	j                  |       |j                  |       |   }|J |j                  D cg c]  }||v r||vr| }}|s||
= ||
= t        |
dz
  d      }
n|j                  s5t        |j                        dk(  r|d   ||
<   ||
   j                  |       nG|d   ||
<   |j                  |dd         |d         ||
<   |j                  fd|dd D               |r|rJ |	S c c}w c c}w c c}w c c}w )zYield 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                h    j                  |    g      D ch c]  }|j                   c}S c c}w r&   )r   re   )r   r   	id_to_revr'   s     r-   get_ancestorsz4RevisionMap._topological_sort.<locals>.get_ancestors  s<     119V3D2EF 

  s   /)keyr   Nr   c              3  .   K   | ]  } |        y wr&   r   )r   r   rR  s     r-   r   z0RevisionMap._topological_sort.<locals>.<genexpr>  s      048M$/0s   )r   rR   r3   Set[str])rp   re   r   r   index	enumerater!  removerB  maxr   r   r   r   r"  )r'   rX   rI   r   rJ  inserted_orderr   r   ancestors_by_idxoutputcurrent_candidate_idx	candidatecheck_head_index	ancestorscandidate_revr   heads_to_addrR  rQ  s   `                @@r-   r2  zRevisionMap._topological_sort  sS    &&		 %..q

.. d001%*AajjD.@A"((
 ANNfM&1NN !%&;<I/89I/J <+ ) %(==!Y.,<) < $MM),KK	* !*) 4$000 +EE DyQm%;     $%&;<()>?,/0E0I1,M) *KK G GHAM?KA&;< ))>?GG% @LA&;<%,,\!"-=>),q/: ))>? )// 0<H<L0 { B xe / B O< s   GG'GGGc                   t        |t              r| j                  |      }n|}t        t	        |            D ]  }|dkD  r^|dk7  sJ | j                  || j                  n|j                        D cg c]  }t        |       }}|r| j                  ||      }	n8|}	n5|dk(  rd}	n-| j                  || j                  n|j                        }	|	sd}	|	s
|rdn|}
|
c S t        |	      dkD  rt        d      |	d   } |S c c}w )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.
        r   r=   Nr   )r=   r   zAmbiguous walk)r   rR   r  rangeabsr   rt   r   r   r   rI   r   r   r8   )r'   startr   r   no_overwalkinitial_r   walk_upchildrenrets              r-   r   zRevisionMap._walk  s0   ( eS!''.GG s5z" !	"Aqy&(((  $11&-o

7??   $   #66wMH&H f$!H#11"? 

$22 H
 $#, *dw
X"#$455qkGC!	"F ?s   3Dc                ^   |yt        |t              sJ d       t        j                  |      }|r|j	                         \  }}}t        |      }|dk\  rA|t        d|t        |      fz        | j                  ||||      }	|	t        d      ||	fS |du }
|
r|rt        j                  |      }| j                  ||      }|sUt        t        t           | j                  |            }| j                  ||      }|D cg c]  }|r|j                   n| }}t#        |      dk(  sJ |d   }nct        j                  |      }|st        d|t        |      fz        t#        t%        |            dkD  rt        j&                  d	       |d   }|}| j                  || j)                  |      n| j)                  |d
|      ||      }	|	&|
rt        d|t        |      fz        t        d      ||	fS |j+                  d
      \  }}}|sd}|| j)                  |      fS c c}w )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)rg  zWalked too farr   zadowngrade -1 from multiple heads is ambiguous; this usage will be disallowed in a future release.r    rf  r   rg  )r   rR   _relative_destinationmatchgroupsr   r8   re  r   r   r   r   r   r   r   _get_all_currentre   r   r   r   r  
rpartition)r'   current_revisionsr'  r,   rr  r   symbolrelativerel_intr   relative_revisioncr_tuplesymbol_listall_currentsl_all_currentr   ri  s                    r-   _parse_downgrade_targetz#RevisionMap._parse_downgrade_targetE  s   $ >C
 	65	6 
 &++F3-2\\^*L&((mG!|>'03;S\2JK 
 jj  6	 !  ;'(899#S(($*dN!$##'==1B#C&*&=&=$l'  +
 +/ #Ht/D/DX/N+K .2-D-D +\.N
 *8+$% /0

Q 6+K +
  #;/1444!,Q,0MM:K,L)0"/!8#+S\":!;#  s#456: II!+ "31!5 (.jj (/ ))&1!..'3V< " 6 ! 
 ;(+47?W6NO 
 ,,<==#S(( #)"3"3C"8aLT..v666k+s   H*c           	        t        |t              rt        j                  |      }nd}|s| j	                  |      S t        j                  |      }|j                         \  }}}t        |      }	|	dkD  r||sd}|}
|r| j                  | j	                  |      |      }
|
s{| j                  | j                  | j	                  |            |      }t        |D ch c]  }|j                   c}|D ch c]  }|j                  D ]  }|  c}}z
        }
|
sd}
t        |
      dkD  rt        d      | j!                  |
d   |	||      }|t        d|t#        |	      fz        |fS | j!                  | j%                  |      |	||      fS |t        d|	t#        |	      fz        | j!                  || j%                  |      n| j%                  |d|      |	|	      fS c c}w c c}}w )
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.
        Nr   r&   r   z1Ambiguous upgrade from multiple current revisions)rf  r   r   rg  ro  r    rp  )r   rR   rq  rr  r   r   r   rs  r   r   r   r   re   rB  r   r8   r   re  r  )r'   rv  r'  r,   rr  current_revisions_tupr   rw  relative_strrx  
start_revsactive_on_branchr   downs                 r-   _parse_upgrade_targetz!RevisionMap._parse_upgrade_target  ss    fc")//7EE%%f-- !%.? @-2\\^*fl|$a<~,,3)2
!%!8!8**+@A$"J & ,0+B+B 44 $ 2 23H I )	,( &+5EFcS\\F ,<$',/,J,J %) !% $&
  * *1Jz?Q&'K  jj$Q-"!- 6	 !  ;'03?X2OP  v JJ"//7&%1$:	    ~#,/7X.GH 
 

 (/ ))&1!..'3V< # 6  
 [ Gs   G)6G.c                    | j                  |||      \  }}|dk(  rd}|t        |t              sJ |6| j                  j	                         D cg c]  }||j
                  | }	}n7|r|g}	n1| j                  |j                        D cg c]  }t        |       }	}|rt        |	      dkD  r| j                  | j                  |      gd      D ch c]  }|j                   }
}| j                  |	D ch c]  }|j                   c}j                  |
            D cg c]  }t        |       }	}t        |	      dk(  rt        d      | j                  |      }t        | j!                  |	d	d
            }t        | j                  |d	            }|j#                  |       |r/|j%                  |j'                  | j                  |	                   ||s||vrt)        d|      ||fS c c}w c c}w c c}w c c}w c c}w )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
        rv  r'  r,   r=   Nr   Fr   r   z/Not a valid downgrade target from current headsT)r   r?  zNothing to drop)r  r   r   rp   r   r   r   r   r   r   r   r  re   r   r8   r   r   intersection_updater   r  r:   )r'   r(   r)   r*   r+   r,   r   target_revisionr   rootsr`  rI   downgrade_revisionsactive_revisionss                 r-   r0  z(RevisionMap._collect_downgrade_revisions+  sq     )-(D(D##9 )E )
%o
 f$"O&*_h*OOO "  --446?s'8'8'@ E 
 $%E
  --o.E.EF C E 
 CJN  33)),78). 4  I   ---23cS\\3@@K C E  5zQ#E  ""5) "&&%),1 ' 
 $$U$F

 	//0@A&& ++D,D,DU,KL
 ''u, ((95AA"E))Q 4s   G7G<H;H&Hc                   | j                  |||      D cg c]  }t        |       }}t        |t              rd|v r|j	                  d      \  }}	}	| j                  |      }
|
G|
j                  |k(  r8t        |
j                        dk(  sJ t        t        |
j                              }|D ch c]  }||j                  v s| }}t        | j                  |dd            j                  |      | j                  |      }|s t        fd|D              rt!        ||      t#        |      t$        u sJ d       |rA|d	   <| j'                  |||      \  }	}|sJ |d
k(  rt%               }d}n|f}|j                  }t        | j                  |dd            j                  |      }j)                  |      }|r'|j+                  d | j                  |      D               |r>|s<| j-                  |D cg c]  }t        |       c}dd      }|j/                  |       |t%        |      fS c c}w c c}w c c}w )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.
        r  r    Nr   T)r<  r   c              3  *   K   | ]
  }||v  y wr&   r   )r   r   required_node_sets     r-   r   z9RevisionMap._collect_upgrade_revisions.<locals>.<genexpr>  s$      %
 ((%
s   z#current_revisions should be a tupler   r=   c              3  2   K   | ]  }t        |        y wr&   )r   r   s     r-   r   z9RevisionMap._collect_upgrade_revisions.<locals>.<genexpr>  s     OcS)Os   F)r  r   r   rR   	partitionr  re   r   r   nextiterr   r   r   r   anyr:   typer   r  r  r   r   r  )r'   r(   r)   r*   r+   r,   r   r  branchri  r	  needrv  current_node_setneedslower_descendentsr  s                   @r-   r1  z&RevisionMap._collect_upgrade_revisions  s   * 11"''= 2 )
 )
 )
 eS!cUl ??3/LFAq**62J%**=*=*G:334999d:#;#;<=!(Fd6H6H,HG   $$t$ % 
 %.	 	 !..u5 %
(%
 "

 (u55"#u,	10	1,
 !21!5!=11"''= 2 FAs
 J3f}$)G!%(F!$$!D % 
 %!
"	 	 ",,-=> LLOT5G5G5NOO
 ] $ : :->?cS!?%* !; !
 %%&78eGn$$a)
(l @s   H:3H?H? Ic                    t        | j                  |            }|j                  | j                  t	        |      d             | j                  |      S )NTr   )r   r   r   r   r   r  )r'   r   top_revss      r-   rt  zRevisionMap._get_all_current  sO     t))#./$$T(^$$O	
 --h77r/   )rn   z Callable[[], Iterable[Revision]]r3   rA   r3   Tuple[str, ...])r3   r   )r   _InterimRevisionMapTyperI   Set[Revision]rt   Tuple[Revision, ...]rv   r  ry   r  r3   rA   )rX   Collection[Revision]r   r   r3   rA   )F)re   r   r   r2   r3   rA   r&   )r   rM   r3   rM   )r   rR   r3   r  )r   Optional[_GetRevArg]r3   %Tuple[Optional[_RevisionOrBase], ...])r   rM   r3   Optional[Revision])r   rR   r3   r  )r  zUnion[str, Tuple[()], None]r  rM   r3   r  )r  z#Iterable[Optional[_RevisionOrBase]]r3   Set[Optional[_RevisionOrBase]])r  zIterable[_TR]r#  rM   r   r2   r3   zTuple[_TR, ...])r'  zOptional[_RevisionOrStr]r(  zSequence[_RevisionOrStr]r   r2   r3   r2   )r   r  r3   z%Tuple[Tuple[str, ...], Optional[str]])FFTF)r(   r1   r)   r1   r+   r2   r*   r2   r,   r2   r3  r2   r3   Iterator[Revision])NFFT)r  %Collection[Optional[_RevisionOrBase]]r   Optional[_RevisionMapType]r<  r2   r?  r2   r   r2   r3   zIterator[Any])NFT)
r  r  r   r  r<  r2   r   r2   r3   r  )
r4  z#Callable[[Revision], Iterable[str]]r  r  r   r  r<  r2   r3   r  )rX   r  rI   r   r3   z	List[str])NT)
rf  zOptional[Union[str, Revision]]r   r   r   rM   rg  r2   r3   zOptional[_RevisionOrBase])rv  r1   r'  r1   r,   r2   r3   z/Tuple[Optional[str], Optional[_RevisionOrBase]])rv  r1   r'  r1   r,   r2   r3   r  r0   )r(   r1   r)   r1   r*   r2   r+   r2   r,   r2   r3   z*Tuple[Set[Revision], Tuple[Revision, ...]])r   r  r3   r  )'r4   r5   r6   __doc__r?   r   memoized_propertyrI   rt   rv   ry   rp   r   r   r   r   r   r   r   r   r   r  r  r   r  r   r  r   r5  r   r   r   r2  r   r  r  r0  r1  rt  r   r/   r-   rk   rk   ~   s   $ 

 
 

 
 
    
    
I IV2@(2@ 2@ $	2@
 #2@ *2@ 
2@h2-25E2	2*-5E	.5-55E5	5.&@-&@5E&@	&@P6%r -1")"	"H?/'/	./b@*& '+@0@ $@ 
	@D:	'" &+	

 %
 #	

 

4 &+	&
(&
 4&
 #	&

 
&
P&B'&B	.&BX $'+%*#4&#4 '#4 	#4
 #4 !%#4 ##4 
#4P ,0,1%)
6
 )
 	

 &*
 #
 

B ,0%)
6
 )
 	

 #
 

4 0/0 70 )	0
 0 
0df'f f 
	fX '+ =-= = $	=
 = 
#=~v72v7 (v7 !%	v7
 
9v7pl2l (l !%	l
 
/l\e*&e* 'e* 	e*
 e* !%e* 
Ee*Nc%&c% 'c% 	c%
 c% !%c% 
4c%J8"8	'8r/   rk   c                     e Zd ZU dZ e       Zded<   	  e       Zded<   dZded<   	 dZ	ded	<   	 dZ
ded
<   	 dZded<   	 ded<   ded<   edd       Z	 	 d	 	 	 	 	 	 	 	 	 d dZd!dZd"dZed#d       Zed#d       Zed#d       Zed$d       Zed$d       Zed$d       Zed$d       Zed$d       Zed$d       Zed$d       Zy)%r   ao  Base 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.

    zFrozenSet[str]r   r   NrR   re   zOptional[_RevIdType]r   r   rU  r   r  r   r   c                    t        |      j                  t              }|r*t        ddj	                  t        |            d|d      y )NzCharacter(s) 'rH   z&' not allowed in revision identifier 'r  )r   r   _revision_illegal_charsr8   rK   r   )clsre   illegal_charss      r-   verify_rev_idzRevision.verify_rev_id.  sD    H223JK99VM23X?  r/   c                   |r"|t        j                  |      v rt        |      |"|t        j                  |      v rt        |      | j	                  |       || _        t        t        j                  |            | _        t        t        j                  |            | _        t        j                  |d      | _	        t        | j                        | _        y Nr   r%  )r   r   rb   rh   r  re   tuple_rev_as_scalarr   r   r   r   r   )r'   re   r   r   r   s        r-   r?   zRevision.__init__7  s     X})EEx((%(dmm7
 +
 )228$ 0}1MN/l0KL#'==#K  !9!9:r/   c                T   t        | j                        t        | j                        g}| j                  r|j	                  d| j                         | j
                  r|j	                  d| j
                         | j                  j                  ddj                  |      dS )Nzdependencies=zbranch_labels=(rH   rW   )	reprre   r   r   r!  r   r@   r4   rK   )r'   argss     r-   __repr__zRevision.__repr__L  sy    T]]#T$*<*<%=>KKT->->@AKKd.@.@BC>>22DIIdODDr/   c                    | j                   j                  |j                  g      | _         | j                  |j                  v r,| j                  j                  |j                  g      | _        y y r&   )r   r   re   r   r   )r'   re   s     r-   r   zRevision.add_nextrevT  sZ     --33X5F5F4GH==H>>><<--x/@/@.ABDL ?r/   c                    t        j                  t        j                  | j                  d      | j                  z         S r  )r   dedupe_tupler   r   r   rq   s    r-   r   zRevision._all_down_revisionsY  s7      MM$,,b9))*
 	
r/   c                    t        j                  t        j                  | j                  d      | j                  z         S )z|return immediate down revisions for a rev, omitting dependencies
        that are still dependencies of ancestors.

        r   r%  )r   r  r   r   r   rq   s    r-   rB  z#Revision._normalized_down_revisions`  s9       MM$,,b9445
 	
r/   c                D    t        j                  | j                  d      S r  )r   r   r   rq   s    r-   r   z"Revision._versioned_down_revisionsk  s    }}T//<<r/   c                .    t        | j                         S )a  Return 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.

        )r2   r   rq   s    r-   r   zRevision.is_heado  s     %%%r/   c                .    t        | j                         S r&   )r2   r   rq   s    r-   r   zRevision._is_real_headz  s    ))***r/   c                    | j                   du S )z<Return True if this :class:`.Revision` is a 'base' revision.N)r   rq   s    r-   r   zRevision.is_base~  s     !!T))r/   c                >    | j                   du xr | j                  du S )zrReturn True if this :class:`.Revision` is a "real" base revision,
        e.g. that it has no dependencies either.N)r   r   rq   s    r-   r   zRevision._is_real_base  s%     !!T)Gd.?.?4.GGr/   c                2    t        | j                        dkD  S )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   rq   s    r-   is_branch_pointzRevision.is_branch_point  s     4<< 1$$r/   c                2    t        | j                        dkD  S )zzReturn True if this :class:`.Script` is a 'real' branch point,
        taking into account dependencies as well.

        r   )r   r   rq   s    r-   r   zRevision._is_real_branch_point  s     4$$%))r/   c                2    t        | j                        dkD  S )z6Return True if this :class:`.Script` is a merge point.r   )r   r   rq   s    r-   r   zRevision.is_merge_point  s     4112Q66r/   rf   rn  )
re   rR   r   %Optional[Union[str, Tuple[str, ...]]]r   r  r   r  r3   rA   )r3   rR   )re   r   r3   rA   r  )r3   r2   )r4   r5   r6   r  r   r   __annotations__r   re   r   r   r   classmethodr  r?   r  r   propertyr   rB  r   r   r   r   r   r  r   r   r   r/   r-   r   r     s    (kG^);#,;L..Hc%*.M'. *.L&- #M8" ,+'66  ?C?C;; =; <	;
 =; 
;*EC
 
 
 
 
 = = & & + + * *
 H H 	% 	% * * 7 7r/   c                     y r&   r   r9  s    r-   r  r    s    ,/r/   c                     y r&   r   r9  s    r-   r  r    s     +.r/   c                2    | sy t        |       dk(  r| d   S | S )Nr   r   )r   r9  s    r-   r  r    s#     	SQ1v
r/   c                *    t        | t              sJ | S r&   )r   r   r9  s    r-   r   r     s    c8$$$Jr/   )r   rA   r3   rA   )r   zUnion[Tuple[_T, ...], List[_T]]r3   z#Union[_T, Tuple[_T, ...], List[_T]])r   zOptional[Sequence[_T]]r3   zUnion[_T, Sequence[_T], None])r   r   r3   r   )9
__future__r   rF  r  typingr   r   r   r   r   r	   r
   r   r   r   r   r   r   r   r   r   r   r   r   
sqlalchemyr   r   r  r   r   rR   
_RevIdType
_GetRevArgr1   _RevisionOrStr_RevisionOrBaser  r   r   r   compilerq  r  r$   r   r8   r:   rF   rO   rT   r^   rb   rh   rk   r   r  r   r   r/   r-   <module>r     s   "  	                     '  3S	5c?23
Xc]SM

  U38_d :; z3'56sJ/ dCr23Xj5IIJ T]e8N34"

#DE ) J J	I 		
M 	

M 
!m !
M 
$m $%= %#4l #A8 A8H,d7 d7N 
 / 
 / 
.	(.(. 
.
	"r/   