7fW >dZddlZddlZddlZddlZddlZddlmZm Z ddl m Z m Z m Z mZmZmZmZmZmZmZmZddlmZddlmZmZddlmZmZmZmZm Z m!Z!m"Z"m#Z#ddl$m%Z%m&Z&m'Z'm(Z(d gZ)ej*e+Z,eee-ee-fZ.d e-d e/fd Z0 d!d e-de-de-dee-d e-f dZ1de-de-d ee-fdZ2Gdde3Z4Gdde3Z5edGddZ6GddZ7e7Z8Gdd Z9dS)"z)Handles all VCS (version control) supportN) dataclassfield) AnyDictIterableIteratorListLiteralMappingOptionalTupleTypeUnion)SpinnerInterface) BadCommandInstallationError) HiddenTextask_path_exists backup_dir display_pathhide_url hide_valueis_installable_dirrmtree) CommandArgscall_subprocessformat_command_args make_commandvcsnamereturncxtj|j}|sdS|gdtjzvS)z3 Return true if the name looks like a URL. F)httphttpsfileftp)urllibparseurlsplitschemer all_schemes)r r*s /builddir/build/BUILD/imunify360-venv-2.3.5/opt/imunify360/venv/lib/python3.11/site-packages/pip/_internal/vcs/versioncontrol.pyis_urlr-2sB\ " "4 ( ( /F u 555G GGrepo_urlrev project_namesubdircZ|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/r0r1r2egg_project_namereqs r,make_vcs_requirement_urlr:<sV$++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_rootrGNsM **  7??8,, } $ $ NN&    4!**  w 8,,t 7??8Y / //r.ceZdZdS)RemoteNotFoundErrorN)__name__ __module__ __qualname__r.r,rIrIksDr.rIc$eZdZdeffd ZxZS)RemoteNotValidErrorurlcXt|||_dSN)super__init__rP)selfrP __class__s r,rTzRemoteNotValidError.__init__ps& r.)rJrKrLstrrT __classcell__rVs@r,rOrOosDCr.rOT)frozenceZdZUdZeded<dZeeed<e e Z e ed<dZ eeed<d efd Zed eefd Zd e fd Zd efd Zded dfdZdS) 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. VersionControlvc_classNr0)default_factory extra_args branch_namer!c2d|jjd|jdS)Nz )r^r r0rUs r,__repr__zRevOptions.__repr__s"Edm0EEEEEEr.c6|j |jjS|jSrR)r0r^default_arg_revrds r,arg_revzRevOptions.arg_revs 8 =0 0xr.cjg}|j}|||j|z }||jz }|S)z< Return the VCS-specific command arguments. )rhr^get_base_rev_argsr`)rUargsr0s r,to_argszRevOptions.to_argss@l ? DM33C88 8D  r.c*|jsdSd|jdS)Nz (to revision )r0rds 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`)rUr0s r,make_newzRevOptions.make_news!}--cdo-NNNr.)rJrKrL__doc__r__annotations__r0r rWrlistr`rrarepropertyrhrlrqrurMr.r,r\r\us$#$$$$C##eD999J 999!%K#%%%F#FFFF#X     ,C,,,, OCOLOOOOOOr.r\cXeZdZUiZeedfed<gdZdfd Zde efdZ e de dfdZ e de efd Ze de efd Zd edddfd Zd eddfdZdededfdZdededfdZd ededfdZxZS) VcsSupportr] _registry)sshgithgbzrsftpsvnr!Nctjj|jt dSrR)r'r( uses_netlocextendschemesrSrT)rUrVs r,rTzVcsSupport.__init__s<   '' 555 r.c4|jSrR)r|__iter__rds r,rzVcsSupport.__iter__s~&&(((r.cNt|jSrR)rxr|valuesrds r,backendszVcsSupport.backendssDN))++,,,r.c$d|jDS)Ncg|] }|j SrM)r@).0backends r, z'VcsSupport.dirnames..s===G===r.)rrds r,dirnameszVcsSupport.dirnamess==t}====r.cRg}|jD]}||j|SrR)rrr)rUrrs r,r+zVcsSupport.all_schemess4} , ,G NN7? + + + +r.clsct|ds"td|jdS|j|jvr9||j|j<td|jdSdS)Nr zCannot register VCS %szRegistered VCS backend: %s)hasattrrArBrJr r|debug)rUrs r,registerzVcsSupport.registersxsF##  NN3S\ B B B F 84> ) )'*suuDN38 $ LL5sx @ @ @ @ @ * )r.r c,||jvr |j|=dSdSrR)r|rUr s r, unregisterzVcsSupport.unregisters' 4> ! !t$$$ " !r.r;ci}|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)r|rget_repository_rootrArr maxlen)rUr; 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)lowerr|getrs r, get_backendzVcsSupport.get_backends'zz||~!!$'''r.)r!N)rJrKrLr|rrWrwrrTrrryr rrr+rrrr rrrrXrYs@r,r{r{s-/ItC))*///888G )(3-))))-$/0---X->$s)>>>X>T#YX AD!12AtAAAA%s%t%%%%2C2H=M4N2222.SX>N5O((1A(B((((((((r.r{ceZdZUdZdZdZdZeedfe d<dZ eedfe d<dZ e ee d<e ded efd Ze d ed e efd Ze d ed efdZe d eded efdZeded eefdZdeded efdZe dCde ede ed efdZe ded efdZe deded eeee ee efffdZe ded eee eeffdZede ede ed efd Zded eeeffd!Z eded efd"Z!e d#ed$ed efd%Z"deded&ed'e#d df d(Z$deded&ed dfd)Z%deded&ed dfd*Z&e ded+e ed efd,Z'deded'e#d dfd-Z(d eded'e#d dfd.Z)e d ed efd/Z*e d ed efd0Z+e dDd4e,eeefd5ed6e ed7d8d9e e-e#d:e ed;e e.ee/fded efd?Z1e d@ed efdAZ2e d ed e efdBZ3dS)Er]rnrM.r unset_environNrg remote_urlr!cb||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_prefix s/ ##%%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. NrMrr;s r,get_subdirectoryzVersionControl.get_subdirectorys 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.r1c||}||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} +)r2)get_remote_urlrr rrr:)rrr1r/revisionr2r9s r,get_src_requirementz"VersionControl.get_src_requirement s%%h//  ( ( 2 2 0(//X//H//99%%h//&xr? splitdriversepbool)rrdrivetails r,_is_local_repositoryz#VersionControl._is_local_repository\s> g((.. trw{++:tE{{:r.netlocr*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)). NNrM)rrr*s r,get_netloc_and_authz"VersionControl.get_netloc_and_authes&|##r.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=MyAppNr6zThe URL zm has an empty revision (after @) which is not supported. Include a revision after @ or remove @ from the URL.rn) r'r(r) ValueErrorsplitrrsplitr urlunsplit) rrPr*rr?queryfrag user_passr0s r,get_url_rev_and_authz#VersionControl.get_url_rev_and_authzs-3L,A,A#,F,F)eT f  =#===  c1%%a(33FFCC  $;; C++ID# '0s000 l%%vvtUB&GHHC""r.usernamepasswordcgS)zM Return the RevOptions "extra arguments" to use in obtain(). rM)rrs r, make_rev_argszVersionControl.make_rev_argss  r.c||j\}}}|\}}d}|t|}|||}|||} t || fS)zq Return the URL and RevOptions object to use in obtain(), as a tuple (url, rev_options). Nrs)rsecretrrrtr) rUrP secret_urlr0rrsecret_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)rPs 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 verbosityct)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. r)rUrrPrrs r, fetch_newzVersionControl.fetch_news "!r.ct)z} Switch the repo at ``dest`` to point to ``URL``. Args: rev_options: a RevOptions object. rrUrrPrs 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.r ct)z Return whether the id of the current commit equals the given name. Args: dest: the repository directory. name: a string name. r)rrr s r,is_commit_id_equalz!VersionControl.is_commit_id_equals "!r.c|||\}}tj|s|||||dS|}||r'||}|||j rt d|j t|||||jsGtdt||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|dkrItd|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?existsrrqis_repository_directoryrrrrAr repo_nametitlerrr0inforrBr rsysexitrrshutilmover) rUrrPrr rev_display existing_urlpromptresponsedest_dirs r,obtainzVersionControl.obtains0 33C88[w~~d##  NN4kYN G G G F!,,..  ' ' - -% F..t44L  sz::  ?N((** &&  ..t[_EE HKK*$T**#  KKc;7777KK 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; / / / / / ?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. )rPrN)r>r?rrr)rUr;rPrs r,unpackzVersionControl.unpackCsF 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_urlOrr.ct)zR Return the current commit id of the files at the given location. rrs r,rzVersionControl.get_revisionYs "!r.TraiseFcmd show_stdoutcwd on_returncodez"Literal["raise", "warn", "ignore"]extra_ok_returncodes command_desc extra_environspinnerlog_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)rrrrrrrrzCannot 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.) rr rrrNotADirectoryErrorrFileNotFoundErrorPermissionError) rrrrrrrrrrrs r, run_commandzVersionControl.run_command`s7&38*c***  .s33L" "+%9)+!/-'    " Q Q QOCHOOOPP P    r?rjoin)rr?s r,rz&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)rrs r,rz"VersionControl.get_repository_roots$  & &x 0 0 Otr.r) TNrNNNNTF)4rJrKrLr r@rrr rWrwrrgr classmethodrrrrr staticmethodr rjrrr\rtrrAuthInforrrrrrintrrrrrrrrrrr rrr$rrrMr.r,r]r]sO DGI!GU38_!!!%'M5c?'''%)OXc])))A3A4AAA[A [*****[* 3cc[."s"tCy"""\" S      LP A A3- A4<[4I A  A A A[ A;;;;;[;$$"%$ sE(3-#677 8$$$[$(#s#uS(3-5Q/R###[#:3-+3J+? \ 1z 1eJ E8<&*59.2#!77 49k) *77c] 7 < 7 'x}5 7sm7 S 127*+777 777[7r?3?4???[? 3 8C=   [   r.r]rR):rvloggingr>r r urllib.parser' dataclassesrrtypingrrrrr r r r r rrpip._internal.cli.spinnersrpip._internal.exceptionsrrpip._internal.utils.miscrrrrrrrrpip._internal.utils.subprocessrrrr__all__ getLoggerrJrArWr*rr-r:rG ExceptionrIrOr\r{rr]rMr.r,r7s// ((((((((                          877777BBBBBBBB                     '  8 $ $ # - .HHHHHHIM+.8@ $00!0 c]0000:     )   )  $3O3O3O3O3O3O3O3OlM(M(M(M(M(M(M(M(`jllqqqqqqqqqqr.