U n aU7@sddlmZddlZddlZddlZddlmZddl mZ ddl m Z ddl mZmZddlmZmZddlmZddlmZdd lmZdd lmZmZmZmZerdd lmZm Z dd lm!Z!dd lm"Z"m#Z#e j$Z$e j%Z%e&e'Z(e)dZ*ddZ+GdddeZ,e-e,dS))absolute_importN)parse)request) BadCommandInstallationError) display_pathhide_url) make_command) TempDirectory)MYPY_CHECK_RUNNING)RemoteNotFoundErrorVersionControl!find_path_to_setup_from_repo_rootvcs)OptionalTuple) HiddenText)AuthInfo RevOptionsz^[a-fA-F0-9]{40}$cCstt|SN)bool HASH_REGEXmatch)sharVC:\Users\vtejo\AppData\Local\Temp\pip-unpacked-wheel-6mt8ur68\pip\_internal\vcs\git.pylooks_like_hash*srcseZdZdZdZdZdZdZdZe ddZ d d Z d d Z e d dZddZe ddZe ddZe ddZddZddZddZe ddZe d*d d!Ze d"d#Ze fd$d%Ze d&d'Ze fd(d)ZZS)+Gitgitz.gitclone)rzgit+httpz git+httpszgit+sshzgit+gitzgit+file)GIT_DIR GIT_WORK_TREEHEADcCs|gSrrrevrrrget_base_rev_args:szGit.get_base_rev_argscCsJ|t|\}}|jsdS|||js.dSt|||jd}| S)NFr)get_url_rev_optionsrr$is_commit_id_equalrget_revision_sha)selfurldest_ rev_optionsis_tag_or_branchrrris_immutable_rev_checkout>szGit.is_immutable_rev_checkoutcCs\d}|jdgdd}||r8|t|dd}nd}d|ddd}t|S) Nz git version versionF) show_stdoutr.) run_command startswithlensplitjoin parse_version)r) VERSION_PFXr0rrrget_git_versionOs zGit.get_git_versioncCsBdddg}|j|dd|d}|}|dr>|tddSdS) zl Return the current branch, or None if HEAD isn't at a branch (e.g. detached HEAD). z symbolic-ref-qr"Fextra_ok_returncodesr1cwdz refs/heads/N)r5stripr6r7)clslocationargsoutputrefrrrget_current_branch\s  zGit.get_current_branchc CsX|ds|d}tdd2}|j|j|d|jdddd|gd |jd W5QRXd S) z@Export the Git repository at the url to the destination location/export)kind)r*zcheckout-indexz-az-fz--prefixFr1rBN)endswithr unpackpathr5)r)rEr*temp_dirrrrrKqs   z Git.exportc Cs|jd|g|ddd}i}|D]@}z|\}}Wn"tk r\td|YnX|||<q&d|}d|} ||}|dk r|d fS|| }|dfS) z Return (sha_or_none, is_branch), where sha_or_none is a commit hash if the revision names a remote branch or tag, otherwise None. Args: dest: the repository directory. rev: the revision name. zshow-refFignore)rBr1 on_returncodezunexpected show-ref line: {!r}zrefs/remotes/origin/{}z refs/tags/{}NT)r5rC splitlinesr8 ValueErrorformatget) rDr+r$rGrefslinerrH branch_reftag_refrrrr(~s$      zGit.get_revision_shacCs|j}|dk st|||\}}|dk rF||}|r<|nd|_|St|sZtd||dsh|S|j t dd|| |d|j |dd}||}|S) z Resolve a revision to a new RevOptions object with the SHA1 of the branch, tag, or ref if found. Args: rev_options: a RevOptions object. Nz:Did not find branch or tag '%s', assuming revision or ref.zrefs/fetchr=rB FETCH_HEADr#) arg_revAssertionErrorr(make_new branch_namerloggerwarningr6r5r to_args get_revision)rDr+r*r-r$r is_branchrrrresolve_revisions*     zGit.resolve_revisioncCs|sdS|||kS)z Return whether the current commit hash equals the given name. Args: dest: the repository directory. name: a string name. F)rf)rDr+namerrrr's zGit.is_commit_id_equalcCs|}td||t||tdd|||jr||||}t|dd}|dkr| ||jstdd| }|j||dn4| ||krd |}dd|d |g}|j||d| |dS) NzCloning %s%s to %srr=rbcheckoutr]z origin/{}z-bz--track) to_displayrcinforr5r r$rhgetattrr'rerIrVupdate_submodules)r)r+r*r- rev_displayrbcmd_args track_branchrrr fetch_news0  z Git.fetch_newcCsB|jtdd||dtdd|}|j||d||dS)Nconfigzremote.origin.urlr]rjr=)r5r rernr)r+r*r-rprrrswitchs z Git.switchcCst|tdkr&|jdddg|dn|jddg|d||||}tddd|}|j||d||dS)Nz1.9.0r\r=z--tagsr]resetz--hard)r<r:r5rhr rernrtrrrupdatesz Git.updatecCsx|jdddgdd|d}|}z |d}Wntk rDtYnX|D]}|drJ|}qbqJ|d d }|S) z Return URL of the first remote encountered. Raises RemoteNotFoundError if the repository does not have a remote url configured. rsz --get-regexpzremote\..*\.urlr>Fr@rzremote.origin.url  r?)r5rT IndexErrorr r6r8rC)rDrEstdoutremotes found_remoteremoter*rrrget_remote_urls"    zGit.get_remote_urlNcCs(|dkr d}|jd|gd|d}|S)Nr" rev-parseFrM)r5rC)rDrEr$ current_revrrrrf0szGit.get_revisioncCsR|jddgd|d}tj|s2tj||}tjtj|d}t||S)z~ Return the path to setup.py, relative to the repo root. Return None if setup.py is in the repo root. rz --git-dirFrMz..)r5rCosrPisabsr9abspathr)rDrEgit_dir repo_rootrrrget_subdirectory9s  zGit.get_subdirectoryc st|\}}}}}|dr|dt|d }|t|ddd}t|||||f}|dd} |d| t|| d||||f}d|krd|kst |d d }t t | |\}} } |d d }nt t | |\}} } || | fS) a9 Prefixes stub URLs like 'user@hostname:user/repo.git' with 'ssh://'. That's required because although they use SSH they sometimes don't work with a ssh:// scheme (e.g. GitHub). But we need a scheme for parsing. Hence we remove it again afterwards and return it as a stub. fileNrJ\+r?z://zfile:zgit+z git+ssh://zssh://r2) urlsplitrNr7lstripurllib_request url2pathnamereplace urlunsplitfindr`superrget_url_rev_and_auth) rDr*schemenetlocrPqueryfragmentinitial_slashesnewpath after_plusr$ user_pass __class__rrrHs0      zGit.get_url_rev_and_authcCs6tjtj|dsdS|jdddddg|ddS)Nz .gitmodules submodulerwz--initz --recursiver=r])rrPexistsr9r5)rDrErrrrnks  zGit.update_submodulescs~tt||}|r|Sz|jddg|dddd}Wn6tk rVtd|YdStk rjYdSXtj | dS)Nrz--show-toplevelFraise)rBr1rSlog_failed_cmdzKcould not determine if %s is under git control because git is not availablez ) rrget_repository_rootr5rrcdebugrrrPnormpathrstrip)rDrElocrrrrrts& zGit.get_repository_root)N)__name__ __module__ __qualname__ridirname repo_nameschemes unset_environdefault_arg_rev staticmethodr%r/r< classmethodrIrKr(rhr'rrrurwr~rfrrrnr __classcell__rrrrr.sD     " ,     " r). __future__rloggingos.pathrrepip._vendor.packaging.versionrr:Zpip._vendor.six.moves.urllib urllib_parserrpip._internal.exceptionsrrpip._internal.utils.miscrrpip._internal.utils.subprocessr pip._internal.utils.temp_dirr pip._internal.utils.typingr pip._internal.vcs.versioncontrolr r rrtypingrrrrrrr getLoggerrrccompilerrrregisterrrrrs2          ^