bgBddlmZddlmZddlmZddlZddlZddlmZddlm Z ddlm Z ddlm Z dd lm Z dd lm Z dd lmZdd lmZdd lmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZ ddl!m"Z"ddl#m$Z$ddl#m%Z%ddl%m&Z&dd l'm(Z(erNdd!lm)Z)dd"lm*Z*dd#l+m,Z,dd$l+m-Z-dd%l.m/Z/dd&l0m1Z1d'd(l2m3Z3dd)l4m5Z5dd*l6m7Z7dd+l6m8Z8dd,l9m:Z:dd-l9m;Z;dd.l9mZ?Gd/d0Z@Gd1d2ZAGd3d4ZBGd5d6ZCGd7d8ZDGd9d:eDZEGd;dr8ts r9rBz_ProxyTransaction.rollback@s1  %}}} .2+++r;c\|j}|J|d|j_dSr7)r@commitr2r>rCs r9rFz_ProxyTransaction.commitFs1  %}}}  .2+++r;c|Sr7r?s r9 __enter__z_ProxyTransaction.__enter__Ls r;type_rvalue tracebackch|j*|j|||d|j_dSdSr7)r@__exit__r2r>)r8rJrKrLs r9rNz_ProxyTransaction.__exit__Os?  $ 0  % . .ueY G G G26D " / / / 1 0r;N)r2r3r4r5)r4r<)r4r5)r4r1)rJrrKrrLrr4r5) __name__ __module__ __qualname__r:propertyr@rBrFrIrNrHr;r9r1r18s3333333X33333 3333 777777r;r1ceZdZdZ d?d@d Ze dAdBdZedCdZ dDdEdZ dFdZ dGd Z dDdHd"Z dId#Z dJd(ZdKd+ZdId,Z d?dLd1ZdMd3ZedNd4ZedOd6ZdPd;ZdQd>ZdS)Rr3aRepresent the database state made available to a migration script. :class:`.MigrationContext` is the front end to an actual database connection, or alternatively a string output stream given a particular database dialect, from an Alembic perspective. When inside the ``env.py`` script, the :class:`.MigrationContext` is available via the :meth:`.EnvironmentContext.get_context` method, which is available at ``alembic.context``:: # from within env.py script from alembic import context migration_context = context.get_context() For usage outside of an ``env.py`` script, such as for utility routines that want to check the current version in the database, the :meth:`.MigrationContext.configure` method to create new :class:`.MigrationContext` objects. For example, to get at the current revision in the database using :meth:`.MigrationContext.get_current_revision`:: # in any application, outside of an env.py script from alembic.migration import MigrationContext from sqlalchemy import create_engine engine = create_engine("postgresql://mydatabase") conn = engine.connect() context = MigrationContext.configure(conn) current_rev = context.get_current_revision() The above context can also be used to produce Alembic migration operations with an :class:`.Operations` instance:: # in any application, outside of the normal Alembic environment from alembic.operations import Operations op = Operations(context) op.alter_column("mytable", "somecolumn", nullable=True) Ndialectr" connectionOptional[Connection]optsDict[str, Any]environment_contextOptional[EnvironmentContext]r4r5c ||_||_||_|d|_|dd}|d}|dd|_|dd|_d|_|rDttd| ||_ |j Jd|_ n ||_ tj||_ |d |_||_|d d|_d |vr;t%|d p t&j|d |_n%|d t&j|_|d d|_|dd|_|ddx|_}|ddx|_}t5|t7t9dt;dd||_|ddr,|jtAdd|z|d|_!tEj#$|||j |j||j||_%tL'd|j%j(j)|jrtL'dtL'd|j%j*rdnddS) Nscriptas_sqlFtransactional_ddltransaction_per_migrationon_version_applyrHr$fnpurgeoutput_encoding output_buffer compare_typecompare_server_default version_tablealembic_versionversion_table_schema version_num )nullable)schemaversion_table_pkTz%s_pkc)name starting_revzContext impl %s.zGenerating static SQLzWill assume %s DDL. transactionalznon-transactional)+rYrWrTgetr\_transaction_per_migrationon_version_apply_callbacksr>rr_stdout_connectionrU_in_external_transactionr _get_connection_in_transaction_migrations_fnr]rbr!sysstdoutrd_user_compare_type_user_compare_server_defaultrgrirrrr_versionappend_constraintr_start_from_revr DefaultImplget_by_dialectimplloginfo __class__rOr^) r8rTrUrWrYr]r^rgris r9r:zMigrationContext.__init__sT$7   15(1C1C xx%00 HH%899*.(( '+ + '+/((3Er*J*J'37  "&(?(? (K(KDO?...,1D ) )(DO::FF  ) HHTNN  XXgu--  $ $!*)):&'""D   "&/3:!F!FD "&((>5"A"A,0HH $e- - ).2XX .. .  ]<@88 "D< <  !$8  JJ =&**u = = ='     88& - -  M + +$!=(@    /3hh~.F.FO227;;  O K         #TY%8%ABBB ; . HH, - - -  !y* %OO$      r;rOptional[Union[str, URL]] dialect_name Optional[str]Optional[Dialect] dialect_optsOptional[Dict[str, str]] Optional[Any]c|i}|i}|r4t|trtjd|z|j}nv|r/t j|}|di|}nE|r2t jd|z}|di|}n|std|Jt||||S)aCreate a new :class:`.MigrationContext`. This is a factory method usually called by :meth:`.EnvironmentContext.configure`. :param connection: a :class:`~sqlalchemy.engine.Connection` to use for SQL execution in "online" mode. When present, is also used to determine the type of dialect in use. :param url: a string database url, or a :class:`sqlalchemy.engine.url.URL` object. The type of dialect to be used will be derived from this if ``connection`` is not passed. :param dialect_name: string name of a dialect, such as "postgresql", "mssql", etc. The type of dialect to be used will be derived from this if ``connection`` and ``url`` are not passed. :param opts: dictionary of options. Most other options accepted by :meth:`.EnvironmentContext.configure` are passed via this dictionary. Nzf'connection' argument to configure() is expected to be a sqlalchemy.engine.Connection instance, got %rz%s://z-Connection, url, or dialect_name is required.rH) isinstancerr CommandErrorrTsqla_urlmake_url get_dialect Exceptionr3) clsrUrrrTrYrrWurl_objs r9 configurezMigrationContext.configures> <D  L  M*f-- ')* !(GG  M',,G+g))++;;l;;GG  M',(>??G+g))++;;l;;GG MKLL L"""T;NOOOr;Iterator[None]c#K|}|jjr!|jr|jn+|r)|jJ|jd|_|jsj|jJ|j}|j}| dx|_|j_|j }nd} dV|jsM|jJ|||j ||x|_|j_|jjr"|jr|j dS|r)|jJ|j |_dSdS#|jsM|jJ|||j ||x|_|j_|jjr!|jr|j n)|r'|jJ|j |_wxYw)amEnter an "autocommit" block, for databases that support AUTOCOMMIT isolation levels. This special directive is intended to support the occasional database DDL or system operation that specifically has to be run outside of any kind of transaction block. The PostgreSQL database platform is the most common target for this style of operation, as many of its DDL operations must be run outside of transaction blocks, even though the database overall supports transactional DDL. The method is used as a context manager within a migration script, by calling on :meth:`.Operations.get_context` to retrieve the :class:`.MigrationContext`, then invoking :meth:`.MigrationContext.autocommit_block` using the ``with:`` statement:: def upgrade(): with op.get_context().autocommit_block(): op.execute("ALTER TYPE mood ADD VALUE 'soso'") Above, a PostgreSQL "ALTER TYPE..ADD VALUE" directive is emitted, which must be run outside of a transaction block at the database level. The :meth:`.MigrationContext.autocommit_block` method makes use of the SQLAlchemy ``AUTOCOMMIT`` isolation level setting, which against the psycogp2 DBAPI corresponds to the ``connection.autocommit`` setting, to ensure that the database driver is not inside of a DBAPI level transaction block. .. warning:: As is necessary, **the database transaction preceding the block is unconditionally committed**. This means that the run of migrations preceding the operation will be committed, before the overall migration operation is complete. It is recommended that when an application includes migrations with "autocommit" blocks, that :paramref:`.EnvironmentContext.transaction_per_migration` be used so that the calling environment is tuned to expect short per-file migrations whether or not one of them has an autocommit block. .. versionadded:: 1.2.0 N AUTOCOMMIT)isolation_level) _in_connection_transactionrr^r] emit_commitr>rFrUget_isolation_levelexecution_optionsbegin emit_begin)r8r current_levelbase_connection fake_transs r9autocommit_blockz!MigrationContext.autocommit_blocks^&*%D%D%F%F" 9 & %4; % I ! ! # # # # ' %$000   $ $ & & & $D { ?... O??AAM"oO 11,1OO PDO $ 150E0E0G0GJJJ < EEE; I222)%%'''11$12:IH$)"6y* .begin_commits> $$&&& %%'''''r;) rvrrr^rsr]r>rUr "_safe_begin_connection_transactionr1r)r8rtransaction_nowin_transactionrs` r9begin_transactionz"MigrationContext.begin_transactionwsNX  ( !== 9 & 5,0OOOO,4O. +== ,+ +! ! !>{ 3"}}$"&!2$!>! 3&==(?666#F O% -T222 [ +  ( ( ( (^ (  <>> !?... + N!!D %T** *r;c|}t|dkrdSt|dkrtjd|jz|dS)aReturn the current revision, usually that which is present in the ``alembic_version`` table in the database. This method intends to be used only for a migration stream that does not contain unmerged branches in the target database; if there are multiple branches present, an exception is raised. The :meth:`.MigrationContext.get_current_heads` should be preferred over this method going forward in order to be compatible with branch migration support. If this :class:`.MigrationContext` was configured in "offline" mode, that is with ``as_sql=True``, the ``starting_rev`` parameter is returned instead, if any. rNr(zQVersion table '%s' has more than one head present; please use get_current_heads())get_current_headslenrrrgr8headss r9get_current_revisionz%MigrationContext.get_current_revisionsi &&(( u::??4 ZZ!^^#1373EF  8Or;Tuple[str, ...]cjrOj}|dkrd}n)|'jr fdtj|D}tj|dSjrtjdsdSjJtdj j DS)aReturn a tuple of the current 'head versions' that are represented in the target database. For a migration stream without branches, this will be a single value, synonymous with that of :meth:`.MigrationContext.get_current_revision`. However when multiple unmerged branches exist within the target database, the returned tuple will contain a value for each head. If this :class:`.MigrationContext` was configured in "offline" mode, that is with ``as_sql=True``, the ``starting_rev`` parameter is returned in a one-length tuple. If no version table is present, or if there are no revisions present, an empty tuple is returned. baseNcrg|]3}|dvtdj|j4S))Nrr+)rr\ get_revisionrevision).0sfrr8s r9 z6MigrationContext.get_current_heads..sK""".004;#;#;C#@#@AAJ000r;rHdefaultzECan't specify current_rev to context when using a database connectionc3&K|] }|dV dS)rNrH)rrows r9 z5MigrationContext.get_current_heads..s7  CF      r;) r]rr\rto_listto_tupler_has_version_tablerUtupleexecuter}select)r8start_from_revs` r9rz"MigrationContext.get_current_headss$ ; "&"6N''!%+ +""""#|N;;""" =<<< <# '7**,, r***  "o55dm6J6J6L6LMM      r;rbc6tj|j5|jJ|j|jd|r:|jJ|j|jddddS#1swxYwYdS)NT) checkfirst)r _ensure_scope_for_ddlrUr}createrdelete)r8rbs r9_ensure_version_tablez&MigrationContext._ensure_version_table!s  .t ? ? @ @?... M T B B B @222'' (<(<(>(>???  @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @sA'BBBc^|jJtj|j|j|jSr7)rUr _connectable_has_tablergrir?s r9rz#MigrationContext._has_version_table)s4***1 OT/1J   r;script_directoryr,rstrc|}|js|s|t||}|||D]}||dS)a\Stamp the version table with a specific revision. This method calculates those branches to which the given revision can apply, and updates those branches as though they were migrated towards that revision (either up or down). If no current branches include the revision, it is added as a new branch head. N)rr]rHeadMaintainer _stamp_revsupdate_to_step)r8rrrhead_maintainersteps r9stampzMigrationContext.stamp/s&&(({ )5 )  & & ( ( ((u55$005AA 1 1D  * *4 0 0 0 0 1 1r;kwrc |j|jr4|jrt jd|dd}nN|}|j dd}|js|s|s|t||}|j J| ||D]}| d5|jr/|j s(|jJ|j|jt"d ||jr"|jd |j|jdi||||jD](}|||jt1|j | ) dddn #1swxYwY|jr1|j s,|jJ|j|jdSdSdS) a-Run the migration scripts established for this :class:`.MigrationContext`, if any. The commands in :mod:`alembic.command` will set up a function that is ultimately passed to the :class:`.MigrationContext` as the ``fn`` argument. This function represents the "work" that will be done when :meth:`.MigrationContext.run_migrations` is called, typically from within the ``env.py`` script of the migration environment. The "work function" then provides an iterable of version callables and other version information which in the case of the ``upgrade`` or ``downgrade`` commands are the list of version scripts to invoke. Other commands yield nothing, in the case that a command wants to run some other operation against the database such as the ``current`` or ``stamp`` commands. :param \**kw: keyword arguments here will be passed to each migration callable, that is the ``upgrade()`` or ``downgrade()`` method within revision scripts. z!Can't use --purge with --sql modeT)rbrH dont_mutateFN)rz Running %sz -- Running )ctxrrrun_args)rstart_migrationsrbr]rrrrrWrrrrxrrrUr}rrr static_output short_log migration_fnrrtsetdrop)r8rrrrrcallbacks r9run_migrationszMigrationContext.run_migrations?s* ""$$$ : -{ M'(KLLL  & &T & 2 2 2EE**,,E)-- u==K; -u -[ -**,,,(u55"...''t44  D''t'<<  ;:'<: ?666M((999t,,,;I++++/>>;"!''B''' ..t444 $ ?HH !Y!/"788!# )               8 ; 04 0?... M  t / / / / / 0 0 0 0s*C GG G cR |jj}|S#t$rYdSwxYwNF)rUrAttributeError)r8meths r9rz+MigrationContext._in_connection_transactionsB ?1D466M   55 s  &&sqlUnion[ClauseElement, str]rOptional[dict]c<|j||dS)aExecute a SQL construct or string statement. The underlying execution mechanics are used, that is if this is "offline mode" the SQL is written to the output buffer, otherwise the SQL is emitted on the current SQLAlchemy connection. Nr_exec)r8rrs r9rzMigrationContext.executes! ./////r;r&cBfd}tjj|S)Nc<j|dSr7r) construct multiparamsparamsr8s r9dumpz1MigrationContext._stdout_connection..dumps IOOI & & & & &r;)rr&rT)r8rUrs` r9ruz#MigrationContext._stdout_connections3 ' ' ' ' '"0tDDDr;c|jS)aReturn the current "bind". In online mode, this is an instance of :class:`sqlalchemy.engine.Connection`, and is suitable for ad-hoc execution of any kind of usage described in SQLAlchemy Core documentation as well as for usage with the :meth:`sqlalchemy.schema.Table.create` and :meth:`sqlalchemy.schema.MetaData.create_all` methods of :class:`~sqlalchemy.schema.Table`, :class:`~sqlalchemy.schema.MetaData`. Note that when "standard output" mode is enabled, this bind will be a "mock" connection handler that cannot return results and is only appropriate for a very limited subset of commands. )rUr?s r9bindzMigrationContext.binds &r;Optional[Config]c,|jr |jjSdS)zLReturn the :class:`.Config` used by the current environment, if any.N)rYconfigr?s r9rzMigrationContext.configs  # +2 24r;inspector_column Column[Any]metadata_columnrc|jdurdSt|jr'|||||j|j}||S|j||Sr)r{callabletyperre)r8rr user_values r9 _compare_typezMigrationContext._compare_types{  "e + +5 D+ , , "00  %$ J%!!y%%&6HHHr;rendered_metadata_defaultrendered_column_defaultc|jdurdSt|jr#||||||j|}||S|j||||Sr)r|rserver_defaultrrf)r8rrrrrs r9_compare_server_defaultz(MigrationContext._compare_server_defaults  , 5 55 D5 6 6 ":: '.) J%!!y//   % #    r;r7) rTr"rUrVrWrXrYrZr4r5)NNNNNNN)rUrVrrrrrTrrYrZrrrWrr4r3)r4r)F)rrr4r)r4rr4r)rbrr4r5r4r)rr,rrr4r5rrr4r5)rrrrr4r5)rUrVr4r&)r4rV)r4r)rrrrr4r) rrrrrrrrr4r)rOrPrQ__doc__r: classmethodrrrrrrrrrrrrrurRrrrr rHr;r9r3r3Us --h=A W W W W W r,0)-&*%)<@15"5P5P5P5P[5Pn]<]<]<^]<@&+b+b+b+b+b+H6) ) ) ) V@@@@@    1111 G0G0G0G0R-1 0 0 0 0 0EEEEX(XIIII&      r;r3c6eZdZddZdd Zdd ZddZddZdS)rcontextr3rrr4r5c<||_t||_dSr7)rrr)r8rrs r9r:zHeadMaintainer.__init__s ZZ r;versionrc||jvsJ|j||jj|jjtd|zdS)N'%s'rj) raddrrrr}insertvaluesr)r8rs r9_insert_versionzHeadMaintainer._insert_versionsdj(((( w  L ! ( ( * * 1 1*6G+;<< 2       r;c |j||jj|jj|jjjj td|zk}|jj sG|jj j r8|8|jdkr/tjd||jj|jfzdSdSdSdS)Nrr(zOOnline migration expected to match one row when deleting '%s' in '%s'; %d found)rremoverrrr}rwherecrjrr]rTsupports_sane_rowcountrowcountrrrg)r8rrets r9_delete_versionzHeadMaintainer._delete_versions '"""l%% L ! ( ( * * 0 0 %'3!&7"2334     #  $;  !!#DL6 EF      !!r;from_to_c l||jvsJ|j||j||jj|jjtd|z |jjj j td|zk}|jj sH|jjjr9|9|jdkr0t#jd|||jj|jfzdSdSdSdS)Nrrr(zWOnline migration expected to match one row when updating '%s' to '%s' in '%s'; %d found)rrrrrrr}updaterrrrrjr]rTrrrrrg)r8r"r#r s r9_update_versionzHeadMaintainer._update_versionsB$*$$$$ %    sl%% L ! ( ( * * Vv| < r@)r8rAr<r=rBrDs r9r:zMigrationInfo.__init__sv)$  #}\2FFF   '"&"6q"9D   #'D !%~r!J!J!Jr;c|j S)aTrue/False: indicates whether this operation is a migration. At present this is true if and only the migration is not a stamp. If other operation types are added in the future, both this attribute and :attr:`~.MigrationInfo.is_stamp` will be false. )r=r?s r9 is_migrationzMigrationInfo.is_migrations=  r;c,|jr|jn|jS)z7Active revisions before this migration step is applied.)r<r@r?r?s r9source_revision_idsz!MigrationInfo.source_revision_idss'+o OD " "4;O r;c,|jr|jn|jS)z6Active revisions after this migration step is applied.)r<r?r@r?s r9destination_revision_idsz&MigrationInfo.destination_revision_idss%)O OD 9O r;Optional[Revision]c@|j|jS)zUGet :attr:`~.MigrationInfo.up_revision_id` as a :class:`.Revision`. )rArr>r?s r9 up_revisionzMigrationInfo.up_revisions  --d.ABBBr;%Tuple[Optional[_RevisionOrBase], ...]c@|j|jS)zLGet :attr:`~.MigrationInfo.up_revision_ids` as a :class:`.Revision`.)rA get_revisionsr?r?s r9rBzMigrationInfo.up_revisionss ..t/CDDDr;c@|j|jS)zcGet :attr:`~.MigrationInfo.down_revision_ids` as a tuple of :class:`Revisions <.Revision>`.)rArQr@r?s r9rDzMigrationInfo.down_revisionss ..t/EFFFr;c@|j|jS)zdGet :attr:`~MigrationInfo.source_revision_ids` as a tuple of :class:`Revisions <.Revision>`.)rArQrIr?s r9source_revisionszMigrationInfo.source_revisionss ..t/GHHHr;c@|j|jS)ziGet :attr:`~MigrationInfo.destination_revision_ids` as a tuple of :class:`Revisions <.Revision>`.)rArQrKr?s r9destination_revisionsz#MigrationInfo.destination_revisionss ..t/LMMMr;N) rAr/r<rr=rrBrCrDrCr4r5r r )r4rL)r4rO)rOrPrQr __annotations__r:rRrGrIrKrNrBrDrTrVrHr;r9r;r;gsNNN6"!!! %$$$'&&&AKKKK*!!!X!   X    X CCCXCEEEXE GGGXG IIIXI NNNXNNNr;r;ceZdZUded<ded<ded<ded<edd ZeddZeddZeddZ eddZ dZ dS) MigrationSteprfrom_revisions_no_depsto_revisions_no_depsrr<rrr4rc|jjSr7)rrOr?s r9rozMigrationStep.names ))r;rAr/r\r+ RevisionStepc$t||dS)NTr]rrAr\s r9upgrade_from_scriptz!MigrationStep.upgrade_from_scriptsL&$777r;c$t||dSrr_r`s r9downgrade_from_scriptz#MigrationStep.downgrade_from_scriptsL&%888r;c|j Sr7)r<r?s r9 is_downgradezMigrationStep.is_downgrades ?""r;c||jdtj|jdtj|jS)N  -> )rorformat_as_commarZr[r?s r9rzMigrationStep.short_logsB III  !< = = = =  !: ; ; ;  r;c|jrE|jdtj|jdtj|jd|jS|jS)Nrgrhz, )docrorrirZr[rr?s r9__str__zMigrationStep.__str__ s^ 8 " $T%@AAAA$T%>????  > !r;Nr4r)rAr/r\r+r4r]r ) rOrPrQrWrRrorrarcrerrlrHr;r9rYrYs++++)))) ***X*888[8 999[9 ###X#   X  " " " " "r;rYc<eZdZd)d Zd Zd*d Zed+dZed,dZed,dZ ed,dZ ed,dZ ed-dZ d.dZ d/dZd0dZd1dZd.dZd.d Zd.d!Zd2d#Zed+d$Zed+d%Zed3d'Zd(S)4r]rAr/rr+r<rr4r5c|||_||_||_|r|jj|_dS|jj|_dSr7)rArr<moduleupgrader downgrade)r8rArr<s r9r:zRevisionStep.__init__sP)  $  '     )    r;c2d|jjd|jdS)Nz RevisionStep(z , is_upgrade=))rr<r?s r9__repr__zRevisionStep.__repr__)s% M " " " OOO  r;otherobjectclt|to|j|jko|j|jkSr7)rr]rr<r8rvs r9__eq__zRevisionStep.__eq__/s7 ul + + 4$-/ 45#33 r;rc|jjSr7)rrkr?s r9rkzRevisionStep.doc6s }  r;rcB|jr |jjS|jjfSr7r<r_normalized_down_revisionsr?s r9from_revisionszRevisionStep.from_revisions:s% ? -=; ;M*, ,r;cB|jr |jjS|jjfSr7r<r_versioned_down_revisionsr?s r9rZz#RevisionStep.from_revisions_no_depsAs' ? -=: :M*, ,r;cB|jr |jjfS|jjSr7r}r?s r9 to_revisionszRevisionStep.to_revisionsJs% ? <M*, ,=; ;r;cB|jr |jjfS|jjSr7rr?s r9r[z!RevisionStep.to_revisions_no_depsQs' ? ;M*, ,=: :r;c<t|jjdkSNr()rrr~r?s r9_has_scalar_down_revisionz&RevisionStep._has_scalar_down_revisionZs4=;<<AAr;rSet[str]c|jsdS|jj|vrdS|jj}|sdS||}| S)zA delete is when we are a. in a downgrade and b. we are going to the "base" or we are going to a version that is implied as a dependency on another version that is remaining. FT)rerr~_unmerge_to_revisions)r8rdownrevsrs r9r)z!RevisionStep.should_delete_branch^s^   5 = ! . .5=; $4 55e<z3RevisionStep.merge_branch_idents..{* r;Fcheckr)r differencerrA_get_ancestor_nodesrQlistr)r8r other_heads ancestorsrs r9r/z RevisionStep.merge_branch_identsus%jj++D,?@@  7*>>%33K@@?I "D'((33I>>NN"$"566N "% & & 2   a   r;Collection[str]cRt||jjg}|rrd|j|j|dD}t t|j|S|jS)Nch|] }|j SrHrrs r9rz5RevisionStep._unmerge_to_revisions..rr;Fr)rrrrArrQrr)r8rrrs r9rz"RevisionStep._unmerge_to_revisionss%jj++T]-C,DEE  %*>>%33K@@?I T.//::9EEFF F$ $r; Tuple[str, str, Tuple[str, ...]]ch||}|jd|d|ddfSNrr)rr)r8rrs r9r1z"RevisionStep.unmerge_branch_identssB11%88    "   2    r;cf|jsdS|jj}|sdS||sdSdS)NFT)r<rr~ intersectionr8rrs r9r,z!RevisionStep.should_create_branchsJ 5=; 4 %%h// tur;c|jsdS|jj}t|dkr(t||dkrdSdSNFr(T)r<rr~rrrs r9r.z"RevisionStep.should_merge_branchessV 5=; x==1  U%7%7%A%A!B!BQ!F!F4ur;cv|jsdS|jj}|jj|vrt|dkrdSdSr)rerr~rrs r9r0z$RevisionStep.should_unmerge_branchessF  5=; = !U * *s8}}q/@/@4ur;Tuple[str, str]c|jsR||jj}t |dks Jdt |d}n|jjd}|jr||jjfS|jj|fS)Nr(z4Can't do an UPDATE because downrevision is ambiguousr)rrrr~rrr<)r8rdownrev down_revisions r9r2zRevisionStep.update_version_nums- H(( 8GG !!!E"!! MM!,MM MDQGM ? 9 $-"88 8=)=8 8r;c|jjSr7rr?s r9r*zRevisionStep.delete_version_num }%%r;c|jjSr7rr?s r9r-zRevisionStep.insert_version_numrr;r;cft|j|jj|jj|jdS)NFrArBrDr<r=)r;rArr~r<r?s r9rzRevisionStep.infos7*/=C     r;N)rAr/rr+r<rr4r5)rvrwr4rrmr r rrr4r)rrr4r)rrr4r)rrr4rrrr4rr4r;)rOrPrQr:rurzrRrkrrZrr[rr)r/rr1r,r.r0r2r*r-rrHr;r9r]r]s           !!!X!---X- ---X-<<<X< ;;;X;BBBXB$$$$.    2 % % % %     &        9999"&&&X&&&&X&   X   r;r]ceZdZU d+d,d ZdZd ed<d-dZdZedZ ed.dZ ed.dZ ed.dZ ed/dZ ed/dZd0dZd1d!Zd2d#Zd3d$Zd4d&Zd3d'Zd3d(Zed5d*ZdS)6 StampStepNr"%Optional[Union[str, Collection[str]]]r#r<r branch_moverAOptional[RevisionMap]r4r5ctj|d|_tj|d|_||_||_|j|_||_dS)NrHr) rrr"r#r<rstamp_revisionrrA)r8r"r#r<rrAs r9r:zStampStep.__init__sX'+mE2&F&F&F $(M#r$B$B$B$& /(r;rrkrrc dSr7rH)r8rs r9rzStampStep.stamp_revisionstr;ct|to?|j|jko/|j|jko|j|jko|j|jkSr7)rrr revisionsrrr<rys r9rzzStampStep.__eq__ sb ui ( ( 4$6 4"d&77 4!T%55 45#33  r;c|jSr7r"r?s r9rzStampStep.from_revisionss zr;rc|jSr7r#r?s r9rzStampStep.to_revisionss xr;c|jSr7rr?s r9rZz StampStep.from_revisions_no_depss zr;c|jSr7rr?s r9r[zStampStep.to_revisions_no_deps s xr;rcPt|jdksJ|jdSNr(rrr"r?s r9r*zStampStep.delete_version_num&s'4:!####z!}r;cPt|jdksJ|jdSrrr#r?s r9r-zStampStep.insert_version_num+s'48}}!!!!x{r;rrrct|jdksJt|jdksJ|jd|jdfSr)rr"r#rs r9r2zStampStep.update_version_num0sK4:!####48}}!!!!z!}dhqk))r;Union[Set[str], List[str]]=Union[Tuple[List[Any], str, str], Tuple[List[str], str, str]]clt|jdd|jd|jdfSr)rr"r#rs r9r/zStampStep.merge_branch_idents5s6 AbD! " " JrN HQK   r;Tuple[str, str, List[str]]cl|jd|jdt|jddfSr)r"r#rrs r9r1zStampStep.unmerge_branch_idents?s5 JqM HRL !B$   r;c|jo|jSr7)rerrs r9r)zStampStep.should_delete_branchIs 5T%55r;Union[Set[str], bool]c|joT|jp&t|j|o&t|j|Sr7)r<rrr"rr#rs r9r,zStampStep.should_create_branchOsP O 0!FS__%?%?%F%F 0DH ((// r;c2t|jdkSrrrs r9r.zStampStep.should_merge_branchesVs4:""r;c2t|jdkSrrrs r9r0z!StampStep.should_unmerge_branchesYs48}}q  r;r;c|jr|j|jfn |j|jf\}}|jJt |j|||jdS)NTr)r<r#r"rAr;)r8updowns r9rzStampStep.info\sm (TXtz " "*dh' D  ,,,*     r;r7) r"rr#rr<rrrrArr4r5r r rmr)rrr4r)rrr4rr)rrr4rr)rOrPrQr:rkrWrrzrRrrrZr[r*r-r2r/r1r)r,r.r0rrHr;r9rrs/3 ) ) ) ) )C   XXX X XX****         6666     ####!!!!    X    r;r)G __future__r contextlibrrloggingrytypingrrrr r r r r rrrrrr sqlalchemyrrrrrrsqlalchemy.enginerrrsqlalchemy.engine.strategiesrrrr util.compatr!r"r#sqlalchemy.engine.baser$r%sqlalchemy.engine.mockr&sqlalchemy.sql.elementsr' environmentr)rr* script.baser+r,script.revisionr-r.r/ getLoggerrOrr1r3rr;rYr]rrHr;r9rs""""""%%%%%%"""""" !!!!!! %%%%%%++++++$$$$$$------;;;;;;######.))))))%%%%%%111111222222555555555555//////$$$$$$------111111******------g!!77777777:`  `  `  `  `  `  `  `  Fl-l-l-l-l-l-l-l-^@N@N@N@N@N@N@N@NF,",",",",",",","^X X X X X =X X X vv v v v v v v v v v r;