
    q"hH                        S SK r S SKrS SKrS SKrS SKrS SKrS SKJ	r	  S SK
JrJrJrJr  S SKJrJr  S SKJrJrJr  S SKJr  S SKJrJrJrJrJrJrJr  \R@                  RB                  r!\R@                  RD                  r"\ RF                  " \$5      r%\RL                  " S5      r'\RL                  " S	5      r(\RL                  " S
\RR                  5      r*S\+S\,4S jr- " S S\5      r.\R^                  " \.5        g)    N)replace)AnyListOptionalTuple)
BadCommandInstallationError)
HiddenTextdisplay_pathhide_url)make_command)AuthInfoRemoteNotFoundErrorRemoteNotValidError
RevOptionsVersionControl(find_path_to_project_root_from_repo_rootvcsz(^git version (\d+)\.(\d+)(?:\.(\d+))?.*$z^[a-fA-F0-9]{40}$a/  ^
    # Optional user, e.g. 'git@'
    (\w+@)?
    # Server, e.g. 'github.com'.
    ([^/:]+):
    # The server-side path. e.g. 'user/project.git'. Must start with an
    # alphanumeric character so as not to be confusable with a Windows paths
    # like 'C:/foo/bar' or 'C:\foo\bar'.
    (\w[^:]*)
    $shareturnc                 >    [        [        R                  U 5      5      $ N)bool
HASH_REGEXmatch)r   s    G/var/www/html/env/lib/python3.13/site-packages/pip/_internal/vcs/git.pylooks_like_hashr   8   s    
  %&&    c            
         ^  \ rS rSrSrSrSrSrSrSr	\
S\S	\\   4S
 j5       r\S\S\S	\4U 4S jj5       rS\S\S	\4S jrS	\\S4   4S jr\S\S	\\   4S j5       r\S\S\S	\\\   \4   4S j5       r\S\S\S	\4S j5       r\S\S\S\S	\4S j5       r\S\S\\   S	\4S j5       rS\S\S\S\S	S4
S jrS\S\S\S	S4S jrS\S\S\S	S4S jr \S\S	\4S  j5       r!\
S\S	\4S! j5       r"\S\S\S	\4S" j5       r#\S+S\S\\   S	\4S# jj5       r$\S\S	\\   4S$ j5       r%\S\S	\\\\   \&4   4U 4S% jj5       r'\S\S	S4S& j5       r(\S\S	\\   4U 4S' jj5       r)\
S(\S	\4S) j5       r*S*r+U =r,$ ),Git<   gitz.gitclone)zgit+httpz	git+httpszgit+sshzgit+gitzgit+file)GIT_DIRGIT_WORK_TREEHEADrevr   c                     U /$ r    r'   s    r   get_base_rev_argsGit.get_base_rev_argsL   s	    ur   argskwargsc                    > [         R                  R                  S5      (       a   UR                  S0 5      nSUS'   SUS'   X2S'   [        TU ]  " U0 UD6$ )NPIP_NO_INPUTextra_environ0GIT_TERMINAL_PROMPTzssh -oBatchMode=yesGIT_SSH_COMMAND)osenvirongetsuperrun_command)clsr-   r.   r1   	__class__s       r   r9   Git.run_commandP   sY    ::>>.))"JJ;M36M/0/DM+,&3?#w"D3F33r   urldestc                     U R                  [        U5      5      u  p4UR                  (       d  gU R                  X$R                  5      (       d  g[	        U R                  X$R                  5      S   5      nU(       + $ )NFr   )get_url_rev_optionsr   r'   is_commit_id_equalr   get_revision_sha)selfr=   r>   _rev_optionsis_tag_or_branchs         r   is_immutable_rev_checkoutGit.is_immutable_rev_checkoutY   sf    11(3-@&&t__==    5 5dOO LQ OP###r   .c                     U R                  S/SSSS9n[        R                  U5      nU(       d  [        R	                  SU5        g[        UR                  S5      5      [        UR                  S	5      5      4$ )
Nversionzgit versionFT)command_descshow_stdoutstdout_onlyzCan't parse git version: %sr)         )r9   GIT_VERSION_REGEXr   loggerwarningintgroup)rC   rJ   r   s      r   get_git_versionGit.get_git_versiong   sq    ""K&	 # 
 "''0NN8'BEKKN#SQ%899r   locationc                     / SQnU R                  USSSUS9nUR                  5       nUR                  S5      (       a  U[        S5      S $ g)zT
Return the current branch, or None if HEAD isn't at a branch
(e.g. detached HEAD).
)zsymbolic-ref-qr&   rN   FTextra_ok_returncodesrL   rM   cwdzrefs/heads/N)r9   strip
startswithlen)r:   rW   r-   outputrefs        r   get_current_branchGit.get_current_brancht   s]     .!% ! 
 lln>>-((s=)+,,r   c                    U R                  SU/USSSS9n0 nUR                  5       R                  S5       H4  nUR                  S5      nU(       d  M   UR                  SS	S
9u  pgXdU'   M6     SU 3nSU 3n	UR                  U5      n
U
b  U
S4$ UR                  U	5      n
U
S4$ ! [         a    [	        SU< 35      ef = f)z
Return (sha_or_none, is_branch), where sha_or_none is a commit hash
if the revision names a remote branch or tag, otherwise None.

Args:
  dest: the repository directory.
  rev: the revision name.
zshow-refFTignore)r]   rL   rM   on_returncode
 rO   )maxsplitzunexpected show-ref line: zrefs/remotes/origin/z
refs/tags/)r9   r^   splitrstrip
ValueErrorr7   )r:   r>   r'   ra   refslineref_sharef_name
branch_reftag_refr   s              r   rB   Git.get_revision_sha   s     " ! 
  LLN((.D;;t$DH$(JJsQJ$?! %N / ,C51
se$hhz"?;hhwU|!  H !#=dX!FGGHs   B&&C c                     UR                  S5      (       a  g[        U5      (       d  gU R                  X5      (       a  gg)z
Return true if rev is a ref or is a commit that we don't have locally.

Branches and tags are not considered in this method because they are
assumed to be always available locally (which is a normal outcome of
``git clone`` and ``git fetch --tags``).
zrefs/TF)r_   r   
has_commit)r:   r>   r'   s      r   _should_fetchGit._should_fetch   s9     >>'""s##>>$$$r   rE   c           	         UR                   nUc   eU R                  X5      u  pVUb%  UR                  U5      n[        X6(       a  UOSS9nU$ [	        U5      (       d  [
        R                  SU5        U R                  X5      (       d  U$ U R                  [        SSX#R                  5       5      US9  U R                  USS9nUR                  U5      nU$ )	z
Resolve a revision to a new RevOptions object with the SHA1 of the
branch, tag, or ref if found.

Args:
  rev_options: a RevOptions object.
N)branch_namez:Did not find branch or tag '%s', assuming revision or ref.fetchrY   r]   
FETCH_HEADr*   )arg_revrB   make_newr   r   rQ   rR   rx   r9   r   to_argsget_revision)r:   r>   r=   rE   r'   r   	is_branchs          r   resolve_revisionGit.resolve_revision   s     !! --d8?%..s3K!+9CRVXK s##NNL
   ++ 	$-@-@-BC 	 	

 t6!**3/r   namec                 :    U(       d  gU R                  U5      U:H  $ )z
Return whether the current commit hash equals the given name.

Args:
  dest: the repository directory.
  name: a string name.
F)r   )r:   r>   r   s      r   rA   Git.is_commit_id_equal   s      %--r   	verbosityNc                 d   UR                  5       n[        R                  SX%[        U5      5        US::  a  SnOUS:X  a  SnOSnU R	                  5       S:  a!  U R                  [        SS	/UQUPUP76 5        OU R                  [        S/UQUPUP76 5        UR                  (       a  U R                  XU5      n[        US
S 5      n[        R                  SX75        UcK  U R                  XR                  5      (       d*  [        SSUR                  5       5      nU R                  XS9  OSU R                  U5      U:w  a  SU 3n	SSUSU	/nU R                  XS9  O"U R                  U5      n
UR                  U
5      n[        R                  SX#R                  5        U R!                  U5        g )NzCloning %s%s to %sr   )z--quietrN   r)   )z	--verbosez
--progress)rO      r#   z--filter=blob:noner{   zRev options %s, branch_name %scheckoutrY   r}   zorigin/z-bz--trackzResolved %s to commit %s)
to_displayrQ   infor   rU   r9   r   r'   r   getattrdebugrA   r   rc   r   r   update_submodules)rC   r>   r=   rE   r   rev_displayflagsr{   cmd_argstrack_branchr   s              r   	fetch_newGit.fetch_new  s    ",,.(#L<NO>%1E!^E/E!W, (  	
  \'EEE3EEF??//;GK!+}dCKLL9;T" ..t__EE+"#++- H
 $$X$8((.+= ")6     4##D)C%..s3K.__E 	t$r   c                     U R                  [        SSU5      US9  [        SSUR                  5       5      nU R                  XAS9  U R                  U5        g )Nconfigzremote.origin.urlr}   r   rY   )r9   r   r   r   rC   r>   r=   rE   r   s        r   switch
Git.switchN  s]    #6< 	 	
  
D+2E2E2GH,t$r   c                    U R                  5       S:  a  U R                  / SQUS9  OU R                  SS/US9  U R                  XU5      n[        SSSUR	                  5       5      nU R                  XAS9  U R                  U5        g )N)rN   	   )r|   rY   z--tagsr}   r|   rY   resetz--hard)rU   r9   r   r   r   r   r   s        r   update
Git.updateX  s    !V+6DAgt_$7++D{C49L9L9NO,t$r   c                 ,   U R                  / SQSSSUS9nUR                  5       n US   nU H  nUR	                  S5      (       d  M  Un  O   UR                  S5      S	   nU R                  UR                  5       5      $ ! [         a    [        ef = f)
z
Return URL of the first remote encountered.

Raises RemoteNotFoundError if the repository does not have a remote
url configured.
)r   z--get-regexpzremote\..*\.urlrZ   FTr[   r   zremote.origin.url rj   rN   )r9   
splitlines
IndexErrorr   r_   rl   _git_remote_to_pip_urlr^   )r:   rW   stdoutremotesfound_remoteremoter=   s          r   get_remote_urlGit.get_remote_urlf  s     :!% ! 
 ##%	&"1:L F  !566%    %a())#))+66  	&%%	&s   B Bc                 >   [         R                  " SU 5      (       a  U $ [        R                  R	                  U 5      (       a$  [
        R                  " U 5      R                  5       $ [        R                  U 5      nU(       a  UR                  S5      $ [        U 5      e)a  
Convert a remote url from what git uses to what pip accepts.

There are 3 legal forms **url** may take:

    1. A fully qualified url: ssh://git@example.com/foo/bar.git
    2. A local project.git folder: /path/to/bare/repository.git
    3. SCP shorthand for form 1: git@example.com:foo/bar.git

Form 1 is output as-is. Form 2 must be converted to URI and form 3 must
be converted to form 1.

See the corresponding test test_git_remote_url_to_pip() for examples of
sample inputs/outputs.
z\w+://zssh://\1\2/\3)rer   r5   pathexistspathlibPurePathas_uri	SCP_REGEXexpandr   )r=   	scp_matchs     r   r   Git._git_remote_to_pip_url  sw    " 88Is##J77>># ##C(//11OOC(	##$455!#&&r   c                 V     U R                  SSSSU-   /USS9  g! [         a     gf = f)zE
Check if rev is a commit that is available in the local repository.
	rev-parserY   z--verifyzsha^F)r]   log_failed_cmdT)r9   r	   )r:   rW   r'   s      r   rw   Git.has_commit  sG    
		OOdJ=$    ! 		s    
((c                 T    Uc  SnU R                  SU/SSUS9nUR                  5       $ )Nr&   r   FTrL   rM   r]   )r9   r^   )r:   rW   r'   current_revs       r   r   Git.get_revision  sA    ;Coo#	 & 
   ""r   c                 \   U R                  SS/SSUS9R                  5       n[        R                  R	                  U5      (       d  [        R                  R                  X5      n[        R                  R                  [        R                  R                  US5      5      n[        X5      $ )zy
Return the path to Python project root, relative to the repo root.
Return None if the project root is in the repo root.
r   z	--git-dirFTr   z..)r9   r^   r5   r   isabsjoinabspathr   )r:   rW   git_dir	repo_roots       r   get_subdirectoryGit.get_subdirectory  s     //+&	 " 

 %' 	 ww}}W%%ggll85GGGOOBGGLL$$?@	7LLr   c                   > [        U5      u  p#pEnUR                  S5      (       a  US[        UR                  S5      5      *  nU[        R
                  R                  U5      R                  SS5      R                  S5      -   nUR                  S5      S-   n	USU	 [        X)S X8XV45      -   nSU;  a?  SU;  d   eUR                  S	S
5      n[        TU ]-  U5      u  pnUR                  SS5      nO[        TU ]-  U5      u  pnXU4$ )a  
Prefixes stub URLs like 'user@hostname:user/repo.git' with 'ssh://'.
That's required because although they use SSH they sometimes don't
work with a ssh:// scheme (e.g. GitHub). But we need a scheme for
parsing. Hence we remove it again afterwards and return it as a stub.
fileN/\+rN   z://zfile:zgit+z
git+ssh://zssh:// )urlsplitendswithr`   lstripurllibrequesturl2pathnamer   find
urlunsplitr8   get_url_rev_and_auth)r:   r=   schemenetlocr   queryfragmentinitial_slashesnewpath
after_plusr'   	user_passr;   s               r   r   Git.get_url_rev_and_auth  s    19-X??6"""#;c$++c*:&;%;<O%(C(CD(I(Q(Qc)fSkG  S)A-J*%
$fuG) C #%%%++fl3C"''">s"CCi++h+C"''">s"CCi""r   c                     [         R                  R                  [         R                  R                  US5      5      (       d  g U R	                  / SQUS9  g )Nz.gitmodules)	submoduler   z--initz--recursiverY   r}   )r5   r   r   r   r9   )r:   rW   s     r   r   Git.update_submodules  s>    ww~~bggll8]CDDB 	 	
r   c           	         > [         TU ]  U5      nU(       a  U$  U R                  SS/USSSSS9n[        R                  R                  UR                  S5      5      $ ! [         a    [        R                  SU5         g [         a     g f = f)	Nr   z--show-toplevelFTraise)r]   rL   rM   rg   r   zKcould not determine if %s is under git control because git is not availablez
)r8   get_repository_rootr9   r   rQ   r   r	   r5   r   normpathrm   )r:   rW   locrr;   s       r   r   Git.get_repository_root  s    g)(3J	/0! %$   A" ww 011  	LL/
   		s   A  B	BBrepo_urlc                     g)zEIn either https or ssh form, requirements must be prefixed with git+.Tr)   )r   s    r   should_add_vcs_url_prefixGit.should_add_vcs_url_prefix  s     r   r)   r   )-__name__
__module____qualname____firstlineno__r   dirname	repo_nameschemesunset_environdefault_arg_revstaticmethodstrr   r+   classmethodr   r9   r   rG   r   rS   rU   r   rc   rB   rx   r
   r   r   rA   r   r   r   r   r   rw   r   r   r   r   r   r   r   __static_attributes____classcell__)r;   s   @r   r    r    <   sY   DGIG 1MOs tCy   4 4s 4s 4 4$S $ $ $:sCx : # (3-  0 +C +c +eHSM4<O6P + +Z  3 4  , ++'+6@+	+ +Z .c .# .4 . .=%=%(=%7A=%NQ=%	=%~%3 %Z %j %T %%3 %Z %j %T % 7c 7c 7 7: 'C 'C ' '< # C D   	#C 	#hsm 	#s 	# 	# M M M M" #s #uS(3-5Q/R # #< 
 
 
 
 23 28C= 2 20 C D  r   r    )0loggingos.pathr5   r   r   urllib.parser   urllib.requestdataclassesr   typingr   r   r   r   pip._internal.exceptionsr   r	   pip._internal.utils.miscr
   r   r   pip._internal.utils.subprocessr    pip._internal.vcs.versioncontrolr   r   r   r   r   r   r   parser   r   	getLoggerr   rQ   compilerP   r   VERBOSEr   r   r   r   r    registerr)   r   r   <module>r
     s       	    - - B G G 7   <<  \\$$
 
		8	$ JJ  ZZ+,
 JJ		 JJ	' ' 'Y. Yx S r   