On this page
hg - Manages Mercurial (hg) repositories
Synopsis
- Manages Mercurial (hg) repositories. Supports SSH, HTTP/S and local address.
 
Parameters
| Parameter | Choices/Defaults | Comments | 
|---|---|---|
| clone  
        bool
         
        (added in 2.3)
         | 
      
       
  | 
      
        
        If  no, do not clone the repository if it does not exist locally.
        | 
     
| dest  
        required
         | 
      
        
        Absolute path of where the repository should be cloned to. This parameter is required, unless clone and update are set to no
         | 
     |
| executable  
        (added in 1.4)
         | 
      
        
        Path to hg executable to use. If not supplied, the normal mechanism for resolving binary paths will be used.
         | 
     |
| force  
        bool
         | 
      
       
  | 
      
        
        Discards uncommitted changes. Runs  hg update -C. Prior to 1.9, the default was `yes`.
        | 
     
| purge  
        bool
         | 
      
       
  | 
      
        
        Deletes untracked files. Runs  hg purge.
        | 
     
| repo  
        required
         | 
      
        
        The repository address.
        
       aliases: name  | 
     |
| revision | 
        
        Equivalent  
       -r option in hg command which could be the changeset, revision number, branch name or even tag.
       aliases: version  | 
     |
| update  
        bool
         
        (added in 2.0)
         | 
      
       
  | 
      
        
        If  no, do not retrieve new revisions from the origin repository
        | 
     
Notes
Note
- This module does not support push capability. See https://github.com/ansible/ansible/issues/31156.
 - If the task seems to be hanging, first verify remote host is in 
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/etc/ssh/ssh_known_hostsbefore 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 https://bitbucket.org/blog/deprecating-tlsv1-tlsv1-1-2018-12-01.
 
Examples
- 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
  Status
This module is flagged as preview which means that it is not guaranteed to have a backwards compatible interface.
Maintenance
This module is flagged as community which means that it is maintained by the Ansible Community. See Module Maintenance & Support for more info.
For a list of other modules that are also maintained by the Ansible Community, see here.
Author
- Yeukhon Wong (@yeukhon)
 
Hint
If you notice any issues in this documentation you can edit this document to improve it.
© 2012–2018 Michael DeHaan
© 2018–2019 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
 https://docs.ansible.com/ansible/2.6/modules/hg_module.html