o
     {gO                     @   s   d dgZ ddlZddlZddlmZ ddlmZmZ ddlm	Z	 ddl
mZmZ dd	lmZ er<dd
lmZ ddlmZ eeZG dd deZejZejZejZejZejZejZG dd  d eZdS )
RootModuleRootUpdateProgress    N)InvalidGitRepositoryError   )	SubmoduleUpdateProgress)find_first_remote_branch)TYPE_CHECKINGUnion)
Commit_ish)Repo)IterableListc                   @   sB   e Zd ZdZdd eejejd D \ZZZ	Z
ejd ZdZdS )r   zaUtility class which adds more opcodes to
    :class:`~git.objects.submodule.base.UpdateProgress`.c                 C   s   g | ]}d |> qS )r    ).0xr   r   w/var/www/bot.gig.net.ua/public_html/telegram/P1/HellBot/venv/lib/python3.10/site-packages/git/objects/submodule/root.py
<listcomp>!   s    zRootUpdateProgress.<listcomp>   r   N)__name__
__module____qualname____doc__ranger   _num_op_codesREMOVE
PATHCHANGEBRANCHCHANGE	URLCHANGE	__slots__r   r   r   r   r      s    
c                       s   e Zd ZdZdZdZd fdd	Zdd
dZ									ddee	e
df dededededed dedededd fddZdddZ  ZS ) r   zA (virtual) root of all submodules in the given repository.

    This can be used to more easily traverse all submodules of the
    superproject (master repository).
    r   __ROOT__repor   returnNc                    s4   t  j|| j| jd| j|jjdtj	| j
d d S )N )binshamodepathnameparent_commiturlbranch_path)super__init__NULL_BIN_SHAk_default_modek_root_nameheadcommitgitHeadto_full_pathk_head_default)selfr    	__class__r   r   r+   <   s   
zRootModule.__init__c                 C   s   dS )zMay not do anything.Nr   r5   r   r   r   _clear_cacheI   s   zRootModule._clear_cacheTFprevious_commit	recursiveforce_removeinitto_latest_revisionprogress)Nr   dry_runforce_reset
keep_goingc
           (         s2  | j jrtd|du rt }d}
|rd}
| j }z2|jj}|du rBz||jdj}|j|j	kr5t
W n t
yA   |}Y nw ||}| j||d}| |}t|}t|}|| }t|}t|D ]C\}}t}|dkru|tO }|||||
d|j|jf   |jj|_|jd	d
||d ||d kr|tO }|||||
d|j   qg||@ }t|}t|D ]\}}||j }||j   j|jkr| r|ttB |||
d j|j jf   |s|j jd
d	d |ttB |||
d j     rI j|jkrd}  }|j}t fdd|D dkr|ttB |||
d j|j jf   |s|dd |D vsDJ || j}|j |d t fdd|j!D dkrjt"d j# jf d}|D ]}|j|jkr{|} nqn|du rt|dkr|d }ntd|j |j} |$| |%|   j}!d	}"|j!| j# }#|#j& D ]}$|$j|!krd
}" nq|"st'(d j) |#jj _|ttB |||
d j    j*|j*krI|tt+B |||
d j|j* j*f   |s:  }|j}%|%D ]	}|j |d qzt,j-j.| j#dd}&W n t/y,   t,-| j*}&Y nw |&0t1|% j# |&|j_2|tt+B |||
d j   qW n t3yi }' z|	sX t'4t5|' W Y d}'~'nd}'~'ww |D ]*  jd	||||||	d  |r  rt6|   jd
|||||||	d! ql| S )"a+  Update the submodules of this repository to the current HEAD commit.

        This method behaves smartly by determining changes of the path of a submodule's
        repository, next to changes to the to-be-checked-out commit or the branch to be
        checked out. This works if the submodule's ID does not change.

        Additionally it will detect addition and removal of submodules, which will be
        handled gracefully.

        :param previous_commit:
            If set to a commit-ish, the commit we should use as the previous commit the
            HEAD pointed to before it was set to the commit it points to now.
            If ``None``, it defaults to ``HEAD@{1}`` otherwise.

        :param recursive:
            If ``True``, the children of submodules will be updated as well using the
            same technique.

        :param force_remove:
            If submodules have been deleted, they will be forcibly removed. Otherwise
            the update may fail if a submodule's repository cannot be deleted as changes
            have been made to it.
            (See :meth:`Submodule.update <git.objects.submodule.base.Submodule.update>`
            for more information.)

        :param init:
            If we encounter a new module which would need to be initialized, then do it.

        :param to_latest_revision:
            If ``True``, instead of checking out the revision pointed to by this
            submodule's sha, the checked out tracking branch will be merged with the
            latest remote branch fetched from the repository's origin.

            Unless `force_reset` is specified, a local tracking branch will never be
            reset into its past, therefore the remote branch must be in the future for
            this to have an effect.

        :param force_reset:
            If ``True``, submodules may checkout or reset their branch even if the
            repository has pending changes that would be overwritten, or if the local
            tracking branch is in the future of the remote tracking branch and would be
            reset into its past.

        :param progress:
            :class:`RootUpdateProgress` instance, or ``None`` if no progress should be
            sent.

        :param dry_run:
            If ``True``, operations will not actually be performed. Progress messages
            will change accordingly to indicate the WOULD DO state of the operation.

        :param keep_going:
            If ``True``, we will ignore but log all errors, and keep going recursively.
            Unless `dry_run` is set as well, `keep_going` could cause
            subsequent/inherited errors you wouldn't see otherwise.
            In conjunction with `dry_run`, this can be useful to anticipate all errors
            when updating submodules.

        :return:
            self
        z-Cannot update submodules in bare repositoriesNr"   z	DRY-RUN: )r'   r   zRemoving submodule %r at %sFT)configurationmoduleforcer@   r   zDone removing submodule %rz/Moving repository of submodule %r from %s to %s)rE   rD   z&Done moving repository of submodule %r__new_origin__c                    s   g | ]
}|j  j kr|qS r   )r(   r   rsmr   r   r   	      z%RootModule.update.<locals>.<listcomp>z*Changing url of submodule %r from %s to %sc                 S   s   g | ]}|j qS r   )r&   rH   r   r   r   r     s    )r?   c                    s   g | ]
}|j  jkr|qS r   )remote_headbranch_namerH   rJ   r   r   r     rL   zISubmodule branch named %r was not available in new submodule remote at %rz,Couldn't find original remote-repo at url %rzCurrent sha %s was not contained in the tracking             branch at the new remote, setting it the the remote's tracking branchz"Done adjusting url of submodule %rz-Changing branch of submodule %r from %s to %szbranch: Created from HEAD)logmsgz$Done changing branch of submodule %r)r;   r=   r>   r?   r@   rF   rB   )r;   r<   r=   r>   r?   r@   rA   rB   )7r    barer   r   r/   r0   	log_entry	oldhexshar#   r,   
IndexError
list_itemssetlen	enumerater   BEGINupdater&   abspath_parent_commitremoveENDr%   module_existsr   mover(   rE   remotesr   create_remotefetchrefs
ValueErrorrN   delete_remoterenametraverse_loggerwarninghexshar)   r   r1   r2   createOSErrorset_tracking_branchr   	reference	Exceptionerrorstrtype)(r5   r:   r;   r<   r=   r>   r?   r@   rA   rB   prefixr    
cur_commitpsmssmsspsmsssmsrrsmlen_rrsmirsmopcsmslen_csmscsmpsmnnsmmrmtssmrrmt_for_deletionremote	orig_namesmshafoundrrefcsmmrtbrerrr   rJ   r   rY   O   s|  I










	

  ?
zRootModule.updatec                 C   s   | j S )z8:return: The actual repository containing the submodules)r    r8   r   r   r   rE     s   zRootModule.module)r    r   r!   N)r!   N)	NTFTFNFFF)r!   r   )r   r   r   r   r   r.   r+   r9   r
   r   rq   boolrY   rE   __classcell__r   r   r6   r   r   1   sN    
	

  )__all__loggingr1   git.excr   baser   r   utilr   typingr	   r
   	git.typesr   git.repor   git.utilr   	getLoggerr   rh   r   rX   r]   r   r   r   r   r   r   r   r   r   <module>   s(   
