a [fQ@sddlZddlZddlZddlmZmZddlmZmZddl m Z m Z ddl m Z ddlmZddlmZmZmZmZeeZGdd d eZeedS) N)ListOptional) BadCommandInstallationError) HiddenText display_path) make_command) path_to_url) RevOptionsVersionControl(find_path_to_project_root_from_repo_rootvcscseZdZdZdZdZdZeee edddZ ee e dd d d Z ee e dd d d Zee e dd ddZeeedddZeeedddZeeedddZeeeeedddZeeeedddZeeeedfdd ZZS) MercurialZhgz.hgclone)zhg+filezhg+httpzhg+httpszhg+sshzhg+static-http)revreturncCs|gS)N)rrr?/usr/lib/python3.9/site-packages/pip/_internal/vcs/mercurial.pyget_base_rev_args szMercurial.get_base_rev_argsN)desturl rev_optionsrcCsP|}td||t||tddd|||jtdd||ddS)NzCloning hg %s%s to %srz --noupdate-qupdatecwd)Z to_displayloggerinfor run_commandrto_args)selfrrrZ rev_displayrrr fetch_new$szMercurial.fetch_newc Cstj||jd}t}zR|||dd|jt |d}| |Wdn1s`0YWn8t tj fy}zt d||WYd}~n(d}~00tdd|}|j||ddS) NZhgrcpathsdefaultwz/Could not switch Mercurial repository to %s: %srrr)ospathjoindirname configparserZRawConfigParserreadsetZsecretopenwriteOSErrorZNoSectionErrorrZwarningrrr) r rrrZ repo_configZconfigZ config_fileexccmd_argsrrrswitch2s  ,$zMercurial.switchcCs4|jddg|dtdd|}|j||ddS)NZpullrrr)rrr)r rrrr0rrrr@szMercurial.update)locationrcCs4|jddgdd|d}||r,t|}|S)NZ showconfigz paths.defaultFT show_stdout stdout_onlyr)rstripZ_is_local_repositoryr )clsr2rrrrget_remote_urlEs  zMercurial.get_remote_urlcCs|jddgdd|d}|S)zW Return the repository-local changeset revision number, as an integer. parentsz--template={rev}FTr3rr6)r7r2Zcurrent_revisionrrr get_revisionQs zMercurial.get_revisioncCs|jddgdd|d}|S)zh Return the changeset identification hash, as a 40-character hexadecimal string r9z--template={node}FTr3r:)r7r2Zcurrent_rev_hashrrrget_requirement_revision^s z"Mercurial.get_requirement_revision)rnamercCsdS)z&Always assume the versions don't matchFr)r7rr=rrris_commit_id_equallszMercurial.is_commit_id_equalcCsD|jdgdd|d}tj|s:tjtj||}t||S)z Return the path to Python project root, relative to the repo root. Return None if the project root is in the repo root. rootFTr3)rr6r%r&isabsabspathr'r )r7r2Z repo_rootrrrget_subdirectoryqs   zMercurial.get_subdirectorycsvt|}|r|Sz|jdg|ddddd}Wn2tyPtd|YdStybYdS0tj | dS)Nr?FTraise)rr4r5Z on_returncodeZlog_failed_cmdzIcould not determine if %s is under hg control because hg is not availablez ) superget_repository_rootrrrdebugrr%r&normpathrstrip)r7r2locr __class__rrrEs*    zMercurial.get_repository_root)__name__ __module__ __qualname__r=r(Z repo_nameZschemes staticmethodstrrrrr r!r1r classmethodr8r;r<rboolr>rBrE __classcell__rrrKrrs*    r)r)Zloggingr%typingrrZpip._internal.exceptionsrrZpip._internal.utils.miscrrZpip._internal.utils.subprocessrZpip._internal.utils.urlsr Z pip._internal.vcs.versioncontrolr r r r Z getLoggerrMrrregisterrrrrs