�
�Udac @` s� d d l m Z m Z m Z e Z i d d 6d g d 6d d 6Z d Z d Z d d
l Z d d l
m Z d d l m
Z
d
e f d � � YZ d � Z e d k r� e � n d
S( i ( t absolute_importt divisiont print_functions 1.1t metadata_versiont previewt statust communityt supported_bys�
---
module: hg
short_description: Manages Mercurial (hg) repositories
description:
- Manages Mercurial (hg) repositories. Supports SSH, HTTP/S and local address.
version_added: "1.0"
author: "Yeukhon Wong (@yeukhon)"
options:
repo:
description:
- The repository address.
required: yes
aliases: [ name ]
dest:
description:
- Absolute path of where the repository should be cloned to.
This parameter is required, unless clone and update are set to no
required: yes
revision:
description:
- Equivalent C(-r) option in hg command which could be the changeset, revision number,
branch name or even tag.
aliases: [ version ]
force:
description:
- Discards uncommitted changes. Runs C(hg update -C). Prior to
1.9, the default was `yes`.
type: bool
default: 'no'
purge:
description:
- Deletes untracked files. Runs C(hg purge).
type: bool
default: 'no'
update:
description:
- If C(no), do not retrieve new revisions from the origin repository
type: bool
default: 'yes'
version_added: '2.0'
clone:
description:
- If C(no), do not clone the repository if it does not exist locally.
type: bool
default: 'yes'
version_added: '2.3'
executable:
description:
- Path to hg executable to use. If not supplied,
the normal mechanism for resolving binary paths will be used.
version_added: '1.4'
notes:
- This module does not support push capability. See U(https://github.com/ansible/ansible/issues/31156).
- "If the task seems to be hanging, first verify remote host is in C(known_hosts).
SSH will prompt user to authorize the first contact with a remote host. To avoid this prompt,
one solution is to add the remote host public key in C(/etc/ssh/ssh_known_hosts) before calling
the hg module, with the following command: ssh-keyscan remote_host.com >> /etc/ssh/ssh_known_hosts."
- As per 01 Dec 2018, Bitbucket has dropped support for TLSv1 and TLSv1.1 connections. As such,
if the underlying system still uses a Python version below 2.7.9, you will have issues checking out
bitbucket repositories. See U(https://bitbucket.org/blog/deprecating-tlsv1-tlsv1-1-2018-12-01).
s�
- name: Ensure the current working copy is inside the stable branch and deletes untracked files if any.
hg:
repo: https://bitbucket.org/user/repo1
dest: /home/user/repo1
revision: stable
purge: yes
- name: Get information about the repository whether or not it has already been cloned locally.
hg:
repo: git://bitbucket.org/user/repo
dest: /srv/checkout
clone: no
update: no
N( t
AnsibleModule( t to_nativet Hgc B` s� e Z d � Z d � Z d � Z d � Z d � Z d � Z d � Z d � Z d � Z
d � Z d
� Z d � Z
e d � � Z RS(
c C` s1 | | _ | | _ | | _ | | _ | | _ d S( N( t modulet destt repot revisiont hg_path( t selfR R R
R R ( ( sE /usr/lib/python2.7/site-packages/ansible/modules/source_control/hg.pyt __init__e s
c C` s2 | j j | j g | � \ } } } | | | f S( N( R t run_commandR ( R t args_listt rct outt err( ( sE /usr/lib/python2.7/site-packages/ansible/modules/source_control/hg.pyt _commandl s %c C` s( d d d d | j d g } | j | � S( Nt purges --configs extensions.purge=s -Rs --print( R R ( R t args( ( sE /usr/lib/python2.7/site-packages/ansible/modules/source_control/hg.pyt _list_untrackedp s c C` sf | j d d d d d | j g � \ } } } | d k rO | j j d | � n t | � j d � Sd S(
s[
hg id -b -i -t returns a string in the format:
"<changeset>[+] <branch_name> <tag>"
This format lists the state of the current working copy,
and indicates whether there are uncommitted changes by the
plus sign. Otherwise, the sign is omitted.
Read the full description via hg id --help
t ids -bs -is -ts -Ri t msgs
N( R R R t fail_jsonR t strip( R R R R ( ( sE /usr/lib/python2.7/site-packages/ansible/modules/source_control/hg.pyt get_revisiont s
-c C` sZ | j d | j g � \ } } } | d k rC | j j d | � n t | � j d � Sd S( NR i R s
( R R
R R R R ( R R R R ( ( sE /usr/lib/python2.7/site-packages/ansible/modules/source_control/hg.pyt get_remote_revision� s !c C` s$ | j � } d | k r t St Sd S( Nt +( R t Truet False( R t now( ( sE /usr/lib/python2.7/site-packages/ansible/modules/source_control/hg.pyt has_local_mods� s c C` s� | j � } | s t Sd d d | j d d g } | j | � \ } } } | d k rk | j j d | � n | j � } | | k r� | r� t Sd S( Nt updates -Cs -Rs -rt .i R ( R% R# R R R R R"