Viewing File: /opt/alt/python35/lib/python3.5/site-packages/pip/_internal/vcs/__pycache__/git.cpython-35.pyc



t_6@sddlmZddlZddlZddlZddlmZddl	mZ
ddl	mZddl
mZmZddlmZmZddlmZddlmZdd	lmZdd
lmZmZmZmZer$ddlmZm Z ddlm!Z!dd
lm"Z"m#Z#e
j$Z$e
j%Z%ej&e'Z(ej)dZ*ddZ+GdddeZ,ej-e,dS))absolute_importN)parse)request)
BadCommandSubProcessError)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}$cCsttj|S)N)bool
HASH_REGEXmatch)shar/builddir/build/BUILDROOT/alt-python35-pip-20.2.4-1.el7.x86_64/opt/alt/python35/lib/python3.5/site-packages/pip/_internal/vcs/git.pylooks_like_hash*srcsQeZdZdZdZdZd/Zd0ZdZe	dd
Z
ddZddZe
ddZddZe
ddZe
ddZe
ddZddZddZd d!Ze
d"d#Ze
d$d%d&Ze
d'd(Ze
fd)d*Ze
d+d,Ze
fd-d.ZS)1Gitgitz.gitclonegit+http	git+httpsgit+sshgit+gitgit+fileGIT_DIR
GIT_WORK_TREEHEADcCs|gS)Nr)revrrrget_base_rev_args:szGit.get_base_rev_argscCse|jt|\}}|js(dS|j||jsAdSt|j||jd}|S)NFr)get_url_rev_optionsrr'is_commit_id_equalrget_revision_sha)selfurldest_rev_optionsis_tag_or_branchrrris_immutable_rev_checkout>s	zGit.is_immutable_rev_checkoutcCs|d}|jdg}|j|rJ|t|djd}nd}dj|jddd}t|S)Nzgit version versionr.)run_command
startswithlensplitjoin
parse_version)r,VERSION_PFXr3rrrget_git_versionOs#"zGit.get_git_versioncCs]dddg}|j|dd	d|}|j}|jdrY|tddSdS)
zl
        Return the current branch, or None if HEAD isn't at a branch
        (e.g. detached HEAD).
        zsymbolic-refz-qr&extra_ok_returncodescwdzrefs/heads/N)r@)r7stripr8r9)clslocationargsoutputrefrrrget_current_branch\s
zGit.get_current_branchc
Csq|jds|d}tddB}|j|jd||jdddd|gd	|jWd
QRXd
S)z@Export the Git repository at the url to the destination location/kindexportr-zcheckout-indexz-az-fz--prefixrAN)endswithr
unpackpathr7)r,rDr-temp_dirrrrrKqs
z
Git.exportc
Csd}y|jd|gd|}Wntk
r9YnXi}xd|jjD]P}y|j\}}Wn'tk
rtdj|YnX|||<qSWdj|}dj|}	|j|}|dk	r|dfS|j|	}|d	fS)
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.
        r4zshow-refrAzunexpected show-ref line: {!r}zrefs/remotes/origin/{}zrefs/tags/{}NTF)r7rrB
splitlinesr:
ValueErrorformatget)
rCr.r'rFrefslinerrG
branch_reftag_refrrrr+~s&


zGit.get_revision_shacCs|j}|dk	st|j||\}}|dk	rg|j|}|rZ|nd|_|St|stjd||jds|S|j	t
dd||jd||j|dd}|j|}|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/fetchz-qrAr'
FETCH_HEAD)
arg_revAssertionErrorr+make_newbranch_namerloggerwarningr8r7r	to_argsget_revision)rCr.r-r0r'r	is_branchrrrresolve_revisions&
	zGit.resolve_revisioncCs|s
dS|j||kS)z
        Return whether the current commit hash equals the given name.

        Args:
          dest: the repository directory.
          name: a string name.
        F)ra)rCr.namerrrr*s	zGit.is_commit_id_equalcCs |j}tjd||t||jtdd|||jr|j|||}t|dd}|dkr|j	||jstdd|j
}|j|d|nL|j||krdj|}dd|d	|g}|j|d||j
|dS)
NzCloning %s%s to %srz-qr]checkoutrAz	origin/{}z-bz--track)
to_displayr^inforr7r	r'rcgetattrr*r`rHrRupdate_submodules)r,r.r-r0rev_displayr]cmd_argstrack_branchrrr	fetch_news 	z
Git.fetch_newcCs[|jtdd|d|tdd|j}|j|d||j|dS)Nconfigzremote.origin.urlrArez-q)r7r	r`ri)r,r.r-r0rkrrrswitchsz
Git.switchcCs|jtdkr7|jdddgd|n|jddgd||j|||}tddd|j}|j|d||j|dS)Nz1.9.0rXz-qz--tagsrAresetz--hard)r>r<r7rcr	r`ri)r,r.r-r0rkrrrupdatesz
Git.updatecCs|jdddgdd
d|}|j}y|d}Wntk
rXtYnXx$|D]}|jdr`|}Pq`W|jd	d}|jS)z
        Return URL of the first remote encountered.

        Raises RemoteNotFoundError if the repository does not have a remote
        url configured.
        rnz--get-regexpzremote\..*\.urlr?r@rArzremote.origin.url  )r@)r7rP
IndexErrorrr8r:rB)rCrDstdoutremotesfound_remoteremoter-rrrget_remote_urls


zGit.get_remote_urlNcCs7|dkrd}|jd|gd|}|jS)Nr&z	rev-parserA)r7rB)rCrDr'current_revrrrra5s
zGit.get_revisioncCsv|jddgd|j}tjj|sHtjj||}tjjtjj|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.
        z	rev-parsez	--git-dirrAz..)r7rBosrNisabsr;abspathr)rCrDgit_dir	repo_rootrrrget_subdirectory>s!zGit.get_subdirectorycsgt|\}}}}}|jdr|dt|jd}|tj|jddjd}t|||||f}|jdd}	|d|	t||	d||||f}d|kr9d|kst	|jd	d
}t
t|j|\}}
}|jdd}n!t
t|j|\}}
}||
|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.
        fileNrI\+r@z://zfile:zgit+z
git+ssh://zssh://r4)
urlsplitrLr9lstripurllib_requesturl2pathnamereplace
urlunsplitfindr[superrget_url_rev_and_auth)rCr-schemenetlocrNqueryfragmentinitial_slashesnewpath
after_plusr'	user_pass)	__class__rrrMs" #!!zGit.get_url_rev_and_authcCsKtjjtjj|ds%dS|jdddddgd|dS)Nz.gitmodules	submodulerqz--initz--recursivez-qrA)rzrNexistsr;r7)rCrDrrrrips
!zGit.update_submodulescstt|j|}|r"|Sy%|jddgd|dd}Wn;tk
rotjd|dSYntk
rdSYnXtj	j
|jdS)Nz	rev-parsez--show-toplevelrAlog_failed_cmdFzKcould not determine if %s is under git control because git is not availablez
)rrget_repository_rootr7rr^debugrrzrNnormpathrstrip)rCrDlocr)rrrrys

	
	zGit.get_repository_root)rrr r!r"r#)r$r%)__name__
__module____qualname__rddirname	repo_nameschemes
unset_environdefault_arg_revstaticmethodr(r2r>classmethodrHrKr+rcr*rmrorqrxrarrrirrr)rrr.s0

(-#	r).
__future__rloggingos.pathrzrepip._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	getLoggerrr^compilerrrregisterrrrr<module>s0"		`
Back to Directory File Manager