HEX
Server: nginx/1.24.0
System: Linux webserver 6.8.0-85-generic #85-Ubuntu SMP PREEMPT_DYNAMIC Thu Sep 18 15:26:59 UTC 2025 x86_64
User: wpuser (1002)
PHP: 8.3.6
Disabled: NONE
Upload Files
File: //lib/python3/dist-packages/pip/_internal/vcs/__pycache__/versioncontrol.cpython-312.pyc
�

��hY����dZddlZddlZddlZddlZddlZddlmZm	Z	m
Z
mZmZm
Z
mZmZmZmZmZddlmZddlmZmZddlmZmZmZmZmZmZmZm Z ddl!m"Z"m#Z#m$Z$m%Z%ddl&m'Z'erdd	lm(Z(d
gZ)ejTe+�Z,eee-ee-fZ.de-de/fd
�Z0	d de-de-de-dee-de-f
d�Z1de-de-dee-fd�Z2Gd�de3�Z4Gd�de3�Z5Gd�d�Z6Gd�d�Z7e7�Z8Gd�d�Z9y)!z)Handles all VCS (version control) support�N)�
TYPE_CHECKING�Any�Dict�Iterable�Iterator�List�Mapping�Optional�Tuple�Type�Union)�SpinnerInterface)�
BadCommand�InstallationError)�
HiddenText�ask_path_exists�
backup_dir�display_path�hide_url�
hide_value�is_installable_dir�rmtree)�CommandArgs�call_subprocess�format_command_args�make_command)�get_url_scheme)�Literal�vcs�name�returnc�L�t|�}|�y|gd�tjzvS)z3
    Return true if the name looks like a URL.
    F)�http�https�file�ftp)rr�all_schemes)r �schemes  �B/usr/lib/python3/dist-packages/pip/_internal/vcs/versioncontrol.py�is_urlr*9s+���D�
!�F�
�~���5����G�G�G��repo_url�rev�project_name�subdirc�R�|jdd�}|�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.r/�egg_project_name�reqs      r)�make_vcs_requirement_urlr7CsH��$�+�+�C��5��
�J�a��u�E�"2�!3�
4�C�
����x�(�(���Jr+�location�	repo_rootc�0�|}t|�sI|}tjj|�}||k(rtjd|�yt|�s�Itjj
||�rytjj||�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)r�os�path�dirname�logger�warning�samefile�relpath)r8r9�
orig_location�
last_locations    r)�(find_path_to_project_root_from_repo_rootrDUs����M� ��*� �
��7�7�?�?�8�,���}�$�
�N�N�&��
�
�!��*�
�w�w���	�8�,��
�7�7�?�?�8�Y�/�/r+c��eZdZy)�RemoteNotFoundErrorN)�__name__�
__module__�__qualname__�r+r)rFrFrs��r+rFc�$��eZdZdef�fd�Z�xZS)�RemoteNotValidError�urlc�2��t�|�|�||_y�N)�super�__init__rM)�selfrM�	__class__s  �r)rQzRemoteNotValidError.__init__ws���
�������r+)rGrHrI�strrQ�
__classcell__�rSs@r)rLrLvs����C��r+rLc	��eZdZdZ		ddeddeedeeddfd�Zdefd	�Z	e
deefd
��Zdefd�Zdefd�Z
deddfd
�Zy)�
RevOptionsz�
    Encapsulates a VCS-specific revision to install, along with any VCS
    install options.

    Instances of this class should be treated as if immutable.
    N�vc_class�VersionControlr-�
extra_argsr!c�D�|�g}||_||_||_d|_y)z�
        Args:
          vc_class: a VersionControl subclass.
          rev: the name of the revision to install.
          extra_args: a list of extra options.
        N)r[r-rY�branch_name)rRrYr-r[s    r)rQzRevOptions.__init__�s,�����J�$������ ��
�*.��r+c�P�d|jj�d|j�d�S)Nz<RevOptions z: rev=�>)rYr r-�rRs r)�__repr__zRevOptions.__repr__�s&���d�m�m�0�0�1�����|�1�E�Er+c�^�|j�|jjS|jSrO)r-rY�default_arg_revr`s r)�arg_revzRevOptions.arg_rev�s%���8�8���=�=�0�0�0��x�x�r+c��g}|j}|�||jj|�z
}||jz
}|S)z<
        Return the VCS-specific command arguments.
        )rdrY�get_base_rev_argsr[)rR�argsr-s   r)�to_argszRevOptions.to_args�sC�����l�l���?��D�M�M�3�3�C�8�8�D��������r+c�<�|jsyd|j�d�S)N�z (to revision �)�r-r`s r)�
to_displayzRevOptions.to_display�s���x�x������z��+�+r+c�P�|jj||j��S)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[)rY�make_rev_optionsr[)rRr-s  r)�make_newzRevOptions.make_new�s"���}�}�-�-�c�d�o�o�-�N�Nr+�NN)rGrHrI�__doc__rr
rTrrQra�propertyrdrhrmrqrJr+r)rXrX|s����"�,0�	/��'�(�/��c�]�/��[�)�	/�

�/�(F�#�F����#�����
��
�,�C�,�O�C�O�L�Or+rXc���eZdZUiZeedfed<gd�Zd�fd�Zde	efd�Z
ededfd��Z
edeefd	��Zedeefd
��Zdedddfd�Zd
eddfd�Zdededfd�Zdededfd�Zd
ededfd�Z�xZS)�
VcsSupportrZ�	_registry)�ssh�git�hg�bzr�sftp�svnr!Nc���tjjj|j�t
�|��yrO)�urllib�parse�uses_netloc�extend�schemesrPrQ)rRrSs �r)rQzVcsSupport.__init__�s,���	��� � �'�'����5�
���r+c�6�|jj�SrO)rw�__iter__r`s r)r�zVcsSupport.__iter__�s���~�~�&�&�(�(r+c�H�t|jj��SrO)�listrw�valuesr`s r)�backendszVcsSupport.backends�s���D�N�N�)�)�+�,�,r+c�T�|jD�cgc]}|j��c}Scc}wrO)r�r=)rR�backends  r)�dirnameszVcsSupport.dirnames�s��/3�}�}�=�G����=�=��=s�%c�b�g}|jD]}|j|j��|SrO)r�r�r�)rRr�r�s   r)r'zVcsSupport.all_schemes�s/�����}�}�	,�G��N�N�7�?�?�+�	,��r+�clsc��t|d�s!tjd|j�y|j|j
vr?|�|j
|j<tj
d|j�yy)Nr zCannot register VCS %szRegistered VCS backend: %s)�hasattrr>r?rGr rw�debug)rRr�s  r)�registerzVcsSupport.register�s^���s�F�#��N�N�3�S�\�\�B���8�8�4�>�>�)�'*�u�D�N�N�3�8�8�$��L�L�5�s�x�x�@�*r+r c�<�||jvr|j|=yyrO)rw�rRr s  r)�
unregisterzVcsSupport.unregister�s���4�>�>�!����t�$�"r+r8c���i}|jj�D]<}|j|�}|s�tj	d||j
�|||<�>|syt
|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)rwr��get_repository_rootr>r�r �max�len)rRr8�vcs_backends�vcs_backend�	repo_path�inner_most_repo_paths      r)�get_backend_for_dirzVcsSupport.get_backend_for_dir�s��
���>�>�0�0�2�	2�K�#�7�7��A�I����L�L�9�8�[�EU�EU�V�&1�L��#�	2��� #�<�S�9���0�1�1r+r(c�f�|jj�D]}||jvs�|cSy)�9
        Return a VersionControl object or None.
        N)rwr�r�)rRr(r�s   r)�get_backend_for_schemez!VcsSupport.get_backend_for_scheme�s9�� �>�>�0�0�2�	#�K���,�,�,�"�"�	#�r+c�X�|j�}|jj|�S)r�)�lowerrw�getr�s  r)�get_backendzVcsSupport.get_backends$���z�z�|���~�~�!�!�$�'�'r+)r!N)rGrHrIrwrrT�__annotations__r�rQrr�rtrr�r�r'rr�r�r
r�r�r�rUrVs@r)rvrv�s���-/�I�t�C�)�)�*�/�8�G��)�(�3�-�)��-�$�/�0�-��-��>�$�s�)�>��>���T�#�Y����A�D�!1�2�A�t�A�%�s�%�t�%�2�C�2�H�=M�4N�2�.�S��X�>N�5O��(��(��1A�(B�(r+rvc���eZdZUdZdZdZdZeedfe	d<dZ
eedfe	d<dZeee	d<e
ded	efd
��Ze
ded	eefd��Ze
d
ed	efd��Ze
d
eded	efd��Zeded	eefd��Zdeded	efd�Ze
	d@deedeed	efd��Ze
ded	efd��Ze
deded	eeeeeeefffd��Ze
ded	eeeeeffd��Zede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(deded'e#d	dfd.�Z)e
ded	efd/��Z*e
ded	efd0��Z+e
									dAd1e,eeefd2ed3eed4d5d6ee-e#d7eed8ee.ee/fd9ee0d:ed;ed	efd<��Z1e
d=ed	efd>��Z2e
ded	eefd?��Z3y)BrZrjrJ.r��
unset_environNrc�
remote_urlr!c�\�|j�j|j�d��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 )r�r�s  r)�should_add_vcs_url_prefixz(VersionControl.should_add_vcs_url_prefixs+���#�#�%�0�0�C�H�H�:�Q��@�@�@r+r8c��y)z�
        Return the path to Python project root, relative to the repo root.
        Return None if the project root is in the repo root.
        NrJ�r�r8s  r)�get_subdirectoryzVersionControl.get_subdirectory$s��r+�repo_dirc�$�|j|�S)zR
        Return the revision string that should be used in a requirement.
        )�get_revision)r�r�s  r)�get_requirement_revisionz'VersionControl.get_requirement_revision,s��
����)�)r+r.c���|j|�}|j|�r|j�d|��}|j|�}|j	|�}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}
        �+)r/)�get_remote_urlr�r r�r�r7)r�r�r.r,�revisionr/r6s       r)�get_src_requirementz"VersionControl.get_src_requirement3sl���%�%�h�/���(�(��2��(�(��1�X�J�/�H��/�/��9���%�%�h�/��&�x��<�PV�W���
r+r-c��t�)z�
        Return the base revision arguments for a vcs command.

        Args:
          rev: the name of a revision to install.  Cannot be None.
        ��NotImplementedErrorrls r)rfz VersionControl.get_base_rev_argsK�
��"�!r+rM�destc��y)aZ
        Return true if the commit hash checked out at dest matches
        the revision in url.

        Always return False, if the VCS does not support immutable commit
        hashes.

        This method does not check if there are local uncommitted changes
        in dest after checkout, as pip currently has no use case for that.
        FrJ)rRrMr�s   r)�is_immutable_rev_checkoutz(VersionControl.is_immutable_rev_checkoutUs��r+r[c��t|||��S)z�
        Return a RevOptions object.

        Args:
          rev: the name of a revision to install.
          extra_args: a list of extra options.
        ro)rX)r�r-r[s   r)rpzVersionControl.make_rev_optionsbs���#�s�z�:�:r+�repoc��tjj|�\}}|jtjj�xst|�S)zs
        posix absolute paths start with os.path.sep,
        win32 ones start with drive (like c:\folder)
        )r;r<�
splitdriver��sep�bool)r�r��drive�tails    r)�_is_local_repositoryz#VersionControl._is_local_repositoryos<���g�g�(�(��.���t����r�w�w�{�{�+�:�t�E�{�: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)).
        rrrJ)r�r�r(s   r)�get_netloc_and_authz"VersionControl.get_netloc_and_authxs��&�|�#�#r+c�p�tjj|�\}}}}}d|vrtd|�d���|j	dd�d}|j||�\}}d}d|vr&|j
dd�\}}|std|�d���tjj||||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)).
        r�zSorry, zk is a malformed VCS url. The format is <vcs>+<protocol>://<url>, e.g. svn+http://myrepo/svn/MyApp#egg=MyApp�Nr3zThe URL zm has an empty revision (after @) which is not supported. Include a revision after @ or remove @ from the URL.rj)	rr��urlsplit�
ValueError�splitr��rsplitr�
urlunsplit)	r�rMr(r�r<�query�frag�	user_passr-s	         r)�get_url_rev_and_authz#VersionControl.get_url_rev_and_auth�s���-3�L�L�,A�,A�#�,F�)����e�T��f����#��!=�=��
����c�1�%�a�(���3�3�F�F�C���	����$�;����C��+�I�D�#��'��s�g�&0�0���
�l�l�%�%�v�v�t�U�B�&G�H���C��"�"r+�username�passwordc��gS)zM
        Return the RevOptions "extra arguments" to use in obtain().
        rJ)r�r�s  r)�
make_rev_argszVersionControl.make_rev_args�s	���	r+c���|j|j�\}}}|\}}d}|�t|�}|j||�}|j	||��}	t|�|	fS)zq
        Return the URL and RevOptions object to use in obtain(),
        as a tuple (url, rev_options).
        Nro)r��secretrr�rpr)
rRrM�
secret_urlr-r�r��secret_passwordr�r[�rev_optionss
          r)�get_url_rev_optionsz"VersionControl.get_url_rev_options�su��
&*�%>�%>�s�z�z�%J�"�
�C��$-�!��/�)-���&�!�/�2�H��'�'��(�;�
��+�+�C�J�+�G���
�#�[�0�0r+c�^�tjj|�jd�S)zi
        Normalize a URL for comparison by unquoting it and removing any
        trailing slash.
        �/)rr��unquote�rstrip)rMs r)�
normalize_urlzVersionControl.normalize_url�s$���|�|�#�#�C�(�/�/��4�4r+�url1�url2c�H�|j|�|j|�k(S)zV
        Compare two repo URLs for identity, ignoring incidental differences.
        )r�)r�r�r�s   r)�compare_urlszVersionControl.compare_urls�s%��
� � ��&�#�*;�*;�D�*A�A�Ar+r��	verbosityc��t�)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�)rRr�rMr�r�s     r)�	fetch_newzVersionControl.fetch_new�s
��"�!r+c��t�)z}
        Switch the repo at ``dest`` to point to ``URL``.

        Args:
          rev_options: a RevOptions object.
        r��rRr�rMr�s    r)�switchzVersionControl.switch��
��"�!r+c��t�)z�
        Update an already-existing repo to the given ``rev_options``.

        Args:
          rev_options: a RevOptions object.
        r�r�s    r)�updatezVersionControl.update�r�r+r c��t�)z�
        Return whether the id of the current commit equals the given name.

        Args:
          dest: the repository directory.
          name: a string name.
        r�)r�r�r s   r)�is_commit_id_equalz!VersionControl.is_commit_id_equal�s
��"�!r+c���|j|�\}}tjj|�s|j	||||��y|j�}|j
|��r|j|�}|j||j�r�tjd|jj�t|�|�|j||j �s?tj#dt|�|j|�|j%|||�ytj#d�ytj'd|j(|jt|�|�d}n.tj'd||j(|j�d	}tj'd
|j(|�t+d|d��|d
�}|dk(rt-j.d�|dk(r@tj'dt|��t1|�|j	||||��y|dk(rWt3|�}	tj'dt|�|	�t5j6||	�|j	||||��y|dk(r@tj#d|jt|�||�|j9|||�yy)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.
        )r�Nz)%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 )�s�i�w�bz0Directory %s already exists, and is not a %s %s.)z(i)gnore, (w)ipe, (b)ackup )r�r�r�z+The plan is to install the %s repository %sz
What to do?  rr��a���r�zDeleting %sr�zBacking up %s to %sr�zSwitching %s %s to %s%s)r�r;r<�existsr�rm�is_repository_directoryr�r�r�r>r��	repo_name�titlerr�r-�infor�r?r r�sys�exitrr�shutil�mover�)
rRr�rMr�r��rev_display�existing_url�prompt�response�dest_dirs
          r)�obtainzVersionControl.obtain�sr�� �3�3�C�8���[��w�w�~�~�d�#��N�N�4��k�Y�N�G��!�,�,�.���'�'��-��.�.�t�4�L�� � ��s�z�z�:����?��N�N�(�(�*� ��&��	��.�.�t�[�_�_�E��K�K�*�$�T�*����#�	��K�K��c�;�7���K�K� F�G���N�N�0��	�	�����T�"��
�U�F��N�N�B���	�	����	
�F�F����9��I�I��	
�
#�]�6�!�9�+�#>��q�	�J���s�?��H�H�R�L��s�?��N�N�=�,�t�*<�=��4�L��N�N�4��k�Y�N�G���s�?�!�$�'�H��N�N�0�,�t�2D�h�O��K�K��h�'��N�N�4��k�Y�N�G���s�?��K�K�)�����T�"���
�
�K�K��c�;�/�r+c��tjj|�rt|�|j	|||��y)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.
        )rMr�N)r;r<r�rr)rRr8rMr�s    r)�unpackzVersionControl.unpackVs.���7�7�>�>�(�#��8�����H�#���;r+c��t�)z�
        Return the url used at location

        Raises RemoteNotFoundError if the repository does not have a remote
        url configured.
        r�r�s  r)r�zVersionControl.get_remote_urlbr�r+c��t�)zR
        Return the current commit id of the files at the given location.
        r�r�s  r)r�zVersionControl.get_revisionls
��
"�!r+�cmd�show_stdout�cwd�
on_returncodez"Literal["raise", "warn", "ignore"]�extra_ok_returncodes�command_desc�
extra_environ�spinner�log_failed_cmd�stdout_onlyc
�2�t|jg|���}|�t|�}	t||||||||j||	|
��S#t
$r't
d|j�d|j�d���t$rt
d|j�d���wxYw)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
        )rrrrr�rrrzCannot find command z - 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 rrr��FileNotFoundErrorr�PermissionError)r�rrrrrrrrrrs           r)�run_commandzVersionControl.run_commandss���&�3�8�8�*�c�*����.�s�3�L� 	�"����+�%9�)�+�!�/�/��-�'��
��!�	��&�s�x�x�l�/��8�8�,�:�<��
��	�
�+�C�H�H�<�8-�.��
�	�s�A�ABr<c���tjd||j|j�tj
j
tj
j||j��S)zL
        Return whether a directory path is a repository directory.
        zChecking in %s for %s (%s)...)r>r�r=r r;r<r��join)r�r<s  r)r�z&VersionControl.is_repository_directory�sE��
	���4�d�C�K�K����R��w�w�~�~�b�g�g�l�l�4����=�>�>r+c�*�|j|�r|Sy)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�r�s  r)r�z"VersionControl.get_repository_root�s���&�&�x�0��O�r+rr)	TN�raiseNNNNTF)4rGrHrIr r=rr�rrTr�r�rcr
�classmethodr�r�r�r�r��staticmethodrrfr�rrXrpr�r��AuthInfor�rr�r�r�r��intr�r�r�r�rrr�r�r
rr	rrrr�r�rJr+r)rZrZs���
�D��G��I�!�G�U�3��8�_�!�%'�M�5��c��?�'�%)�O�X�c�]�)��A�3�A�4�A��A�������
�����*��*��*��*���3��c��c����.�"�s�"�t�C�y�"��"��S�������LP�
;��3�-�
;�4<�[�4I�
;�	�
;��
;��;��;��;��;��$��$�"%�$�	�s�E�(�3�-��#��6�7�7�	8�$��$�(�#�s�#�u�S�(�3�-��5Q�/R�#��#�:���3�-��+3�J�+?��	����
1�z�
1�e�J�
�<R�6S�
1��5�3�5�3�5��5��B��B�3�B�4�B��B�"��"�(�"�7A�"�NQ�"�	
�"�"�3�"�Z�"�j�"�T�"�"�3�"�Z�"�j�"�T�"��"�c�"��#��"�4�"��"�W0�3�W0�Z�W0�C�W0�D�W0�r
<�s�
<��
<��
<��
<��"�c�"�c�"��"��"�C�"�C�"��"��!�!�>E�8<�&*�59�.2�#�!�5�
�4��9�k�)�
*�5��5��c�]�	5�
<�5�'�x��}�5�
5��s�m�5� ���S�� 1�2�5��*�+�5��5��5�

�5��5�n�?�3�?�4�?��?��
�3�
�8�C�=�
��
r+rZrO):rs�loggingr;rr�urllib.parser�typingrrrrrrr	r
rrr
�pip._internal.cli.spinnersr�pip._internal.exceptionsrr�pip._internal.utils.miscrrrrrrrr�pip._internal.utils.subprocessrrrr�pip._internal.utils.urlsrr�__all__�	getLoggerrGr>rTr%r�r*r7rD�	ExceptionrFrLrXrvrrZrJr+r)�<module>r2sE��/��	�
�
������8�B�	�	�	���4����'��
��	�	�8�	$����#����
�-�.��H��H��H�IM������+.��8@��
����$0��0�!�0�
�c�]�0�:	�)�	��)��@O�@O�FM(�M(�`�l��o�or+