
    Wh                        d dl mZ d dlZd dlZd dl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 )
    )annotationsN)
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 d	            Zd!dZ		 d"d!dZ
	 d"d!dZed#d            Zed#d            Zed#d            Zed$d            Zed%d            Zed% fd            Z xZS )&	Mercurialhgz.hgclone)zhg+filezhg+httpzhg+httpszhg+sshzhg+static-httprevstrreturn	list[str]c                    d|  gS )Nz--rev= )r   s    m/var/www/tools.fuzzalab.pt/emblema-extractor/venv/lib/python3.11/site-packages/pip/_internal/vcs/mercurial.pyget_base_rev_argszMercurial.get_base_rev_args!   s        desturlr   rev_optionsr
   	verbosityintNonec                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   r   c                   g }t           j                            || j        d          }t	          j                    }|dk    r|                    d           	 |                    |           |                    dd|j	                   t          |d          5 }|                    |           d d d            n# 1 swxY w Y   t          dg||                                R  }	|                     |	|           d S # t          t          j        f$ r'}
t"                              d	||
           Y d }
~
d S d }
~
ww xY w)
Nhgrcr   -qpathsdefaultwr%   r&   z/Could not switch Mercurial repository to %s: %s)ospathjoindirnameconfigparserRawConfigParserappendreadsetsecretopenwriter   r,   r+   OSErrorNoSectionErrorr)   warning)r-   r   r   r   r   extra_flagsrepo_configconfigconfig_filecmd_argsexcs              r   switchzMercurial.switch=   s    gll4v>>-//>>t$$$		1KK$$$JJw	3:666k3'' *;[)))* * * * * * * * * * * * * * *
 $HR{RK<O<O<Q<QRRRH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D  B;/D  ;B??D  B?D   D=D88D=c                    g }|dk    r|                     d           |                     dg||           t          dg||                                R  }|                     ||           d S )Nr   r3   pullr&   r%   )r=   r+   r   r,   )r-   r   r   r   r   rF   rJ   s          r   r%   zMercurial.updateV   s     >>t$$$&/;/T:::N;N8K8K8M8MNNNt,,,,,r   locationc                    |                      ddgdd|                                          }|                     |          rt          |          }|                                S )N
showconfigzpaths.defaultFTshow_stdoutstdout_onlyr'   )r+   strip_is_local_repositoryr	   )clsrO   r   s      r   get_remote_urlzMercurial.get_remote_urlf   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}FTrR   r+   rU   )rW   rO   current_revisions      r   get_revisionzMercurial.get_revisionr   sD    
 ??*+	 + 
 

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

 %'' 	  r   name
str | Noneboolc                    dS )z&Always assume the versions don't matchFr   )rW   r   ra   s      r   is_commit_id_equalzMercurial.is_commit_id_equal   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.
        rootFTrR   )r+   rU   r7   r8   isabsabspathr9   r   )rW   rO   	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 )Nrg   FTraise)r'   rS   rT   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   r7   r8   normpathrstrip)rW   rO   locr	__class__s       r   rq   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:)r   r   r   r   )
r   r   r   r   r   r
   r   r   r   r    )r   )rO   r   r   r   )r   r   ra   rb   r   rc   )rO   r   r   rb   )__name__
__module____qualname__ra   r:   	repo_nameschemesstaticmethodr   r0   rL   r%   classmethodrX   r]   r`   re   rk   rq   __classcell__)rw   s   @r   r   r      ss       DGIG       \ 
 
 
 
: 1 1 1 1 1< - - - - -  	 	 	 [	 
  
  
  [
        [     [ M M M [M 2 2 2 2 2 [2 2 2 2 2r   r   )
__future__r   r;   loggingr7   pip._internal.exceptionsr   r   pip._internal.utils.miscr   r   pip._internal.utils.subprocessr   pip._internal.utils.urlsr	    pip._internal.vcs.versioncontrolr
   r   r   r   	getLoggerrx   r)   r   registerr   r   r   <module>r      s&   " " " " " "      				 B B B B B B B B = = = = = = = = 7 7 7 7 7 7 0 0 0 0 0 0            
	8	$	$b2 b2 b2 b2 b2 b2 b2 b2J Y     r   