
    64%e                     R   d dl mZ d dlZd dlZd dl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mZmZ d dlmZmZmZmZ d dlmZmZ d dlmZ d d	lmZmZmZmZmZm Z  d d
lm!Z! d dl"m#Z$ ddl%m&Z&m'Z'm(Z(m)Z)m*Z* d dl+m,Z,m-Z-m.Z.m/Z/m0Z0m1Z1 d dl+m2Z2m3Z3m4Z4 d dl5m6Z6m7Z7m8Z8m9Z9 e0rd dl:m;Z; d dl<m=Z= d dl>m?Z? ddgZ@ ejA        d          ZBeBC                     ejD                                G d de          ZEeEjF        ZFeEjG        ZGeEjH        ZHeEjI        ZIeEjJ        ZJ G d dee          ZKdS )    )BytesION)Git)defencis_win)SectionConstraintGitConfigParsercp)InvalidGitRepositoryErrorNoSuchPathErrorRepositoryDirtyErrorBadName)IndexObjectObject)TraversableIterableObj)join_path_nativeto_native_path_linuxRemoteProgressrmtreeunbare_repoIterableList)HIDE_WINDOWS_KNOWN_ERRORS   )mkheadsm_name
sm_sectionSubmoduleConfigParserfind_first_remote_branch)CallableDictMappingSequenceTYPE_CHECKINGcast)AnyIteratorUnion)
Commit_ishLiteralPathLikeTBD)	IndexFile)Repo)Head	SubmoduleUpdateProgresszgit.objects.submodule.basec                       e Zd ZU dZd  eej        ej        dz             D             \  ZZZ	ej        dz   Ze
ed<   dZdS )r/   zClass providing detailed progress information to the caller who should
    derive from it and implement the ``update(...)`` messagec                     g | ]}d |z  S )r    ).0xs     :lib/python3.11/site-packages/git/objects/submodule/base.py
<listcomp>zUpdateProgress.<listcomp>G   s    uuu!qAvuuu       _num_op_codesr2   N)__name__
__module____qualname____doc__ranger   r9   CLONEFETCH	UPDWKTREEint__annotations__	__slots__r2   r7   r5   r/   r/   B   so         @ @ vuuu^5QSaSorsSs/t/tuuuE5)'59M3999IIIr7   c                   Z    e Zd ZU dZdZdZdZdZej	        ej
        z  ZdZed         ed<   dZd	Z	 	 	 	 	 	 d_dddedeed
f         deed
f         deed
f         deed
f         deed
f         deed
f         dd
f fdZdedd
f fdZedd ded          fd            Zededefd            ZdedefdZ de!defdZ"defdZ#defdZ$defd Z%edddeed
f         d!ede&fd"            Z'd`d#Z(edede)fd$            Z*d!ede+fd%Z,ed&ddededefd'            Z-e	 	 dadddededed)ed*ed+eddfd,            Z.ed&ddedefd-            Z/ed.ed/edd
fd0            Z0e	 	 	 	 	 	 	 	 dbdddededeed
f         deed
f         d1ed2eed
f         d3ee1eef         d
f         d4ee2e3         d
f         d)ed*edd fd5            Z4	 	 	 	 	 	 	 	 	 	 	 dcd7ed8ed9ed:ed;         d<ed=ed>ed3ee1eef         d
f         d4ee2e3         d
f         d)ed*edd fd?Z5e6ddd@edAedBedd fdC            Z7e6	 	 	 	 dedBed=edAed<edd f
dD            Z8dfdEeed
f         dFedd fdGZ9e6	 dgdHedI         dJede+dK         fdL            Z:e6dMedd fdN            Z;e6dhdO            Z<defdPZ=defdQZ>e?didS            Z@e?defdT            ZAe?defdU            ZBe?defdV            ZCe?djdX            ZDe?defdY            ZEde+e&         fdZZFded          fd[ZGe	 dkdddeeef         d]ed+edeHd          f
d^            ZI xZJS )lr.   av  Implements access to a git submodule. They are special in that their sha
    represents a commit in the submodule's repository which is to be checked out
    at the path of this instance.
    The submodule type does not have a string type associated with it, as it exists
    solely as a marker in the tree and index.

    All methods work in bare and non-bare repositories.name.gitmodulesbranchmaster	submoduletype)_parent_commit_url_branch_path_name__weakref__pathrM   rN   Nrepor,   binshamoderR   parent_commiturlbranch_pathreturnc	                     t          t          |                               ||||           d| _        || _        ||| _        ||| _        |	|| _        dS dS )a  Initialize this instance with its attributes. We only document the ones
        that differ from ``IndexObject``

        :param repo: Our parent repository
        :param binsha: binary sha referring to a commit in the remote repository, see url parameter
        :param parent_commit: see set_parent_commit()
        :param url: The url to the remote repository which is the submodule
        :param branch_path: full (relative) path to ref to checkout when cloning the remote repositoryr   N)superr.   __init__sizerL   rM   rN   rO   )
selfrS   rT   rU   rR   rF   rV   rW   rX   	__class__s
            r5   r\   zSubmodule.__init__m   sk    & 	i''fdDAAA	+?DI" +DDJJJ r7   attrc                 V   |dv r|                                  }	 |                    d          | _        nX# t          j        $ rF}| j        j        0t          dt          j	        | j        j        d          z            |Y d }~nd }~ww xY w|                    d          | _
        |                    | j        t          j                            | j                            | _        d S |dk    rt%          d          t'          t(          |                               |           d S )NrQ   rR   z;This submodule instance does not exist anymore in '%s' filerG   rW   rO   zCCannot retrieve the name of a submodule if it was not set initially)config_readergetrR   r	   NoSectionErrorrS   working_tree_dir
ValueErrorospjoinrM   	get_valuek_head_optiongitr-   to_full_pathk_head_defaultrN   AttributeErrorr[   r.   _set_cache_)r^   r`   readerer_   s       r5   ro   zSubmodule._set_cache_   s2   333(,(:(:(<(<F"JJv..		$   9-9$U(49#=}MMN   :9999 

5))DI & 0 01CSXEZEZ[_[nEoEo p pDW__ !fggg)T""..t44444s   6 B<BBitemc                     	 |                      |                                          S # t          $ r t          d          cY S w xY w)z4:return: all the submodules of our module repository )
list_itemsmoduler
   r   )clsrr   s     r5   _get_intermediate_itemsz!Submodule._get_intermediate_items   sP    	$>>$++--000( 	$ 	$ 	$#####	$s   &) AArk   c                 (    |j         d d         dk    S )Nr8   )r         )version_info)rw   rk   s     r5   _need_gitfile_submodulesz"Submodule._need_gitfile_submodules   s    #y00r7   otherc                 "    | j         |j         k    S )zCompare with another submodulerO   r^   r~   s     r5   __eq__zSubmodule.__eq__   s    
 zU[((r7   c                     | |k     S )z-Compare with another submodule for inequalityr2   r   s     r5   __ne__zSubmodule.__ne__   s    EM""r7   c                 *    t          | j                  S )z4Hash this instance using its logical id, not the sha)hashrO   r^   s    r5   __hash__zSubmodule.__hash__   s    DJr7   c                     | j         S Nr   r   s    r5   __str__zSubmodule.__str__   s
    zr7   c                 r    dt          |           j        d| j        d| j        d| j        d| j        dS )Nzgit.z(name=z, path=z, url=z, branch_path=))rK   r:   rO   rR   rW   rX   r   s    r5   __repr__zSubmodule.__repr__   sG     JJJJJIIIHHH
 	
r7   	read_onlyc                    d}|"	 |j         j        |k    }n# t          $ r Y nw xY w|j        s)|r'|j        r t          j        |j        | j                  }nP|
J d            	 |                     |          }n-# t          $ r }t          d| j        d|          |d}~ww xY w|s|j        s|st          d          t          ||          S )a7  :return: Config Parser constrained to our submodule in read or write mode
        :raise IOError: If the .gitmodules file cannot be found, either locally or in the repository
            at the given parent commit. Otherwise the exception would be delayed until the first
            access of the config parserTNz-need valid parent_commit in bare repositorieszCould not find z# file in the tree of parent commit z;Cannot write blobs of 'historical' submodule configurationsr   )headcommitrf   barere   rg   rh   k_modules_file_sio_modulesKeyErrorIOErrorr   )rw   rS   rV   r   parent_matches_head	fp_modulerq   s          r5   _config_parserzSubmodule._config_parser   s;    #$&*i&6-&G##   
 y 		0 		T5J 		!68JKKII ,,.],,,,,];;		   gPSPbPbPbdqdqr   	\di 	\/B 	\Z[[[ %Y)DDDDs$    
$$$A: :
B$BB$c                 \    | j         D ]#}	 t          | |           # t          $ r Y  w xY wd S r   )_cache_attrsdelattrrn   )r^   rF   s     r5   _clear_cachezSubmodule._clear_cache   sV    % 	 	Dd####!   	 	s   
))c                     t          |j        | j                 j                                                  }| j        |_        |S )z]:return: Configuration file as BytesIO - we only access it through the respective blob's data)r   treer   data_streamreadrF   )rw   rV   sios      r5   r   zSubmodule._sio_modules   s:     m();<HMMOOPP%
r7   c                     	 | j         }n# t          $ r d}Y nw xY w|                     | j        ||          }|                    |            t          |t          | j                            S )zI:return: Config Parser constrained to our submodule in read or write modeN)rV   rf   r   rS   set_submoduler   r   rF   )r^   r   pcparsers       r5   _config_parser_constrainedz$Submodule._config_parser_constrained   s~    	,0,>BB 	 	 	BBB	 $$TYI>>T""" DI)>)>???s   
 parent_repoc                     |                      |j                  rt          j        |j        d|          S |j        rt          j        |j        |          S t                      )Nmodules)r}   rk   rg   rh   git_dirre   NotADirectoryError)rw   r   rR   rF   s       r5   _module_abspathzSubmodule._module_abspath	  s_    ''88 	B8K/DAAA' 	@8K8$??? """r7   Fallow_unsafe_optionsallow_unsafe_protocolskwargsc                    |                      |||          }|}	|                     |j                  rh||d<   t          j        |          }
t          j        |
          st          j        |
           t          j        t          |j
                  |          }	t          j        j        ||	f||d|}|                     |j                  r|                     |	|           |S )a  :return: Repo instance of newly cloned repository
        :param repo: our parent repository
        :param url: url to clone from
        :param path: repository - relative path to the submodule checkout location
        :param name: canonical of the submodule
        :param allow_unsafe_protocols: Allow unsafe protocols to be used, like ext
        :param allow_unsafe_options: Allow unsafe options to be used, like --upload-pack
        :param kwargs: additional arguments given to git.cloneseparate_git_dir)r   r   )r   r}   rk   rg   dirnameisdirosmakedirsrh   strre   r,   
clone_from!_write_git_file_and_module_config)rw   rS   rW   rR   rF   r   r   r   module_abspathmodule_checkout_pathmodule_abspath_dirclones               r5   _clone_repozSubmodule._clone_repo  s   & ,,T4>>-''11 	N)7F%&!$^!<!<9/00 0.///#&8C0E,F,F#M#M  # 
 "6#9	
 

 
 
 ''11 	X112FWWWr7   c                    t          |          }|                    d          r
|dd         }t          j        |          r|j        rt          |j                  }|                    |          st          d|d|d          |t          |                    d                    dz   d         }|st          d|z            |S )	z:return: a path guaranteed  to be relative to the given parent - repository
        :raise ValueError: if path is not contained in the parent repository's working tree/NzSubmodule checkout path 'z0' needs to be within the parents repository at ''r   z?Absolute submodule path '%s' didn't yield a valid relative path)	r   endswithrg   isabsre   
startswithrf   lenrstrip)rw   r   rR   working_tree_linuxs       r5   _to_relative_pathzSubmodule._to_relative_path;  s     $D))== 	9D 9T?? 		k{; 		k!5k6R!S!S??#566  j)))4441   .55c::;;a?AABD k !bei!ijjj r7   re   r   c                 V   t          j        |d          }t          j        ||          }t          r(t          j        |          rt          j        |           t          |d          5 }|                    d|z  	                    t                               ddd           n# 1 swxY w Y   t          t          j        |d          dd          5 }|                    d	d
t          t          j        ||                               ddd           dS # 1 swxY w Y   dS )a  Writes a .git file containing a(preferably) relative path to the actual git module repository.
        It is an error if the module_abspath cannot be made into a relative path, relative to the working_tree_dir
        :note: will overwrite existing files !
        :note: as we rewrite both the git file as well as the module configuration, we might fail on the configuration
            and will not roll back changes done to the git file. This should be a non - issue, but may easily be fixed
            if it becomes one
        :param working_tree_dir: directory to write the .git file into
        :param module_abspath: absolute path to the bare repository
        .git)startwbz
gitdir: %sNconfigF)r   merge_includescoreworktree)rg   rh   relpathr   isfiler   removeopenwriteencoder   r   	set_valuer   )rw   re   r   git_file	rela_pathfpwriters          r5   r   z+Submodule._write_git_file_and_module_configS  s    8,f55K6FGGG	 	$z(## $	(###(D!! 	@RHHlY.66v>>???	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ SXnh??5afggg 	kq$S[1A%X%X%XYY  	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	s$   +1B((B,/B,9DD"%D"no_checkoutdepthenvclone_multi_optionsc                    |j         rt          d          |                     ||          }|t          |          } | || j        | j        ||d          }|                                rt	 |j        j        j	        t          |                   }||_        |S # t          $ r9 |j        }|j        |                    |d                   }|j        |_        |cY S w xY wt#          j        |t"          j                            t          |          p| j                            }|                                }|du }|rB|@|d |                                j        D             vrt1          d|d|j        d	          d}|[|st1          d
|z            |                                }d |j        D             }|st1          d|j        z            |d         }nXd|i}|s
|j        |d<   |r*t7          |t8                    r||d<   nt1          d          |	r|	|d<    | j        ||||f||
|d|}t=          j        |          }|j         !                                5 }|"                    tG          |          d|           ddd           n# 1 swxY w Y   |j         j        }|!                    |d          5 }|"                    d|           |"                    d|           ||_$        |s,|"                    | j%        |j&                   |j&        |_'        ddd           n# 1 swxY w Y   |r|j        j        j        |_        |(                    |gd           |S )ac
  Add a new submodule to the given repository. This will alter the index
        as well as the .gitmodules file, but will not create a new commit.
        If the submodule already exists, no matter if the configuration differs
        from the one provided, the existing submodule will be returned.

        :param repo: Repository instance which should receive the submodule
        :param name: The name/identifier for the submodule
        :param path: repository-relative or absolute path at which the submodule
            should be located
            It will be created as required during the repository initialization.
        :param url: git-clone compatible URL, see git-clone reference for more information
            If None, the repository is assumed to exist, and the url of the first
            remote is taken instead. This is useful if you want to make an existing
            repository a submodule of anotherone.
        :param branch: name of branch at which the submodule should (later) be checked out.
            The given branch must exist in the remote repository, and will be checked
            out locally as a tracking branch.
            It will only be written into the configuration if it not None, which is
            when the checked out branch will be the one the remote HEAD pointed to.
            The result you get in these situation is somewhat fuzzy, and it is recommended
            to specify at least 'master' here.
            Examples are 'master' or 'feature/new'
        :param no_checkout: if True, and if the repository has to be cloned manually,
            no checkout will be performed
        :param depth: Create a shallow clone with a history truncated to the
            specified number of commits.
        :param env: Optional dictionary containing the desired environment variables.
            Note: Provided variables will be used to update the execution
            environment for `git`. If some variable is not specified in `env`
            and is defined in `os.environ`, value from `os.environ` will be used.
            If you want to unset some variable, consider providing empty string
            as its value.
        :param clone_multi_options: A list of Clone options. Please see ``git.repo.base.Repo.clone``
            for details.
        :param allow_unsafe_protocols: Allow unsafe protocols to be used, like ext
        :param allow_unsafe_options: Allow unsafe options to be used, like --upload-pack
        :return: The newly created submodule instance
        :note: works atomically, such that no change will be done if the repository
            update fails for instancez*Cannot add submodules to bare repositoriesNzinvalid-temporaryrW   r   c                     g | ]	}|j         
S r2   r   r3   rs     r5   r6   z!Submodule.add.<locals>.<listcomp>  s    >>>Q15>>>r7   zSpecified URL 'z6' does not match any remote url of the repository at 'r   z8A URL was not given and a repository did not exist at %sc                     g | ]	}|j         
S r2   r   r   s     r5   r6   z!Submodule.add.<locals>.<listcomp>  s    111aAE111r7   z.Didn't find any remote url in repository at %snbr   zdepth should be an integermulti_options)r   r   r   rW   F)indexr   rR   Tr   ))r   r
   r   r   NULL_BIN_SHAk_default_modeexistsr   r   r   r   rO   r   r   entries	entry_keyrT   rk   r-   rl   rm   module_existsrv   remotesrf   abspathrF   
isinstancerB   r   r   
polish_urlrS   config_writerr   r   rM   rj   rR   rN   add)rw   rS   rF   rR   rW   rH   r   r   r   r   r   r   smr   entrybr
has_modulebranch_is_defaultmrepourlsr   r   s                         r5   r   zSubmodule.addo  ss   n 9 	Z+,XYYY $$T400 ?&s++C S#
 
 
 99;; 		Y%*3t995	   
eoodA&>&>?!L				 XdCH11#f++2SASTTUU%%''
"dN 	#/>>"))++*=>>>>> jdgdgdgikisisist   $(; d ![^b!bcccIIKKE115=111D ` !QTVT^!^___q'CC HKKFXF$ & gs  CeS)) C&+F7OO$%ABBB" >*=' $CO		
 %9'=	 	 	 	E nS!! W""$$ 	;Z--uc:::	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; E77 	*6UC(((VT***BG$ *  !2BG<<<"$'	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	*  	1
)0BI		2$d	###	s8   .,B A CC'%JJJA"L44L8;L8T	recursiveinitto_latest_revisionprogress)r/   Ndry_runforce
keep_goingc                 >   | j         j        r| S |t                      }d}|rd}|rd}	 	 |                                 }|j        }t          |          }t          |          D ]\  }}t          }|dk    r
|t          z  }|	                    ||||d|d| j
        z              |s|                    |           ||dz
  k    r
|t          z  }|	                    ||||d	| j
        z  z              nK# t          $ r= d}|s| cY S | j        }|sOt          j        |          r;	 t#          j        |           n%# t&          $ r}t'          d
|z            |d}~ww xY w|	                    t          t(          z  dd|d| j        d|d| j
        z              |s2|                     | j         | j        | j        | j
        d||	|
|	  	        }|	                    t          t(          z  dd|d|z  z              |s=	 t1          d|          }t3          |j        | j                  }t7          || j                  }|                    t=          || j                             |j         !                    |d|z             |j         j"        #                    |           n7# tH          t          f$ r# tJ          &                    d| j                   Y nw xY w| j         '                                5 }|(                    tS          | j
                  d| j                   ddd           n# 1 swxY w Y   Y nw xY w| j*        }| j+        }||j         j,        }||rd|j-        z  }|s]|j         j"        .                                }||j/        }|j*        }|j+        }nBtJ          0                    d||j         j"                   ntJ          0                    d|           ||j         j/        j*        |k    rd}|j         j/        j*        | j        k    r|1                    |j         j/        |          }t          |          dk    s|d         d|d         j+        |k    rS|r"d} | dz  } tJ          2                    |            n/d} | |rdpd|j         |fz  } tJ          3                    |            d}|r*|s(|4                    ddd          rtk          |d           |	                    t          tl          z  dd|d!| j        d"| j
        d#|z              |s>|r<|r|j7        8                    ||$           n|j         9                    |dd%           |	                    t          tl          z  dd|d&| j
        z  z              nA# tt          $ r4}!|s tJ          0                    tw          |!                     Y d}!~!nd}!~!ww xY w|rH|F| <                    |                                           D ]}"|"	                    |||||||'           | S )(a}
  Update the repository of this submodule to point to the checkout
        we point at with the binsha of this instance.

        :param recursive: if True, we will operate recursively and update child-
            modules as well.
        :param init: if True, the module repository will be cloned into place if necessary
        :param to_latest_revision: if True, the submodule's sha will be ignored during checkout.
            Instead, the remote will be fetched, and the local tracking branch updated.
            This only works if we have a local tracking branch, which is the case
            if the remote repository had a master branch, or of the 'branch' option
            was specified for this submodule and the branch existed remotely
        :param progress: UpdateProgress instance or None if no progress should be shown
        :param dry_run: if True, the operation will only be simulated, but not performed.
            All performed operations are read - only
        :param force:
            If True, we may reset heads even if the repository in question is dirty. Additinoally we will be allowed
            to set a tracking branch which is ahead of its remote branch back into the past or the location of the
            remote branch. This will essentially 'forget' commits.
            If False, local tracking branches that are in the future of their respective remote branches will simply
            not be moved.
        :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, it can be useful to anticipate all errors when updating submodules
        :param env: Optional dictionary containing the desired environment variables.
            Note: Provided variables will be used to update the execution
            environment for `git`. If some variable is not specified in `env`
            and is defined in `os.environ`, value from `os.environ` will be used.
            If you want to unset some variable, consider providing empty string
            as its value.
        :param clone_multi_options:  list of Clone options. Please see ``git.repo.base.Repo.clone``
            for details. Only take effect with `init` option.
        :param allow_unsafe_protocols: Allow unsafe protocols to be used, like ext
        :param allow_unsafe_options: Allow unsafe options to be used, like --upload-pack
        :note: does nothing in bare repositories
        :note: method is definitely not atomic if recurisve is True
        :return: selfNrt   z	DRY-RUN: r   zFetching remote z of submodule )r  r   z$Done fetching remote of submodule %rz:Module directory at %r does already exist and is non-emptyzCloning url 'z' to 'z' in submodule T)r   r   r   r   r   zDone cloning to %sr,   zsubmodule: attaching head to %s)logmsgz%Failed to checkout tracking branch %srW   z8Cannot update to latest revision in repository at %r as z6%s a tracking branch was not set for local branch '%s'z%%s there was no local tracking branchzNWill force checkout or reset on local branch that is possibly in the future ofzJthe commit it will be checked out to, effectively 'forgetting' new commitszRSkipping %s on branch '%s' of submodule repo '%s' as it contains un-pushed commitscheckoutresetFr   working_treeuntracked_fileszCannot reset a dirty repositoryzUpdating working tree at z for submodule z to revision )r  )r   r  z+Done updating working tree for submodule %r)r  r  r  r  )=rS   r   r/   rv   r   r   	enumerater@   BEGINupdaterF   fetchENDr
   r   rg   r   r   rmdirOSErrorr?   rW   r   rR   r#   r   branch_namer   rX   
set_objectr   r   r   set_reference	referenceset_tracking_branch
IndexErrorlogwarningr   r   r   rT   hexshais_detachedworking_dirtracking_branchr   error
merge_basedebuginfois_dirtyr   rA   rk   r
  r  	Exceptionr   
iter_items)#r^   r  r  r  r  r  r  r  r   r   r   r   prefixr   rmtslen_rmtsiremoteopcheckout_module_abspathrq   remote_branchlocal_branchr   rT   r  r  msg_baserrefrcommit	may_resetbase_commitmsgerrrJ   s#                                      r5   r  zSubmodule.update  s   f 9> 	K %''H 	! F  	EL	 jQ}t99!*4  IAvBAvve OO QUQZQZ![[	   # 8h777 HqL((c	OO !G$)!SS	   )6 - KQ KQ KQ  KKK +/,' !39-D#E#E !!!89999" ! ! !%X[rr  !! EMFDHHHHNeNeNegkgpgpqr	     ,,			&9-A/E - 
 
E %K14KKK	    Q_ $VU 3 3(@PTP`(a(a'-eT5E'F'F %//ud>O0P0PQQQ 
00(#D|#S 1    
,@@OOOO&(AB _ _ _$KTM]^^^^^_ 0022 Qf((DI)>)>txPPPQ Q Q Q Q Q Q Q Q Q Q Q Q Q QUKQb [F[F #j4  %7 UX]Xii" Q :/??AAD'"&+!(!(		T$!J0    IIExPPP  UZ%6%=%G%G
 !	:$+t/@@@"'"2"25:3Df"M"MK;''1,,Q1KP[\]P^PeioPoPo  ."rC#ooCIIcNNNN"vC + :
 Eg %
 %$ C
  HHSMMM(-I ! ] ]5>>[_qu>3v3v ]25:[\\\
 I%FW[W`W`W`bfbkbkbkmsmstu	    P9 P" P
 	**6*????
((t$(OOO )OJTYVV	    	  	  	  IIc#hh	   	 !%!?!? 	 	I$$!*!) '##- %     s   C
C7 5V 7L?V 
L?(D=<L?=
EEEB L? B%J&%L?&1KL?KL?6/L1%L?1L5	5L?8L5	9L?<V >L??IV 
W*WWmodule_pathconfigurationrv   c                 .   ||z   dk     rt          d          |                     | j        |          }|| j        k    r| S t	          t          | j        j                  |          }t          j        |          rt          d|z            | j        j	        }|
                    |d          }|r||j        v rt          d          |rt          j        |          rnt          t          j        |                    rt          d          t          j        |          rt          j        |           nt          j        |           n	 | j        }d}	|rt          j        |          rzt          j        ||           d}	t          j        t          j        |d	                    r<|                     | j        | j        | j                  }
|                     ||
           | j        }	 |r	 |
                    | j        d          }|j        |         }|j        |= t3          j        |d
d         |fz   |dd
         z             }||j        |<   n*# t6          $ r}t9          d| j        z            |d
}~ww xY w|                     |          5 }|                    d|           || _        d
d
d
           n# 1 swxY w Y   n&# t>          $ r |	rt          j        ||            w xY w|| j        k    r|                      |           | S )a  Move the submodule to a another module path. This involves physically moving
        the repository at our current path, changing the configuration, as well as
        adjusting our index entry accordingly.

        :param module_path: the path to which to move our module in the parent repostory's working tree,
            given as repository - relative or absolute path. Intermediate directories will be created
            accordingly. If the path already exists, it must be empty.
            Trailing(back)slashes are removed automatically
        :param configuration: if True, the configuration will be adjusted to let
            the submodule point to the given path.
        :param module: if True, the repository managed by this submodule
            will be moved as well. If False, we don't move the submodule's checkout, which may leave
            the parent repository in an inconsistent state.
        :return: self
        :raise ValueError: if the module path existed and was not empty, or was a file
        :note: Currently the method is not atomic, and it could leave the repository
            in an inconsistent state if a sub - step fails for some reason
        r   zRYou must specify to move at least the module or the configuration of the submodulez&Cannot move repository onto a file: %sr   z-Index entry for target path did already existz*Destination module directory was not emptyFTr   Nr8      z%Submodule's entry at %r did not exist)r   rR   )!rf   r   rS   rR   r   r   re   rg   r   r   r   r   r   r   r   listdirislinkr   r  r   renamesrh   r   rF   r   rk   
IndexEntryr   r
   r   r   r'  rename)r^   r9  r:  rv   r   module_checkout_abspathr   tekeycur_pathrenamed_moduler   previous_sm_pathekeyr   nentryrq   r   s                    r5   movezSubmodule.moveF  s   ( M!A%%qrrr  $55diMM  49,,K #33ty7Q3R3RTh"i"i:-.. 	aEH__``` 	 4a88 	NUem33LMMM  	z122 rz"9::;; S$%QRRR :566 6I56666H45555
 
 < 	`cj** 	`Jx!8999!Nz#(#:FCCDD `!%!5!5diDI!V!V667NP^___  9	 5r ??49a88D!M$/Ed+ ^E"1"I9M8O,ORWXYXZXZR[,[\\F+1EM%(( r r r34[_c_h4ijjpqqr
 ''e'44 5$$V-ABBB 4DI5 5 5 5 5 5 5 5 5 5 5 5 5 5 5  	 	 	 >
2H===		 ty((KK,--- sU   0K 3A%I K 
J #I;;J  K K7K KK 
KK #K2c                    |s|st          d          d}|                                 D ] }|dz  }|                    ||||           ~!|r<|s:|dk    r4|                                 j                            d| j        z             |rk|                                 rV|                                 }|j        }|r|| j	        }	d}
t          j        |	          rt          j        }
n?t          j        |	          rt          }
n#t          j        |	          rt!          d          |s|
sJ  |
|	           nS|                    ddd          rt%          d	|j        z            |j        D ]}d}|j        }|D ]0}|t-          |j                            |                    dk    z  }1t-          |          r*|t-          |          k    rt%          d
|j        z            t-          |          r~~~|s|                                  |j        }~ddl}|                                 	 t          t9          |                     n?# t:          $ r2}t<          r%ddlm }  |d!                    |                    | d}~ww xY w|sht          j        |          rT|                                  	 t          |           n/# t:          $ r"}t<          rddlm }  |d|           | d}~ww xY w|s|                                  |r|s| j"        j        }	 |j#        |$                    | j%        d          = n# tL          $ r Y nw xY w|'                                 | j"        (                                5 }|)                    tU          | j                             ddd           n# 1 swxY w Y   | (                                5 }|)                                 ddd           n# 1 swxY w Y   | S )a  Remove this submodule from the repository. This will remove our entry
        from the .gitmodules file and the entry in the .git / config file.

        :param module: If True, the module checkout we point to will be deleted
            as well. If the module is currently on a commit which is not part
            of any branch in the remote, if the currently checked out branch
            working tree, or untracked files,
            is ahead of its tracking branch, if you have modifications in the
            In case the removal of the repository fails for these reasons, the
            submodule status will not have been altered.
            If this submodule has child - modules on its own, these will be deleted
            prior to touching the own module.
        :param force: Enforces the deletion of the module even though it contains
            modifications. This basically enforces a brute - force file system based
            deletion.
        :param configuration: if True, the submodule is deleted from the configuration,
            otherwise it isn't. Although this should be enabled most of the times,
            this flag enables you to safely delete the repository of your submodule.
        :param dry_run: if True, we will not actually do anything, but throw the errors
            we would usually throw
        :return: self
        :note: doesn't work in bare repositories
        :note: doesn't work atomically, as failure to remove any part of the submodule will leave
            an inconsistent state
        :raise InvalidGitRepositoryError: thrown if the repository cannot be deleted
        :raise OSError: if directories or files could not be removedzCNeed to specify to delete at least the module, or the configurationr   r   z-Removed at least one of child-modules of '%s'NzKCannot forcibly delete repository as it was neither a link, nor a directoryTr  zLCannot delete module at %s with any modifications, unless force is specifiedz3Cannot delete module at %s as there are new commits)SkipTestz'FIXME: fails with: PermissionError
  {}z%FIXME: fails with: PermissionError
  )+rf   childrenr   rv   r   r   rF   r   r   r   rg   r>  r   r   r   r   AssertionErrorr&  r
   re   r   refsr   rk   cherryr   gccollectr   r'  r   unittestrK  formatrS   r   r   rR   r   r   r   remove_sectionr   )r^   rv   r  r:  r  nccsmmodr   mpmethodr-  num_branches_with_new_commitsrrefsr3  wtdrP  exrK  parent_index
gcp_writer	sc_writers                         r5   r   zSubmodule.remove  sN   D  	d- 	dbccc ==?? 	 	C!GBJJvumW=== 	d 	dR!VV KKMM&&'VY]Yb'bccc
  T	d((** T	++--CkG C \BF:b>> xYFFYr]] x#FFZ^^ x()vwww !MMMF2JJJ <<dt<TT 3f./   "k  F451"KE % X X5SW^^D=Q=Q9R9RVW9WW55 5zz &Cs5zz&Q&Q7QTWThh   5zz !   %%'''.CIIIJJLLLs3xx(((($   4 j999999"*(+U+\+\]_+`+`"a"agii  
sy11 
!!###7OOOO    0 555555&h'TPR'T'TUU[]]  	   	+ 	+9?L ()?)?	1)M)MNN       
 ((** Aj))*TY*?*?@@@A A A A A A A A A A A A A A A ##%% +((***+ + + + + + + + + + + + + + + sf   1I 
J
-JJ
8K 
K4K//K4!M   
MM=(N11N58N5O11O58O5r   checkc                 F   |	d| _         | S | j                            |          }|j        }| j        |vrt          d|d| j        d          | j         }|| _         |rj|                     | j        | j         d          }|                    t          | j	                            s!|| _         t          d| j
        d|          	 |t          | j
                           j        | _        n# t          $ r | j        | _        Y nw xY w|                                  | S )	a_  Set this instance to use the given commit whose tree is supposed to
        contain the .gitmodules blob.

        :param commit:
            Commit'ish reference pointing at the root_tree, or None to always point to the
            most recent commit
        :param check:
            if True, relatively expensive checks will be performed to verify
            validity of the submodule.
        :raise ValueError: if the commit's tree didn't contain the .gitmodules blob.
        :raise ValueError:
            if the parent commit didn't store this submodule under the current path
        :return: selfNzTree of commit z did not contain the z fileTr   zSubmodule at path z  did not exist in parent commit )rL   rS   r   r   r   rf   r   has_sectionr   rF   rR   r   rT   r   r   r   )r^   r   ra  pcommitpctreeprev_pcr   s          r5   set_parent_commitzSubmodule.set_parent_commit\  sM    >"&DK)""6**f,,*PVPVPVX\XkXkXklmmm %% 	q((D4GSW(XXF%%j&;&;<< q&-# j]a]f]f]fhnhn!oppp	, TY07DKK 	, 	, 	,+DKKK	, 	s   $C1 1D
	D
r   )r+   Nr   r   c                 f    |                      d          }|||j        _        ||j        _        |S )aH  :return: a config writer instance allowing you to read and write the data
            belonging to this submodule into the .gitmodules file.

        :param index: if not None, an IndexFile instance which should be written.
            defaults to the index of the Submodule's parent repository.
        :param write: if True, the index will be written each time a configuration
            value changes.
        :note: the parameters allow for a more efficient writing of the index,
            as you can pass in a modified index on your own, prevent automatic writing,
            and write yourself once the whole operation is complete
        :raise ValueError: if trying to get a writer on a parent_commit which does not
            match the current head commit
        :raise IOError: If the .gitmodules file/blob could not be readFr   )r   r   _index_auto_write)r^   r   r   r   s       r5   r   zSubmodule.config_writer  s9    " 0050AA#(FM $)!r7   new_namec                 :   | j         |k    r| S | j                                        5 }|                    t	          | j                             r5|                    t	          | j                   t	          |                     ddd           n# 1 swxY w Y   |                     d          j        5 }|                    t	          | j                   t	          |                     ddd           n# 1 swxY w Y   || _        |                                 }|	                                r| 
                    | j        | j        |          }|j        }t          |                              t          |j                            rV| 
                    | j        | j        t          t          j                                        }t#          j        ||           |}t#          j        ||           |j        r|                     |j        |           | S )a  Rename this submodule
        :note: This method takes care of renaming the submodule in various places, such as

            * $parent_git_dir / config
            * $working_tree_dir / .gitmodules
            * (git >= v1.8.0: move submodule repository to new name)

        As .gitmodules will be changed, you would need to make a commit afterwards. The changed .gitmodules file
        will already be added to the index

        :return: this submodule instance
        NTr   )rF   rS   r   rc  r   rename_sectionr   rO   rv   has_separate_working_treer   rR   r   r   r   uuiduuid4r   r?  re   r   )r^   rk  pwcwrW  destination_module_abspath
source_dirtmp_dirs           r5   rA  zSubmodule.rename  sw    9  K Y$$&& 	O" ~~j3344 O!!*TY"7"7H9M9MNNN		O 	O 	O 	O 	O 	O 	O 	O 	O 	O 	O 	O 	O 	O 	O d++2 	Kbj33Z5I5IJJJ	K 	K 	K 	K 	K 	K 	K 	K 	K 	K 	K 	K 	K 	K 	K 
 kkmm((** 	i)-)=)=diT\)])]&J-..99#ck:J:JKK %..ty$)SEVEVWW
:w///$
Jz#=>>># i66s7KMghhh s$   ABBB66C88C<?C<c                     | j         }	 t          j        |          }|| j        k    r|S 	 t	          d|z            # t          t
          f$ r}t	          d|z            |d}~ww xY w)z:return: Repo instance initialized from the repository at our submodule path
        :raise InvalidGitRepositoryError: if a repository was not available. This could
            also mean that it was not yet initializedz(Repository at %r was not yet checked outzNo valid repository at %sN)r   rk   r,   rS   r
   r   )r^   rB  rS   rq   s       r5   rv   zSubmodule.module  s     #',	r8344Dty   ! ,,VYp,pqqq *?; 	j 	j 	j+,GJa,abbhii	js    = A&A!!A&c                 R    	 |                                   dS # t          $ r Y dS w xY w)zU:return: True if our module exists and is a valid git repository. See module() methodTF)rv   r'  r   s    r5   r   zSubmodule.module_exists  s;    	KKMMM4 	 	 	55	s    
&&c           	         t                      }| j        D ]B}	 t          | |          rt          | |          ||<   '# t          j        t          f$ r Y ?w xY w|                                  	 	 | j         	 | j        D ]}||v rt          | |||                    dS # t          $ r) Y | j        D ]}||v rt          | |||                    dS w xY w# | j        D ]}||v rt          | |||                    w xY w)z
        :return: True if the submodule exists, False otherwise. Please note that
            a submodule may exist ( in the .gitmodules file) even though its module
            doesn't exist on diskTF)localsr   hasattrgetattrr	   rd   rf   r   rR   setattrr'  )r^   locr`   s      r5   r   zSubmodule.exists  ss    hh% 	 	D4&& 4 'd 3 3CI%z2    	
	3		
 ) 3 33;;D$D	2223 3	     ) 3 33;;D$D	2223 3	 ) 3 33;;D$D	2223s3   #=AA/B 
C(C CC 'C;r-   c                 P    t          |                                 | j                  S )z:return: The branch instance that we are to checkout
        :raise InvalidGitRepositoryError: if our module is not yet checked out)r   rv   rN   r   s    r5   rH   zSubmodule.branch  s     dkkmmT%6777r7   c                     | j         S )zu
        :return: full(relative) path as string to the branch we would checkout
            from the remote and track)rN   r   s    r5   rX   zSubmodule.branch_path  s    
   r7   c                 J    t          j        | j        | j                  j        S )zK:return: the name of the branch, which is the shortest possible branch name)rk   r-   rS   rN   rF   r   s    r5   r  zSubmodule.branch_name   s    
 x	4#455::r7   c                     | j         S )zJ:return: The url to the repository which our module - repository refers to)rM   r   s    r5   rW   zSubmodule.url'  s     yr7   r'   c                 P    | j         | j                                        S | j         S )z:return: Commit instance with the tree containing the .gitmodules file
        :note: will always point to the current head's commit if it was not set explicitly)rL   rS   r   r   s    r5   rV   zSubmodule.parent_commit,  s*     &9##%%%""r7   c                     | j         S )a~  :return: The name of this submodule. It is used to identify it within the
            .gitmodules file.
        :note: by default, the name is the path at which to find the submodule, but
            in git - python it should be a unique identifier similar to the identifiers
            used for remotes, which allows to change the path of the submodule
            easily
        r   r   s    r5   rF   zSubmodule.name4  s     zr7   c                 .    |                      d          S )a  
        :return: ConfigReader instance which allows you to qurey the configuration values
            of this submodule, as provided by the .gitmodules file
        :note: The config reader will actually read the data directly from the repository
            and thus does not need nor care about your working tree.
        :note: Should be cached by the caller and only kept as long as needed
        :raise IOError: If the .gitmodules file/blob could not be readTr   )r   r   s    r5   rb   zSubmodule.config_reader?  s     ...>>>r7   c                 ,    |                      |           S )z
        :return: IterableList(Submodule, ...) an iterable list of submodules instances
            which are children of this submodule or 0 if the submodule is not checked out)rx   r   s    r5   rL  zSubmodule.childrenI  s     ++D111r7   HEADArgsc              /     K   	 |                     |          }|                     ||d          }n&# t          t          f$ r t	          g           cY S w xY w|                                D ]}t          |          }|                    |d          }	|                    |d          }
| j        }|	                    || j
                  r(t          |                    || j
                            }|j        }	 |j        }||	         }ne# t          $ rX 	 |j        |                    |	d                   }t#          ||j        |j        |j                  }n# t          $ r Y Y w xY wY nw xY wt+          |          t,          j        j        j        j        ur1||_        ||                                 k    r||_        t,          j                            |          |_        |
|_        |V  dS )zP:return: iterator yielding Submodule instances available in the given repositoryTr   rR   rW   r   N) r   r   r   r   itersectionsr   rc   rm   
has_optionrj   r   r   r   r   r   r   r.   rT   rU   rR   rK   rk   objectsrJ   baserO   rL   r-   rl   rN   rM   )rw   rS   rV   r  r   r   r   smsr   pur   r   rtr   r   s                   r5   r(  zSubmodule.iter_itemsS  s     	]++B''bD'AAFF! 	 	 	88OOO	 ??$$ &	 &	CA

3''A

3&&A"A  c&788 <

3(9::;; JEWU   !M%//!Q*?*?@E"4uz5:NNBB    HH B	 Bxxs{49CCC BHT[[]]""$&!!h33A66BOBGHHHHM&	 &	sF   -2  AA<D
E.AEE.
E($E.'E((E.-E.)NNNNNN)rY   N)FF)NNFNNNFF)FTFNFFFNNFF)TT)TFTF)T)NT)rY   r,   )rY   r-   )rY   r'   )r  )Kr:   r;   r<   r=   _id_attribute_r   rj   rm   statS_IFDIRS_IFLNKr   rK   r(   rC   rD   r   bytesr&   rB   r)   r   r'   r\   ro   classmethodr   rx   r   boolr}   r$   r   objectr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r    r!   r*   r   r  r   rI  r   rg  r   rA  rv   r   r   propertyrH   rX   r  rW   rV   rF   rb   rL  r%   r(  __classcell__)r_   s   @r5   r.   r.   W   sy	        ; ; N"NMN\DL0N "-D'+
,,,RI3L "&&*!%15 $-1   CI	
 HdN# CI Z-. 39 8T>* 
     <5 5 5 5 5 5 5 5, $; $<;T $ $ $ [$ 13 14 1 1 1 [1)C )D ) ) ) )#F #t # # # # #            
# 
 
 
 
 !E!E*/
D0@*A!ENR!E	!E !E !E [!EF         [	@D 	@=N 	@ 	@ 	@ 	@ #& # # #PX # # # [#  &+',& && & 	&
 & #& !%& & 
& & & [&P F ( x    [.  [c hl    [6  !%#'!"&.2:>%*',l ll l 	l
 39l c4i l l S$Yl 738$d*+l #8C=$#67l #l !%l 
l l l [l`  #(26 .2:>%*',f ff f !	f
 ./f f f f 738$d*+f #8C=$#67f #f !%f 
f f f fP	 j j j jd j^i j j j [jX  "f ff f 	f
 f 
f f f [fP- -j$.>(? - -Xc - - - -^ DH ,-=A	2	3   [, -s -{ - - - [-f r r r [r"t    3 3 3 3 3D 8 8 8 X8
 !X ! ! ! X! ;S ; ; ; X; S    X # # # X# c    X?01FG ? ? ? ?2,{3 2 2 2 2  175 55 Z_-5 	5
 5 
+	5 5 5 [5 5 5 5 5r7   )Lior   loggingr   r  ro  rk   git.cmdr   
git.compatr   r   
git.configr   r   r	   git.excr
   r   r   r   git.objects.baser   r   git.objects.utilr   git.utilr   r   r   r   r   r   r   os.pathrR   rg   utilr   r   r   r   r   typingr   r   r    r!   r"   r#   r$   r%   r&   	git.typesr'   r(   r)   r*   	git.indexr+   git.repor,   git.refsr-   __all__	getLoggerr  
addHandlerNullHandlerr/   r  r  r?   r@   rA   r.   r2   r7   r5   <module>r     sJ          				   



              > = = = = = = = = =            1 0 0 0 0 0 0 0 3 3 3 3 3 3                / . . . . .                    J I I I I I I I I I I I I I I I ' ' ' ' ' ' ' ' ' ' 8 8 8 8 8 8 8 8 8 8 8 8 ######
 (
) g455 "w"$$ % % %    ^    	$	r r r r r3 r r r r rr7   