3
Pf
@ s d dl mZ d dlZd dlZd dlZd dlmZmZ d dlm Z m
Z
d dlmZ d dl
mZ ejeZG dd de
Ze je dS ) )absolute_importN)display_pathrmtree)vcsVersionControl)path_to_url)configparserc @ sd e Zd ZdZdZdZdZdd Zd
d Zdd
Z dd Z
dd Zdd Zdd Z
dd Zdd ZdS ) Mercurialhgz.hgclonehg+httphg+httpshg+sshhg+static-httpc C s> t jdd}| j| z| jd|gd|d W dt| X dS )z?Export the Hg repository at the url to the destination locationz-exportzpip-archiveF)show_stdoutcwdN)tempfileZmkdtempunpackrun_commandr )selflocationZtemp_dir r /usr/lib/python3.6/mercurial.pyexport s
zMercurial.exportc C s t jj|| jd}tj }y<|j| |jdd| t|d}|j | W d Q R X W n6 t
tjfk
r } ztj
d|| W Y d d }~X nX | jddg| |d d S ) NZhgrcpathsdefaultwz/Could not switch Mercurial repository to %s: %supdatez-q)r )ospathjoindirnamer ZSafeConfigParserreadsetopenwriteOSErrorZNoSectionErrorloggerZwarningr )r desturlrev_optionsZrepo_configconfigZconfig_fileexcr r r switch s
zMercurial.switchc C s, | j ddg|d | j ddg| |d d S )NZpullz-q)r r )r )r r) r+ r r r r / s zMercurial.updatec C sz | j \}}|r |g}d| }ng }d}| j||||rvtjd||t| | jddd||g | jddg| |d d S ) Nz (to revision %s) zCloning hg %s%s to %sr z
--noupdatez-qr )r )Zget_url_revZcheck_destinationr( infor r )r r) r* Zrevr+ Zrev_displayr r r obtain3 s
zMercurial.obtainc C s2 | j ddgd|dj }| j|r*t|}|j S )NZ
showconfigz
paths.defaultF)r r )r stripZ_is_local_repositoryr )r r r* r r r get_urlE s
zMercurial.get_urlc C s | j ddgd|dj }|S )Nparentsz--template={rev}F)r r )r r2 )r r Zcurrent_revisionr r r get_revisionM s zMercurial.get_revisionc C s | j ddgd|dj }|S )Nr4 z--template={node}F)r r )r r2 )r r current_rev_hashr r r get_revision_hashS s zMercurial.get_revision_hashc C sT | j |}|j jds d| }|j jddd }|s