Q[dZddlmZddlZddlZddlZddlZddlZddl m Z m Z m Z ddl mZmZddlmZmZmZddlmZddlmZmZdd lmZmZmZmZmZmZm Z m!Z!dd l"m#Z#m$Z$m%Z%m&Z&d gZ'ej(e)Z*e+ee,ee,fZ-d&dZ. d'd(dZ/d)dZ0Gdde1Z2Gdde1Z3edGd d!Z4Gd"d#Z5e5Z6Gd$d%Z7dS)*z)Handles all VCS (version control) support) annotationsN)IterableIteratorMapping) dataclassfield)AnyLiteralOptional)SpinnerInterface) BadCommandInstallationError) HiddenTextask_path_exists backup_dir display_pathhide_url hide_valueis_installable_dirrmtree) CommandArgscall_subprocessformat_command_args make_commandvcsnamestrreturnboolcxtj|j}|sdS|gdtjzvS)z3 Return true if the name looks like a URL. F)httphttpsfileftp)urllibparseurlsplitschemer all_schemes)rr(s r/builddir/build/BUILD/cloudlinux-venv-1.0.10/venv/lib/python3.11/site-packages/pip/_internal/vcs/versioncontrol.pyis_urlr+-sB\ " "4 ( ( /F u 555G GGrepo_urlrev project_namesubdir str | NonecZ|dd}|d|d|}|r|d|z }|S)z Return the URL for a VCS requirement. Args: repo_url: the remote VCS url, with any needed VCS prefix (e.g. "git+"). project_name: the (unescaped) project name. -_@z#egg=z&subdirectory=)replace)r-r.r/r0egg_project_namereqs r*make_vcs_requirement_urlr97sV$++C55  4 4 4 4"2 4 4C ) (((( Jr,location repo_rootcN|}t|sS|}tj|}||krtd|dSt|Stj||rdStj||S)z Find the the Python project's root by searching up the filesystem from `location`. Return the path to project root relative to `repo_root`. Return None if the project root is `repo_root`, or cannot be found. zOCould not find a Python project for directory %s (tried all parent directories)N)rospathdirnameloggerwarningsamefilerelpath)r:r; orig_location last_locations r*(find_path_to_project_root_from_repo_rootrFIsM **  7??8,, } $ $ NN&    4!**  w 8,,t 7??8Y / //r,ceZdZdS)RemoteNotFoundErrorN)__name__ __module__ __qualname__r,r*rHrHfsDr,rHc eZdZdfd ZxZS)RemoteNotValidErrorurlrcXt|||_dSN)super__init__rO)selfrO __class__s r*rSzRemoteNotValidError.__init__ks& r,)rOr)rIrJrKrS __classcell__rUs@r*rNrNjs=r,rNT)frozenceZdZUdZded<dZded<eeZded <dZ ded <dd Z e ddZ ddZ ddZddZdS) RevOptionsz Encapsulates a VCS-specific revision to install, along with any VCS install options. Args: vc_class: a VersionControl subclass. rev: the name of the revision to install. extra_args: a list of extra options. type[VersionControl]vc_classNr1r.)default_factoryr extra_args branch_namerrc2d|jjd|jdS)Nz )r\rr.rTs r*__repr__zRevOptions.__repr__s"Edm0EEEEEEr,c6|j |jjS|jSrQ)r.r\default_arg_revrbs r*arg_revzRevOptions.arg_revs 8 =0 0xr,cjg}|j}|||j|z }||jz }|S)z< Return the VCS-specific command arguments. )rfr\get_base_rev_argsr^)rTargsr.s r*to_argszRevOptions.to_argss@l ? DM33C88 8D  r,c*|jsdSd|jdS)Nz (to revision )r.rbs r* to_displayzRevOptions.to_displays$x 2+++++r,cD|j||jS)z Make a copy of the current instance, but with a new rev. Args: rev: the name of the revision for the new object. r^)r\make_rev_optionsr^)rTr.s r*make_newzRevOptions.make_news!}--cdo-NNNr,)rr)rr1)rr)r.rrrZ)rIrJrK__doc____annotations__r.rlistr^r_rcpropertyrfrjrorsrLr,r*rZrZps#"""C#eD999J9999"K""""FFFFX    ,,,, OOOOOOr,rZceZdZUiZded<gdZdfd ZddZedd Z edd Z edd Z ddZ ddZ d dZd!dZd"dZxZS)# VcsSupportzdict[str, VersionControl] _registry)sshgithgbzrsftpsvnrNonectjj|jt dSrQ)r%r& uses_netlocextendschemesrRrS)rTrUs r*rSzVcsSupport.__init__s<   '' 555 r, Iterator[str]c4|jSrQ)rz__iter__rbs r*rzVcsSupport.__iter__s~&&(((r,list[VersionControl]cNt|jSrQ)rvrzvaluesrbs r*backendszVcsSupport.backendssDN))++,,,r, list[str]c$d|jDS)Ncg|] }|j SrL)r?).0backends r* z'VcsSupport.dirnames..s===G===r,)rrbs r*dirnameszVcsSupport.dirnamess==t}====r,cRg}|jD]}||j|SrQ)rrr)rTrrs r*r)zVcsSupport.all_schemess4} , ,G NN7? + + + +r,clsr[ct|ds"td|jdS|j|jvr9||j|j<td|jdSdS)NrzCannot register VCS %szRegistered VCS backend: %s)hasattrr@rArIrrzdebug)rTrs r*registerzVcsSupport.registersxsF##  NN3S\ B B B F 84> ) )'*suuDN38 $ LL5sx @ @ @ @ @ * )r,rrc,||jvr |j|=dSdSrQ)rzrTrs r* unregisterzVcsSupport.unregisters' 4> ! !t$$$ " !r,r:VersionControl | Noneci}|jD]@}||}|std||j|||<A|sdSt |t}||S)zv Return a VersionControl object if a repository of that type is found at the given directory. zDetermine that %s uses VCS: %sN)key)rzrget_repository_rootr@rrmaxlen)rTr: vcs_backends vcs_backend repo_pathinner_most_repo_paths r*get_backend_for_dirzVcsSupport.get_backend_for_dirs  >0022 2 2K#77AAI  LL98[EU V V V&1L # # 4 #0022 # #K,,,""""-tr,c^|}|j|S)r)lowerrzgetrs r* get_backendzVcsSupport.get_backends'zz||~!!$'''r,)rr)rr)rr)rr)rr[rr)rrrr)r:rrr)r(rrr)rrrr)rIrJrKrzrurrSrrwrrr)rrrrrrVrWs@r*ryrys7+-I----888G ))))---X->>>X>X AAAA%%%%2222.((((((((r,rycNeZdZUdZdZdZdZded<dZded<dZ ded<e dVd Z e dWdZ e dXdZ e dYdZedZdZd[dZe d\d]dZe d^dZe d_d#Ze d`d%Zedad*Zdbd-Zedcd.Ze ddd1Zded6Z dfded8Z dfded9Ze dgd;Zdhd<Zdid=Ze djd>Z e djd?Z!e dkdldRZ"e dmdTZ#e dWdUZ$dS)nVersionControlrlrLztuple[str, ...]r unset_environNr1re remote_urlrrrcb||jd S)z Return whether the vcs prefix (e.g. "git+") should be added to a repository's remote url when used in a requirement. :)r startswithr)rrs r*should_add_vcs_url_prefixz(VersionControl.should_add_vcs_url_prefixs/ ##%%00CH@@@@r,r:cdS)z Return the path to Python project root, relative to the repo root. Return None if the project root is in the repo root. NrLrr:s r*get_subdirectoryzVersionControl.get_subdirectory s tr,repo_dirc,||S)zR Return the revision string that should be used in a requirement. ) get_revision)rrs r*get_requirement_revisionz'VersionControl.get_requirement_revisions )))r,r/c||}||r |jd|}||}||}t ||||}|S)aC Return the requirement string to use to redownload the files currently at the given repository directory. Args: project_name: the (unescaped) project name. The return value has a form similar to the following: {repository_url}@{revision}#egg={project_name} +)r0)get_remote_urlrrrrr9)rrr/r-revisionr0r8s r*get_src_requirementz"VersionControl.get_src_requirements%%h//  ( ( 2 2 0(//X//H//99%%h//&x splitdriversepr)rrdrivetails r*_is_local_repositoryz#VersionControl._is_local_repositoryWs> g((.. trw{++:tE{{:r,netlocr()tuple[str, tuple[str | None, str | None]]c |dfS)aZ Parse the repository URL's netloc, and return the new netloc to use along with auth information. Args: netloc: the original repository URL netloc. scheme: the repository URL's scheme without the vcs prefix. This is mainly for the Subversion class to override, so that auth information can be provided via the --username and --password options instead of through the URL. For other subclasses like Git without such an option, auth information must stay in the URL. Returns: (netloc, (username, password)). NNrL)rrr(s r*get_netloc_and_authz"VersionControl.get_netloc_and_auth`s&|##r, tuple[str, str | None, AuthInfo]ctj|\}}}}}d|vrtd|d|ddd}|||\}}d}d|vr.|dd\}}|std|dtj||||d f}|||fS) z Parse the repository URL to use, and return the URL, revision, and auth info to use. Returns: (url, rev, (username, password)). rzSorry, zk is a malformed VCS url. The format is +://, e.g. svn+http://myrepo/svn/MyApp#egg=MyAppNr5zThe URL zm has an empty revision (after @) which is not supported. Include a revision after @ or remove @ from the URL.rl) r%r&r' ValueErrorsplitrrsplitr urlunsplit) rrOr(rr>queryfrag user_passr.s r*get_url_rev_and_authz#VersionControl.get_url_rev_and_authus-3L,A,A#,F,F)eT f  =#===  c1%%a(33FFCC  $;; C++ID# '0s000 l%%vvtUB&GHHC""r,usernamepasswordHiddenText | NonercgS)zM Return the RevOptions "extra arguments" to use in obtain(). rL)rrs r* make_rev_argszVersionControl.make_rev_argss  r,rtuple[HiddenText, RevOptions]c||j\}}}|\}}d}|t|}|||}|||} t || fS)zq Return the URL and RevOptions object to use in obtain(), as a tuple (url, rev_options). Nrq)rsecretrrrrr) rTrO secret_urlr.rrsecret_passwordrr^ rev_optionss r*get_url_rev_optionsz"VersionControl.get_url_rev_optionss &*%>%>sz%J%J" C$-!/&*  &!/22H''(;; ++CJ+GG  ##[00r,cftj|dS)zi Normalize a URL for comparison by unquoting it and removing any trailing slash. /)r%r&unquoterstrip)rOs r* normalize_urlzVersionControl.normalize_urls( |##C((//444r,url1url2cZ||||kS)zV Compare two repo URLs for identity, ignoring incidental differences. )r)rrrs r* compare_urlszVersionControl.compare_urlss+   &&#*;*;D*A*AAAr,r verbosityintrct)a Fetch a revision from a repository, in the case that this is the first fetch from the repository. Args: dest: the directory to fetch the repository to. rev_options: a RevOptions object. verbosity: verbosity level. rrTrrOrrs r* fetch_newzVersionControl.fetch_news "!r,rct)z} Switch the repo at ``dest`` to point to ``URL``. Args: rev_options: a RevOptions object. rrs r*switchzVersionControl.switch "!r,ct)z Update an already-existing repo to the given ``rev_options``. Args: rev_options: a RevOptions object. rrs r*updatezVersionControl.updaterr,rct)z Return whether the id of the current commit equals the given name. Args: dest: the repository directory. name: a string name. r)rrrs r*is_commit_id_equalz!VersionControl.is_commit_id_equals "!r,c||\}}tj|s|||||dS|}||r)||}|||j rt d|j t|||||jsItdt||j ||||||ntddStd|j|j t||d}n)td||j|j d }td |j|t+d |d |d }|dkrt-jd|dkrRtdt|t1||||||dS|dkrht3|} tdt|| t5j|| |||||dS|dkrKtd|j t||||||||dSdS)a/ Install or update in editable mode the package represented by this VersionControl object. :param dest: the repository directory in which to install or update. :param url: the repository URL starting with a vcs prefix. :param verbosity: verbosity level. )rNz)%s in %s exists, and has correct URL (%s)zUpdating %s %s%sz$Skipping because already up-to-date.z%s %s in %s exists with URL %s)z%(s)witch, (i)gnore, (w)ipe, (b)ackup )siwbz0Directory %s already exists, and is not a %s %s.)z(i)gnore, (w)ipe, (b)ackup )rrrz+The plan is to install the %s repository %sz What to do? rrarz Deleting %srzBacking up %s to %srzSwitching %s %s to %s%s)rr=r>existsrrois_repository_directoryrrrr@r repo_nametitlerrr.inforrArrsysexitrrshutilmover) rTrrOrr rev_display existing_urlpromptresponsedest_dirs r*obtainzVersionControl.obtains8 33C88[w~~d##  NN4kYN G G G F!,,..  ' ' - -% F..t44L  sz::  ?N((** &&  ..t[_EE HKK*$T**#  KKc;)KLLLLKK FGGG NN0 T""    UFF NNB     FF 9 I    ##>6!9#>#>q JJ s?? HRLLL s?? NN=,t*<*< = = = 4LLL NN4kYN G G G F s??!$''H NN0,t2D2Dh O O O Kh ' ' ' NN4kYN G G G F s?? KK)T""     KKc;)K D D D D D ?r,ctj|rt|||||dS)z Clean up current location and download the url repository (and vcs infos) into location :param url: the repository URL starting with a vcs prefix. :param verbosity: verbosity level. )rOrN)r=r>r rr)rTr:rOrs r*unpackzVersionControl.unpackHsF 7>>( # #  8    H# ;;;;;r,ct)z Return the url used at location Raises RemoteNotFoundError if the repository does not have a remote url configured. rrs r*rzVersionControl.get_remote_urlTrr,ct)zR Return the current commit id of the files at the given location. rrs r*rzVersionControl.get_revision^s "!r,TraiseFcmdlist[str] | CommandArgs show_stdoutcwd on_returncode"Literal['raise', 'warn', 'ignore']extra_ok_returncodesIterable[int] | None command_desc extra_environMapping[str, Any] | NonespinnerSpinnerInterface | Nonelog_failed_cmd stdout_onlyc ht|jg|R}|t|} t||||||||j|| |  S#t $rt d|jdt$r!t d|jd|jdt$rt d|jdwxYw) z Run a VCS subcommand This is simply a wrapper around call_subprocess that adds the VCS command name, and checks that the VCS is available N)r#r%r'r(rr*r,r-zCannot find command z - invalid PATHz - do you have z installed and in your PATH?zNo permission to execute z - install it locally, globally (ask admin), or check your PATH. See possible solutions at https://pip.pypa.io/en/latest/reference/pip_freeze/#fixing-permission-denied.) rrrrrNotADirectoryErrorr FileNotFoundErrorPermissionError) rrr!r"r#r%r'r(r*r,r-s r* run_commandzVersionControl.run_commandes7&38*c***  .s33L" "+%9)+!/-'    " Q Q QOCHOOOPP P    ctd||j|jtjtj||jS)zL Return whether a directory path is a repository directory. zChecking in %s for %s (%s)...)r@rr?rr=r>r join)rr>s r*r z&VersionControl.is_repository_directorysG  4dCKRRRw~~bgll4==>>>r,c4||r|SdS)ay Return the "root" (top-level) directory controlled by the vcs, or `None` if the directory is not in any. It is meant to be overridden to implement smarter detection mechanisms for specific vcs. This can do more than is_repository_directory() alone. For example, the Git override checks that Git is actually available. N)r rs r*rz"VersionControl.get_repository_roots$  & &x 0 0 Otr,)rrrr)r:rrr1)rrrr)rrr/rrr)r.rrr)rOrrrrrr)r.r1r^rrrZ)rrrr)rrr(rrr)rOrrr)rr1rrrr)rOrrr)rOrrr)rrrrrr) rrrOrrrZrrrr)r)rrrr1rr)rrrOrrrrr)r:rrOrrrrr)r:rrr) TNrNNNNTF)rr r!rr"r1r#r$r%r&r'r1r(r)r*r+r,rr-rrr)r>rrr)%rIrJrKrr?r rrurre classmethodrrrr staticmethodrhrrrrrrrrrrrrrrrrrrr2r rrLr,r*rrsw DGI!G!!!!%'M''''"&O&&&&AAA[A[***[* [."""\"    FJ A A A A[ A;;;[;$$$[$(###[#:\ 1 1 1 1555\5BBB[B " " " "& " " " " "( " " " " """"["WEWEWEWEr < < < <"""[""""[" !rGs//"""""" 7777777777(((((((( 877777BBBBBBBB                     '  8 $ $ # - .HHHHFJ$0000:     )   )  $3O3O3O3O3O3O3O3OlM(M(M(M(M(M(M(M(`jll{{{{{{{{{{r,