
    ev                         d dl Z d dlZd dlZd dlmZmZmZ d dlmZm	Z	 d dl
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  ej        e          Z G d d	e          Z ej        e           dS )
    N)ListOptionalTuple)
BadCommandInstallationError)
HiddenTextdisplay_path)make_command)path_to_url)
RevOptionsVersionControl(find_path_to_project_root_from_repo_rootvcsc            
           e Zd ZdZdZdZdZedede	e         fd            Z
ded	ed
ededdf
dZded	ed
eddfdZded	ed
eddfdZededefd            Zededefd            Zededefd            Zededee         defd            Zededee         fd            Zededee         f fd            Z xZS )	Mercurialhgz.hgclone)zhg+filezhg+httpzhg+httpszhg+sshzhg+static-httprevreturnc                     | gS )N )r   s    R/var/www/html/api/venv/lib/python3.11/site-packages/pip/_internal/vcs/mercurial.pyget_base_rev_argszMercurial.get_base_rev_args    s	    u    desturlrev_options	verbosityNc                 r   |                                 }t                              d||t          |                     |dk    rd}n|dk    rd}n|dk    rd}nd}|                     t          d	d
g|||R             |                     t          dg||                                R  |           d S )NzCloning hg %s%s to %sr   )z--quiet   r      )	--verbose)r"   z--debugr   z
--noupdateupdatecwd)
to_displayloggerinfor	   run_commandr
   to_args)selfr   r   r   r   rev_displayflagss          r   	fetch_newzMercurial.fetch_new$   s     ",,..#		
 	
 	
 >>%1EE!^^EE!^^"EE,Eg|OeOSO$OOOPPPAEA;+>+>+@+@AAA 	 	
 	
 	
 	
 	
r   c                 J   t           j                            || j        d          }t	          j                    }	 |                    |           |                    dd|j                   t          |d          5 }|
                    |           d d d            n# 1 swxY w Y   t          dd|                                          }|                     ||           d S # t          t          j        f$ r'}t                               d||           Y d }~d S d }~ww xY w)	Nhgrcpathsdefaultwr#   -qr$   z/Could not switch Mercurial repository to %s: %s)ospathjoindirnameconfigparserRawConfigParserreadsetsecretopenwriter
   r*   r)   OSErrorNoSectionErrorr'   warning)	r+   r   r   r   repo_configconfigconfig_filecmd_argsexcs	            r   switchzMercurial.switch<   sa   gll4v>>-//		1KK$$$JJw	3:666k3'' *;[)))* * * * * * * * * * * * * * *
 $HdK4G4G4I4IJJHX400000	 45 	X 	X 	XNNLcSVWWWWWWWWW	Xs<   AC% <BC% B""C% %B"&C% %D";DD"c                     |                      ddg|           t          dd|                                          }|                      ||           d S )Npullr4   r$   r#   )r)   r
   r*   )r+   r   r   r   rF   s        r   r#   zMercurial.updateJ   s[    &$T222$0C0C0E0EFFt,,,,,r   locationc                     |                      ddgdd|                                          }|                     |          rt          |          }|                                S )N
showconfigzpaths.defaultFTshow_stdoutstdout_onlyr%   )r)   strip_is_local_repositoryr   )clsrK   r   s      r   get_remote_urlzMercurial.get_remote_urlO   sl    oo?+	  
 

 %'' 	 ##C(( 	#c""Cyy{{r   c                 `    |                      ddgdd|                                          }|S )zW
        Return the repository-local changeset revision number, as an integer.
        parentsz--template={rev}FTrN   r)   rQ   )rS   rK   current_revisions      r   get_revisionzMercurial.get_revision[   sD    
 ??*+	 + 
 

 %'' 	  r   c                 `    |                      ddgdd|                                          }|S )zh
        Return the changeset identification hash, as a 40-character
        hexadecimal string
        rV   z--template={node}FTrN   rW   )rS   rK   current_rev_hashs      r   get_requirement_revisionz"Mercurial.get_requirement_revisionh   sD     ??+,	 + 
 

 %'' 	  r   namec                     dS )z&Always assume the versions don't matchFr   )rS   r   r]   s      r   is_commit_id_equalzMercurial.is_commit_id_equalv   s	     ur   c                 2   |                      dgdd|                                          }t          j                            |          s=t          j                            t          j                            ||                    }t          ||          S )z
        Return the path to Python project root, relative to the repo root.
        Return None if the project root is in the repo root.
        rootFTrN   )r)   rQ   r5   r6   isabsabspathr7   r   )rS   rK   	repo_roots      r   get_subdirectoryzMercurial.get_subdirectory{   s     OOH%Tx $ 
 

%'' 	 w}}Y'' 	KXy(I(IJJI7)LLLr   c                 ^   t                                          |          }|r|S 	 |                     dg|dddd          }n8# t          $ r t                              d|           Y d S t          $ r Y d S w xY wt          j        	                    |
                    d                    S )Nra   FTraise)r%   rO   rP   on_returncodelog_failed_cmdzIcould not determine if %s is under hg control because hg is not availablez
)superget_repository_rootr)   r   r'   debugr   r5   r6   normpathrstrip)rS   rK   locr	__class__s       r   rk   zMercurial.get_repository_root   s    gg))(33 	J	! %$    AA  	 	 	LL.  
 44  	 	 	44	w 0 0111s   A %A:-	A:9A:)__name__
__module____qualname__r]   r8   	repo_nameschemesstaticmethodstrr   r   r   r   intr.   rH   r#   classmethodrT   rY   r\   r   boolr_   re   rk   __classcell__)rq   s   @r   r   r      s:       DGIG s tCy    \

(
7A
NQ
	
 
 
 
013 1Z 1j 1T 1 1 1 1-3 -Z -j -T - - - -
 	c 	c 	 	 	 [	 
 C 
 C 
  
  
  [
            [  c # 4    [ M M M M M [M 23 28C= 2 2 2 2 2 [2 2 2 2 2r   r   )r9   loggingr5   typingr   r   r   pip._internal.exceptionsr   r   pip._internal.utils.miscr   r	   pip._internal.utils.subprocessr
   pip._internal.utils.urlsr    pip._internal.vcs.versioncontrolr   r   r   r   	getLoggerrr   r'   r   registerr   r   r   <module>r      s2        				 ( ( ( ( ( ( ( ( ( ( B B B B B B B B = = = = = = = = 7 7 7 7 7 7 0 0 0 0 0 0            
	8	$	$L2 L2 L2 L2 L2 L2 L2 L2^ Y     r   