+
    WGj"                    4   ^ RI Ht ^ RIt^ RIt^ RIt^ RIt^ RIt^ RIHt ^ RI	H
t
HtHtHtHt ^ RIHtHtHt ^ RIHt ^ RIHt ]P.                  ! ]4      t ! R R	4      t ! R
 R]P6                  4      t]! R]],          R7      t ! R R4      t]! 4       tR# )    )annotationsN)Path)
CollectionSequenceTypeTypeVarcast)UnpackErrorURLErrorVCSBackendError)Link)compare_urlsc                  >    ] tR t^tRtR R ltR R ltR R ltRtR	# )

HiddenTextz1A string that redacts the auth info from the URL.c               $    V ^8  d   QhRRRRRR/# )   secretstrredactedreturnNone )formats   "0lib/python3.14/site-packages/unearth/vcs/base.py__annotate__HiddenText.__annotate__   s!     ! !s !c !d !    c                	    Wn         W n        R # N)r   r   )selfr   r   s   &&&r   __init__HiddenText.__init__   s     r   c                   V ^8  d   QhRR/# r   r   r   r   )r   s   "r   r   r      s       r   c                	    V P                   # r   )r   r    s   &r   __str__HiddenText.__str__   s    }}r   c                   V ^8  d   QhRR/# r$   r   )r   s   "r   r   r      s     & &# &r   c                	"    R \        V 4      : R2# )z<URL >)r   r&   s   &r   __repr__HiddenText.__repr__   s    s4ym1%%r   )r   r   N)	__name__
__module____qualname____firstlineno____doc__r!   r'   r,   __static_attributes__r   r   r   r   r      s    ;!& &r   r   c                  d   ] tR t^ t$ RtR]R&   R]R&   R%R R lltR&R R	 lltR
 R ltR R lt	R R lt
]P                  R R l4       t]P                  R R l4       t]P                  R R l4       t]P                  R R l4       tR R ltR R ltR R ltR R ltR  R! ltR" R# ltR$tR# )'VersionControlzThe base class for all version control systems.

Attributes:
    name: the backend name
    dir_name: the backend data directory, such as '.git'
    action: the word to describe the clone action.
r   namedir_namec                    V ^8  d   QhRRRR/# )r   	verbosityintr   r   r   )r   s   "r   r   VersionControl.__annotate__,   s     # ## #d #r   c                	    Wn         R # r   r9   )r    r9   s   &&r   r!   VersionControl.__init__,   s    "r   Nc               4    V ^8  d   QhRRRRRRRRR	RR
RRR/# )r   cmdzSequence[str | HiddenText]cwdzPath | None	extra_envzdict[str, str] | None
log_outputboolstdout_onlyextra_ok_returncodeszCollection[int]r   z subprocess.CompletedProcess[str]r   )r   s   "r   r   r;   /   sP     * *'* * )	*
 * * .* 
**r   c           
        RpV'       d   \        \        P                  3/ VB p V P                  .VOp\        P
                  ! \        \        V4      4      p\        P                  RV4       \        P                  ! V U	u. uF'  p	\        V	\        4      '       d   V	P                  MT	NK)  	  up	V'       d   \        V4      MRR\        P                  V'       d   \        P                  M\        P                   VRR7      p
V'       d.   \        P                  V
P"                  P%                  4       4       V
# u up	i   \        P&                   d   pTP(                  T9   dq   T'       d.   \        P                  TP"                  P%                  4       4       \        P*                  ! TP,                  TP(                  TP"                  4      u Rp?# \/        TP0                  4      RhRp?i\2         d`    \        P                  RT P                   R\        P                  P5                  R4       24       RT P                   R	2p\3        T4      Rhi ; i)
z/Run the command in the given working directory.NzRunning command %sT)rA   checkstdoutstderrenvtextzCannot find `z`, PATH=PATHzUnable to find executable `z$`, make sure it's installed in PATH.)dictosenvironr6   
subprocesslist2cmdlinemapr   loggerdebugrun
isinstancer   r   PIPEDEVNULLSTDOUTrI   rstripCalledProcessError
returncodeCompletedProcessargsr
   outputFileNotFoundErrorget)r    r@   rA   rB   rC   rE   rF   rK   display_cmdvresultemsgs   &&&&&&&      r   run_commandVersionControl.run_command/   s    rzz/Y/C	99#s#C$11#c3-@KLL-{;^^GJKs!Z:66A=sK #CH!-8z))j>O>OF. V]]1134M1 L ,, 	2||33LL!23!221661<<RRahh'T1  	3LL=8BJJNN6<R;STU-dii[ 94 4  $C(d2	3sP   AE -D<0	E :#E 'E <E IG-/A"G-IG--I:A Ic                    V ^8  d   QhRRRR/# )r   repor   r   rD   r   )r   s   "r   r   r;   [   s     ; ; ; ;r   c                    \         P                  P                  V4      w  r#VP                  \         P                  P                  4      ;'       g    \        V4      # )z[
posix absolute paths start with os.path.sep,
win32 ones start with drive (like c:\folder)
)rO   path
splitdrive
startswithseprD   )r    rk   drive_s   &&  r   _is_local_repository#VersionControl._is_local_repository[   s=    
 77%%d+rww{{+::tE{:r   c                    V ^8  d   QhRRRR/# )r   linkr   r   z5tuple[HiddenText, str | None, list[str | HiddenText]]r   )r   s   "r   r   r;   c   s     % %%	>%r   c                   VP                   pVP                  P                  R^4      R,          pV P                  VP                  V4      w  rEpVe   \        VR4      pRVP                  P                  R^4      R,          RVRR/pRVP                  9  d   RpMDVP                  P                  R4      w  rpV'       g   \        R	VP                  : R
24      hWR&   V P                  V\        \
        V4      4      pVP                  ! R/ VB P                  4       p\        V\        V4      P                  4      pWV3# )z/Get the URL and revision options from the link.+Nz***schemenetlocfragment @zThe url z\ has an empty revision (after @).You should specify a revision or remove the @ from the URL.rm   r   )parsedry   rsplitget_netloc_and_authrz   r   rm   
rpartitionr   r   make_auth_argsr	   _replacegeturlr   )r    rv   r   ry   rz   userpasswordreplace_dictrevrm   rr   r_   url
hidden_urls   &&            r   get_url_and_rev_options&VersionControl.get_url_and_rev_optionsc   s2    %%c1-b1!%!9!9&--!Ph!(E2Hfmm**3226f

 fkk!C!;;11#6LDSt}}/ 0R R  $( ""4j()CDoo--446T#Y%7%78
$$r   c               $    V ^8  d   QhRRRRRR/# )r   rv   r   locationr   r   r   r   )r   s   "r   r   r;      s!     ) )$ )$ )4 )r   c                   V P                  V4      w  r4pVP                  4       '       g   V P                  W#WE4      # V P                  V4      '       d,   \	        VP
                  V P                  V4      4      '       g   V P                  V4      '       g   \        P                  V R24       M1V P                  V4      p\        P                  V RV: RV: R24       \        P                  ! V4       V P                  W#WE4      # V P                  W$4      '       d   \        P                  RV4       R# V P                  W$V4       R# )zClone the repository to the destination directory, and return
the path to the local repository.

Args:
    link (Link): the VCS link to the repository
    location (Path): the destination directory
z, is not a repository directory, removing it.z/ is a repository directory, but the remote url z does not match the url .z#Repository %s is already up-to-dateN)r   exists	fetch_newis_repository_dirr   r   get_remote_urlrT   rU   shutilrmtreeis_commit_hash_equalupdate)r    rv   r   r   r   r_   
remote_urls   &&&    r   fetchVersionControl.fetch   s    55d;$  >>(;;%%h//|JJ++H58
 8
 ))(33z)UVW!00:
j O!n$<SG1F MM(#>>(;;$$X33LL>IH4(r   c          
     ,    V ^8  d   QhRRRRRRRRR	R
/# )r   r   r   r   r   r   
str | Noner_   list[str | HiddenText]r   r   r   )r   s   "r   r   r;      s<        	
 % 
r   c                    R# )a'  Fetch the repository from the remote link, as if it is the first time.

Args:
    location (Path): the repository location
    link (Link): the VCS link to the repository
    rev (str|None): the revision to checkout
    args (list[str | HiddenText]): the arguments to pass to the update command
Nr   )r    r   r   r   r_   s   &&&&&r   r   VersionControl.fetch_new   s      	r   c               (    V ^8  d   QhRRRRRRRR/# )	r   r   r   r   r   r_   r   r   r   r   )r   s   "r   r   r;      s,     
 

#-
5K
	
r   c                    R# )zUpdate the repository to the given revision.

Args:
    location (Path): the repository location
    rev (str|None): the revision to checkout
    args (list[str | HiddenText]): the arguments to pass to the update command
Nr   )r    r   r   r_   s   &&&&r   r   VersionControl.update   s     	r   c                    V ^8  d   QhRRRR/# r   r   r   r   r   r   )r   s   "r   r   r;      s      t  r   c                    R# )z%Get the remote URL of the repository.r|   r   r    r   s   &&r   r   VersionControl.get_remote_url   s     r   c                    V ^8  d   QhRRRR/# r   r   )r   s   "r   r   r;      s      T c r   c                    R# )z&Get the commit hash of the repository.Nr   r   s   &&r   get_revisionVersionControl.get_revision   s     	r   c               $    V ^8  d   QhRRRRRR/# )r   r   r   rv   r   r   rD   r   )r   s   "r   r   r;      s!      d $ 4 r   c                    R# )zlCheck if the revision is immutable.
Always return False if the backend doesn't support immutable revisions.
Fr   )r    r   rv   s   &&&r   is_immutable_revision$VersionControl.is_immutable_revision   s     r   c                    V ^8  d   QhRRRR/# )r   r   r   r   z	list[str]r   )r   s   "r   r   r;      s     0 0
 0y 0r   c                    Ve   V.# . # )z+Get the revision arguments for the command.r   )r    r   s   &&r   get_rev_argsVersionControl.get_rev_args   s    u/R/r   c               $    V ^8  d   QhRRRRRR/# )r   r   r   r   r   r   rD   r   )r   s   "r   r   r;      s!      T 
 t r   c                    R# )z&Always assume the versions don't matchFr   )r    r   r   s   &&&r   r   #VersionControl.is_commit_hash_equal   s    r   c                    V ^8  d   QhRRRR/# )r   r   r   r   rD   r   )r   s   "r   r   r;      s     9 9$ 94 9r   c                T    VP                  V P                  4      P                  4       # )z7Check if the given directory is a repository directory.)joinpathr7   r   r   s   &&r   r    VersionControl.is_repository_dir   s       /6688r   c               $    V ^8  d   QhRRRRRR/# )r   rz   r   ry   r   z"tuple[str, str | None, str | None]r   )r   s   "r   r   r;      s$     " ""#&"	+"r   c                    VRR3# )zcGet the auth info and the URL from the link.
For VCS like git, the auth info must stay in the URL.
Nr   )r    rz   ry   s   &&&r   r   "VersionControl.get_netloc_and_auth   s     tT!!r   c               $    V ^8  d   QhRRRRRR/# )r   r   r   r   zHiddenText | Noner   r   r   )r   s   "r   r   r;      s$      *;	r   c                    . # )zMake the auth args for the URL.r   )r    r   r   s   &&&r   r   VersionControl.make_auth_args   s	     	r   r=   r   )NNTFr   )r.   r/   r0   r1   r2   __annotations__r!   rh   rs   r   r   abcabstractmethodr   r   r   r   r   r   r   r   r   r   r3   r   r   r   r5   r5       s     IM#*X;%:)> 	 " 	
 
 	  	 09" r   r5   _V)boundc                  J    ] tR t^tR R ltR R ltR R ltRR R lltR	tR
# )
VcsSupportc                   V ^8  d   QhRR/# r   r   r   r   )r   s   "r   r   VcsSupport.__annotate__   s     = =$ =r   c                	    / V n         R # r   	_registryr&   s   &r   r!   VcsSupport.__init__   s	    :<r   c                    V ^8  d   QhRRRR/# )r   vcsr   r   r   )r   s   "r   r   r      s      B 2 r   c                	6    WP                   VP                  &   V# r   )r   r6   )r    r   s   &&r   registerVcsSupport.register   s    #&sxx 
r   c                   V ^8  d   QhRR/# r   r   )r   s   "r   r   r      s       r   c                	:    V P                   P                  4        R # r   )r   clearr&   s   &r   unregister_allVcsSupport.unregister_all   s    r   c               $    V ^8  d   QhRRRRRR/# )r   r6   r   r9   r:   r   r5   r   )r   s   "r   r   r      s!     2 2 2 2N 2r   c                	n     V P                   V,          ! VR 7      #   \         d    \        T4      Rhi ; i)r=   N)r   KeyErrorr   )r    r6   r9   s   &&&r   get_backendVcsSupport.get_backend   s7    	2>>$')<< 	2!$'T1	2s    4r   Nr   )	r.   r/   r0   r1   r!   r   r   r   r3   r   r   r   r   r      s    =2 2r   r   ) 
__future__r   r   loggingrO   r   rQ   pathlibr   typingr   r   r   r   r	   unearth.errorsr
   r   r   unearth.linkr   unearth.utilsr   	getLoggerr.   rT   r   ABCr5   r   r   vcs_supportr   r   r   <module>r      s    " 
  	    < < A A  &			8	$& &FSWW FR Tn-.2 2$ lr   