File: //opt/saltstack/salt/lib/python3.10/site-packages/salt/states/__pycache__/hg.cpython-310.pyc
o
�N�g � @ s� d Z ddlZddlZddlZddlZddlmZ ddlm Z m
Z
e�e�Z
ejj�� r-dndZdd� Z
ddd�Zd
d� Zdd� Zdd� ZdS )a�
Interaction with Mercurial repositories
=======================================
Before using hg over ssh, make sure the remote host fingerprint already exists
in ~/.ssh/known_hosts, and the remote host has this host's public key.
.. code-block:: yaml
https://bitbucket.org/example_user/example_repo:
hg.latest:
- rev: tip
- target: /tmp/example_repo
� N)�CommandExecutionError)�_fail�
_neutral_testzhg.exeZhgc C s t d t�rdS ddt� d�fS )z&
Only load if hg is available
zcmd.has_execTFzCommand z
not found)�__salt__� HG_BINARY� r r �B/opt/saltstack/salt/lib/python3.10/site-packages/salt/states/hg.py�__virtual__ s r FTc
C s� | ddi d�} |st | d�S tj�|�otj�|� d��}
|
r-t| | |||||||� } | S tj�|�r@t| ||�}|dur?|S nt�d|� td rUt | d | � d
|� ��S t
| || ||||� | S )a�
Make sure the repository is cloned to the given directory and is up to date
name
Address of the remote repository as passed to "hg clone"
rev
The remote branch, tag, or revision hash to clone/pull
target
Target destination directory path on minion to clone into
clean
Force a clean update with -C (Default: False)
user
Name of the user performing repository management operations
.. versionadded:: 0.17.0
identity
Private SSH key on the minion server for authentication (ssh://)
.. versionadded:: 2015.5.0
force
Force hg to clone into pre-existing directories (deletes contents)
opts
Include additional arguments and options to the hg command line
update_head
Should we update the head if new changes are found? Defaults to True
.. versionadded:: 2017.7.0
T� )�name�result�comment�changesz"target option is requiredz/.hgNz.target %s is not found, "hg clone" is required�test�Repository z is about to be cloned to )r �os�path�isdir�_update_repo�_handle_existing�log�debug�__opts__r �_clone_repo)r �rev�target�clean�user�identity�force�opts�update_head�retZ
is_repositoryZfailr r r �latest&