ó •abc@@søddlmZddlZddlZddlZddlmZddlm Z ddl m Z ddl m Zddlm ZddlmZmZddlmZmZe jZe jZejeƒZd efd „ƒYZejeƒdS( i(tabsolute_importN(tsamefile(t BadCommand(tparse(trequest(t display_pathtrmtree(tvcstVersionControltGitcB@sïeZdZdZdZdZdd„Zd „Zd „Z d „Z d „Z d „Z d„Z d„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zed„ƒZRS( tgits.gittclonesgit+https git+httpssgit+sshsgit+gitsgit+filec 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 urlunsplittfindtsuperR t__init__( tselfturltargstkwargstschemetnetloctpathtquerytfragmenttinitial_slashestnewpatht after_plus((s//usr/lib/python2.7/site-packages/pip/vcs/git.pyR s #cC@sld}|jdgdtƒ}|j|ƒr@|t|ƒ}nd}dj|jdƒd ƒ}t|ƒS(Ns git version tversiont show_stdouttt.i(t run_commandtFalset startswithRtjointsplitt parse_version(Rt VERSION_PFXR&((s//usr/lib/python2.7/site-packages/pip/vcs/git.pytget_git_version5scC@sytjddƒ}|j|ƒzH|jdƒs>|d}n|jdddd|gdtd |ƒWd t|ƒXd S( s@Export the Git repository at the url to the destination locations-exportspip-R scheckout-indexs-as-fs--prefixR'tcwdN(ttempfiletmkdtemptunpackRR*R+R(Rtlocationttemp_dir((s//usr/lib/python2.7/site-packages/pip/vcs/git.pytexportBs  cC@s_|j|ƒ}d|}||kr0||gS||krG||gStjd|ƒ|SdS(s¶Check the revision options before checkout to compensate that tags and branches may need origin/ as a prefix. Returns the SHA1 of the branch or tag if found. s origin/%ss5Could not find a tag or branch '%s', assuming commit.N(tget_short_refstloggertwarning(Rtrevtdestt rev_optionst revisionst origin_rev((s//usr/lib/python2.7/site-packages/pip/vcs/git.pytcheck_rev_optionsOs      cC@s|j|ƒj|dƒS(s  Compare the current sha to the ref. ref may be a branch or tag name, but current rev will always point to a sha. This means that a branch or tag will never compare as True. So this ultimately only matches against exact shas. i(t get_revisionR,(RR=R>((s//usr/lib/python2.7/site-packages/pip/vcs/git.pyt check_versioncscC@sJ|jdd|gd|ƒ|jddg|d|ƒ|j|ƒdS(Ntconfigsremote.origin.urlR2tcheckouts-q(R*tupdate_submodules(RR=RR>((s//usr/lib/python2.7/site-packages/pip/vcs/git.pytswitchlscC@s£|jƒtdƒkr7|jdddgd|ƒn|jddgd|ƒ|rr|j|d||ƒ}n|jdddg|d|ƒ|j|ƒdS( Ns1.9.0tfetchs-qs--tagsR2itresets--hard(R1R/R*RARF(RR=R>((s//usr/lib/python2.7/site-packages/pip/vcs/git.pytupdaters cC@sî|jƒ\}}|r.|g}d|}ndg}d}|j||||ƒrêtjd||t|ƒƒ|jdd||gƒ|rÚ|j|||ƒ}|j||ƒsÚ|jddg|d|ƒqÚn|j|ƒndS( Ns (to %s)s origin/masterR(sCloning %s%s to %sR s-qRER2( t get_url_revtcheck_destinationR:tinfoRR*RARCRF(RR=RR<R>t rev_display((s//usr/lib/python2.7/site-packages/pip/vcs/git.pytobtain‚s"    cC@s|jdddgdtd|ƒ}|jƒ}|d}x'|D]}|jdƒrA|}PqAqAW|jdƒd }|jƒS( s+Return URL of the first remote encountered.RDs --get-regexpsremote\..*\.urlR'R2isremote.origin.url t i(R*R+t splitlinesR,R.tstrip(RR6tremotest found_remotetremoteR((s//usr/lib/python2.7/site-packages/pip/vcs/git.pytget_url›s   cC@s+|jddgdtd|ƒ}|jƒS(Ns rev-parsetHEADR'R2(R*R+RR(RR6t current_rev((s//usr/lib/python2.7/site-packages/pip/vcs/git.pyRB©scc@sn|jdgdtd|ƒ}xI|jƒjƒD]5}|jddƒ\}}|jƒ|jƒfVq1WdS(s4Yields tuples of (commit, ref) for branches and tagssshow-refR'R2RPiN(R*R+RRRQR.(RR6toutputtlinetcommittref((s//usr/lib/python2.7/site-packages/pip/vcs/git.pyt get_full_refs®s cC@s |jdƒS(Ns refs/remotes/(R,(RR\((s//usr/lib/python2.7/site-packages/pip/vcs/git.pyt is_ref_remote¶scC@s |jdƒS(Ns refs/heads/(R,(RR\((s//usr/lib/python2.7/site-packages/pip/vcs/git.pyt is_ref_branch¹scC@s |jdƒS(Ns refs/tags/(R,(RR\((s//usr/lib/python2.7/site-packages/pip/vcs/git.pyt is_ref_tag¼scC@s/t|j|ƒ|j|ƒ|j|ƒfƒ S(s0A ref is a commit sha if it is not anything else(tanyR^R_R`(RR\((s//usr/lib/python2.7/site-packages/pip/vcs/git.pyt is_ref_commit¿s  cC@s |j|ƒS(N(R9(RR6((s//usr/lib/python2.7/site-packages/pip/vcs/git.pytget_refsÈscC@s¯i}x¢|j|ƒD]‘\}}d}|j|ƒrJ|tdƒ}nD|j|ƒrl|tdƒ}n"|j|ƒrŽ|tdƒ}n|dk r|||s      ÿ