HEX
Server: Apache
System: Linux server2.voipitup.com.au 4.18.0-553.109.1.lve.el8.x86_64 #1 SMP Thu Mar 5 20:23:46 UTC 2026 x86_64
User: posscale (1027)
PHP: 8.2.30
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/__pycache__/hg.cpython-310.pyc
o

�N�gB�@s�dZddlZddlZddlZddlmZe�e�Z	dd�Z
dd�Zdd
d�Zddd
�Z
ddd�Zddd�Zddd�Zddd�Zddd�ZdS)z
Support for the Mercurial SCM
�N)�CommandExecutionErrorcCstjj�d�durdSdS)z&
    Only load if hg is installed
    �hgN)Fz9The hg execution module cannot be loaded: hg unavailable.T)�salt�utils�path�which�rr�C/opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/hg.py�__virtual__sr
cCsdd|��gS)Nz--sshzssh -i r)Z
identity_pathrrr	�	_ssh_flagsr�tipFcCsFddd|sdndd|�g}td|||dd	�}|d
dkr!|dSdS)
a�
    Returns the long hash of a given identifier (hash, branch, tag, HEAD, etc)

    cwd
        The path to the Mercurial repository

    rev: tip
        The revision

    short: False
        Return an abbreviated commit hash

    user : None
        Run hg as a user other than what the minion runs as

    CLI Example:

    .. code-block:: bash

        salt '*' hg.revision /path/to/repo mybranch
    r�idz-iz--debug��-r�cmd.run_allF��cwd�runas�python_shell�retcoder�stdout)�__salt__)r�rev�short�user�cmd�resultrrr	�revisions
rcCs8ddd|�ddg}td|||dd�}|pt||d	d
�S)a]
    Mimic git describe and return an identifier for the given revision

    cwd
        The path to the Mercurial repository

    rev: tip
        The path to the archive tarball

    user : None
        Run hg as a user other than what the minion runs as

    CLI Example:

    .. code-block:: bash

        salt '*' hg.describe /path/to/repo
    r�logrz
--templatez4'{{latesttag}}-{{latesttagdistance}}-{{node|short}}'�cmd.run_stdoutFrT)r)rr)rrrr�descrrr	�describe<s�r!cCs`dd|�d|�g}|r|�d�|�|��|r&|�d�|�d|�d��td|||dd	�S)
a�
    Export a tarball from the repository

    cwd
        The path to the Mercurial repository

    output
        The path to the archive tarball

    rev: tip
        The revision to create an archive from

    fmt: None
        Format of the resulting archive. Mercurial supports: tar,
        tbz2, tgz, zip, uzip, and files formats.

    prefix : None
        Prepend <prefix>/ to every filename in the archive

    user : None
        Run hg as a user other than what the minion runs as

    If ``prefix`` is not specified it defaults to the basename of the repo
    directory.

    CLI Example:

    .. code-block:: bash

        salt '*' hg.archive /path/to/repo output=/tmp/archive.tgz fmt=tgz
    r�archivez--revz--typez--prefix�"zcmd.runFr)�appendr)r�outputr�fmt�prefixrrrrr	r"\s!�

r"cCs�ddg}|r
|�t|��|r|��D]}|�|�q|dur$|�|�td|||dd�}|ddkrAtd	�|�d
|d����|dS)aD
    Perform a pull on the given repository

    cwd
        The path to the Mercurial repository

    repository : None
        Perform pull from the repository different from .hg/hgrc:[paths]:default

    opts : None
        Any additional options to add to the command line

    user : None
        Run hg as a user other than what the minion runs as

    identity : None
        Private SSH key on the minion server for authentication (ssh://)

        .. versionadded:: 2015.5.0

    CLI Example:

    .. code-block:: bash

        salt '*' hg.pull /path/to/repo opts=-u
    r�pullNrFrrr�Hg command failed: {}�stderrr)�extendr�splitr$rr�format�get)r�optsr�identity�
repositoryr�opt�retrrr	r(�s
�r(cCs\dd|�g}|r
|�d�td|||dd�}|ddkr*td	�|�d
|d����|dS)ae
    Update to a given revision

    cwd
        The path to the Mercurial repository

    rev
        The revision to update to

    force : False
        Force an update

    user : None
        Run hg as a user other than what the minion runs as

    CLI Example:

    .. code-block:: bash

        salt devserver1 hg.update /path/to/repo somebranch
    r�updatez-CrFrrrr)r*r)r$rrr-r.)rr�forcerrr3rrr	r4�s
�r4cCs�dd|�|�g}|r|��D]}|�|��q|r |�t|��td||dd�}|ddkr<td�|�d	|d
����|d
S)a"
    Clone a new repository

    cwd
        The path to the Mercurial repository

    repository
        The hg URI of the repository

    opts : None
        Any additional options to add to the command line

    user : None
        Run hg as a user other than what the minion runs as

    identity : None
        Private SSH key on the minion server for authentication (ssh://)

        .. versionadded:: 2015.5.0

    CLI Example:

    .. code-block:: bash

        salt '*' hg.clone /path/to/repo https://bitbucket.org/birkenfeld/sphinx
    r�clonerF)rrrrr)r*r)r,r$r+rrrr-r.)rr1r/rr0rr2r3rrr	r6�s�r6cs6��fdd��tjj�|�r�fdd�|D�S�|�S)aX
    Show changed files of the given repository

    cwd
        The path to the Mercurial repository

    opts : None
        Any additional options to add to the command line

    user : None
        Run hg as a user other than what the minion runs as

    CLI Example:

    .. code-block:: bash

        salt '*' hg.status /path/to/repo
    c		s�ddg}�r���D]}|�|��q
td||�dd�}dddd	d
ddd
d�}i}|��D]}||d|dd�}}||vrEg||<||�|�q.|S)Nr�statusrFrZmodifiedZaddedZremovedZclean�missingznot trackedZignoredzorigin of the previous file)�M�A�R�C�!�?�I� r�)r,r$r�
splitlines)	rrr2�out�typesr3�line�t�f)r/rrr	�_statuss*�
zstatus.<locals>._statuscsi|]}|�|��qSrr)�.0r)rHrr	�
<dictcomp>4szstatus.<locals>.<dictcomp>)rr�dataZis_iter)rr/rr)rHr/rr	r7sr7)rFN)rN)rNNN)NNNN)FN)NNN)NN)�__doc__�loggingZsalt.utils.datarZsalt.utils.pathZsalt.exceptionsr�	getLogger�__name__rr
rrr!r"r(r4r6r7rrrr	�<module>s



 
 
0
-
#+