ó â\e[c@@sddlmZddlZddlZddlZddlmZddl mZ ddl m Z ddl mZddlmZddlmZddlmZdd lmZmZe jZe jZejeƒZejd ƒZd „Zd efd „ƒYZ ej!e ƒdS(i(tabsolute_importN(tparse(trequest(tsamefile(t BadCommand(t display_path(t TempDirectory(tVersionControltvcss[a-fA-F0-9]{40}cC@sttj|ƒƒS(N(tboolt HASH_REGEXtmatch(tsha((s4/tmp/pip-install-0xiv62/pip/pip/_internal/vcs/git.pytlooks_like_hashstGitcB@sÎeZdZdZdZdZdZd Zdd „Z d „Z d „Z d„Z d„Z d„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zed„ƒZRS(tgits.gittclonesgit+https git+httpssgit+sshsgit+gitsgit+filetGIT_DIRt GIT_WORK_TREEtHEADc O@sí|rÍt|ƒ\}}}}}|jdƒrÍ|t|jdƒƒ } | tj|ƒjddƒjdƒ} t||| ||fƒ}|jdƒd} || t|| || ||fƒ}qÍnt t |ƒj |||ŽdS(Ntfilet/s\t+i( turlsplittendswithtlentlstripturllib_requestt url2pathnametreplacet urlunsplittfindtsuperRt__init__( tselfturltargstkwargstschemetnetloctpathtquerytfragmenttinitial_slashestnewpatht after_plus((s4/tmp/pip-install-0xiv62/pip/pip/_internal/vcs/git.pyR!+s #cC@s|gS(N((R"trev((s4/tmp/pip-install-0xiv62/pip/pip/_internal/vcs/git.pytget_base_rev_args@scC@svd}|jdgdtƒ}|j|ƒrJ|t|ƒjƒd}nd}dj|jdƒd ƒ}t|ƒS(Ns git version tversiont show_stdoutitt.i(t run_commandtFalset startswithRtsplittjoint parse_version(R"t VERSION_PFXR0((s4/tmp/pip-install-0xiv62/pip/pip/_internal/vcs/git.pytget_git_versionCsc C@ss|jdƒs|d}ntddƒB}|j|jƒ|jdddd|gdtd |jƒWd QXd S( s@Export the Git repository at the url to the destination locationRtkindtexportscheckout-indexs-as-fs--prefixR1tcwdN(RRtunpackR(R4R5(R"tlocationttemp_dir((s4/tmp/pip-install-0xiv62/pip/pip/_internal/vcs/git.pyR=Ps c C@sÍ|jd|gd|dtddƒ}i}xc|jƒjƒD]O}y|jƒ\}}Wn&tk r„tdj|ƒƒ‚nX|||R1t on_returncodetignoresunexpected show-ref line: {!r}srefs/remotes/origin/{}s refs/tags/{}(R4R5tstript splitlinesR7t ValueErrortformattget( R"tdestR.toutputtrefstlineR treft branch_refttag_ref((s4/tmp/pip-install-0xiv62/pip/pip/_internal/vcs/git.pytget_revision_sha\s  cC@sW|j}|j||ƒ}|dk r4|j|ƒSt|ƒsStjd|ƒn|S(sÌCheck the revision options before checkout. Returns a new RevOptions object for the SHA1 of the branch or tag if found. Args: rev_options: a RevOptions object. s:Did not find branch or tag '%s', assuming revision or ref.N(targ_revRPtNonetmake_newR tloggertwarning(R"RIt rev_optionsR.R ((s4/tmp/pip-install-0xiv62/pip/pip/_internal/vcs/git.pytcheck_rev_optionsxs     cC@s|s tS|j|ƒ|kS(s§ Return whether the current commit hash equals the given name. Args: dest: the repository directory. name: a string name. (R5t get_revision(R"RItname((s4/tmp/pip-install-0xiv62/pip/pip/_internal/vcs/git.pytis_commit_id_equalscC@së|jƒ}tjd||t|ƒƒ|jdd||gƒ|jrÚ|j||ƒ}|j||jƒsÚ|j}|jdƒr¸|jdd|g|j ƒd|ƒd}n|jdd|gd|ƒqÚn|j |ƒdS( NsCloning %s%s to %sRs-qsrefs/tfetchR>t FETCH_HEADtcheckout( t to_displayRTtinfoRR4R.RWRZR6tto_argstupdate_submodules(R"RIR#RVt rev_displayR.((s4/tmp/pip-install-0xiv62/pip/pip/_internal/vcs/git.pyt fetch_newžs    "cC@sV|jdd|gd|ƒddg|jƒ}|j|d|ƒ|j|ƒdS(Ntconfigsremote.origin.urlR>R]s-q(R4R`Ra(R"RIR#RVtcmd_args((s4/tmp/pip-install-0xiv62/pip/pip/_internal/vcs/git.pytswitch¹scC@sŸ|jƒtdƒkr7|jdddgd|ƒn|jddgd|ƒ|j||ƒ}dddg|jƒ}|j|d|ƒ|j|ƒdS(Ns1.9.0R[s-qs--tagsR>tresets--hard(R;R9R4RWR`Ra(R"RIRVRe((s4/tmp/pip-install-0xiv62/pip/pip/_internal/vcs/git.pytupdateÀscC@s|jdddgdtd|ƒ}|jƒ}|d}x'|D]}|jdƒrA|}PqAqAW|jdƒd }|jƒS( s+Return URL of the first remote encountered.Rds --get-regexpsremote\..*\.urlR1R>isremote.origin.url t i(R4R5RER6R7RD(R"R@tremotest found_remotetremoteR#((s4/tmp/pip-install-0xiv62/pip/pip/_internal/vcs/git.pytget_urlÎs   cC@s+|jddgdtd|ƒ}|jƒS(Ns rev-parseRR1R>(R4R5RD(R"R@t current_rev((s4/tmp/pip-install-0xiv62/pip/pip/_internal/vcs/git.pyRXÝscC@sò|jddgdtd|ƒjƒ}tjj|ƒsQtjj||ƒ}ntjj|dƒ}|}x]tjjtjj|dƒƒsË|}tjj|ƒ}||krot j d|ƒdSqoWt ||ƒrßdStjj ||ƒS( s:Return the relative path of setup.py to the git repo root.s rev-parses --git-dirR1R>s..ssetup.pysGCould not find setup.py for directory %s (tried all parent directories)N(R4R5RDtosR(tisabsR8texiststdirnameRTRURRRtrelpath(R"R@tgit_dirtroot_dirt orig_locationt last_location((s4/tmp/pip-install-0xiv62/pip/pip/_internal/vcs/git.pyt_get_subdirectoryãs"$ cC@s£|j|ƒ}|jƒjdƒs1d|}n|jƒjddƒd}|sWdS|j|ƒ}d|||f}|j|ƒ}|rŸ|d|7}n|S(Nsgit:sgit+t-iis %s@%s#egg=%ss&subdirectory=(RmtlowerR6tegg_nameR7RRRXRx(R"tdistR@trepotegg_project_nameRntreqt subdirectory((s4/tmp/pip-install-0xiv62/pip/pip/_internal/vcs/git.pytget_src_requirementþs cC@s‹d|krcd|kst‚|jddƒ}tt|ƒj|ƒ\}}|jddƒ}ntt|ƒj|ƒ\}}||fS(s9 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. s://sfile:sgit+s git+ssh://sssh://R2(tAssertionErrorRR Rt get_url_rev(R"R#R.((s4/tmp/pip-install-0xiv62/pip/pip/_internal/vcs/git.pyRƒ s cC@sKtjjtjj|dƒƒs%dS|jdddddgd|ƒdS(Ns .gitmodulest submoduleRhs--inits --recursives-qR>(RoR(RqR8R4(R"R@((s4/tmp/pip-install-0xiv62/pip/pip/_internal/vcs/git.pyRas !cC@sutt|ƒj|ƒrtSy0|ƒjdgd|dtddƒ}| SWn"tk rptjd|ƒtSXdS(Ns rev-parseR>R1RBRCsKcould not determine if %s is under git control because git is not available( R Rtcontrols_locationtTrueR4R5RRTtdebug(tclsR@tr((s4/tmp/pip-install-0xiv62/pip/pip/_internal/vcs/git.pyR…%s    (sgitsgit+https git+httpssgit+sshsgit+gitsgit+file(sGIT_DIRs GIT_WORK_TREEN(t__name__t __module__RYRrt repo_nametschemest unset_environtdefault_arg_revRRR!R/R;R=RPRWRZRcRfRhRmRXRxRRƒRat classmethodR…(((s4/tmp/pip-install-0xiv62/pip/pip/_internal/vcs/git.pyRs.              ("t __future__Rtloggingtos.pathRotretpip._vendor.packaging.versionRR9tpip._vendor.six.moves.urllibt urllib_parseRRtpip._internal.compatRtpip._internal.exceptionsRtpip._internal.utils.miscRtpip._internal.utils.temp_dirRtpip._internal.vcsRRRRt getLoggerRŠRTtcompileR R Rtregister(((s4/tmp/pip-install-0xiv62/pip/pip/_internal/vcs/git.pyts&      ÿ