https://t.me/RX1948
Server : Apache
System : Linux iad1-shared-b8-43 6.6.49-grsec-jammy+ #10 SMP Thu Sep 12 23:23:08 UTC 2024 x86_64
User : dh_edsupp ( 6597262)
PHP Version : 8.2.26
Disable Function : NONE
Directory :  /lib/python3/dist-packages/hgext/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib/python3/dist-packages/hgext/__pycache__/releasenotes.cpython-310.pyc
o

�]Lb�W�	@sDdZddlmZddlZddlZddlZddlmZddlm	Z	ddl
mZddlm
Z
mZmZmZmZmZmZmZddlmZmZiZe�e�Zz,ddlZe���ejd	d
edd�ddlmZej Wd�n1sowYWne!y�dZYnwd
Z"ded�fded�fded�fded�fded�fgZ#e�$d�Z%dZ&ed�Z'Gdd�de(�Z)Gdd�de(�Z*dd �Z+d!d"�Z,d#d$�Z-d%d&�Z.d'd(�Z/d)d*�Z0d+d,�Z1d-d.�Z2d/d0�Z3d1d2�Z4d3d4�Z5d5d6�Z6ed7d8d9d:ed;�ed<�fd=d>d?ed@�ed<�fdAdBd?edC�dfgedD�ej7dE�dMdFdG��Z8edHdIdJ�dMdKdL��Z9dS)Na/generate release notes from commit messages (EXPERIMENTAL)

It is common to maintain files detailing changes in a project between
releases. Maintaining these files can be difficult and time consuming.
The :hg:`releasenotes` command provided by this extension makes the
process simpler by automating it.
�)�absolute_importN)�_)�open)�hex)�cmdutil�config�error�
logcmdutil�minirst�pycompat�	registrar�util)�procutil�
stringutil�ignorez.*python-Levenshtein.*zfuzzywuzzy.fuzz)�action�message�category�modulesships-with-hg-coresfeaturesNew FeaturessbcsBackwards Compatibility Changes�fixs	Bug FixessperfsPerformance ImprovementssapisAPI Changess#^\.\. ([a-zA-Z0-9_]+)::\s*([^$]+)?$s\bissue ?[0-9]{4,6}(?![0-9])\bs
Other Changesc@sTeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�ZdS)�parsedreleasenotescCs
i|_dS�N��sections��self�r�4/usr/lib/python3/dist-packages/hgext/releasenotes.py�__init__R�
zparsedreleasenotes.__init__cCs
||jvSrr�r�sectionrrr�__contains__Urzparsedreleasenotes.__contains__cCstt|j��Sr)�iter�sortedrrrrr�__iter__Xszparsedreleasenotes.__iter__cCs.|j�|ggf�|j|d�||f�dS)z Add a titled release note entry.rN�r�
setdefault�append)rr!�title�
paragraphsrrr�
addtitleditem[sz parsedreleasenotes.addtitleditemcCs*|j�|ggf�|j|d�|�dS)z[Adds a non-titled release note entry.

        Will be rendered as a bullet point.
        �Nr&)rr!r*rrr�addnontitleditem`sz#parsedreleasenotes.addnontitleditemcC�|j�|ggf�dS)z|Returns titled entries in a section.

        Returns a list of (title, paragraphs) tuples describing sub-sections.
        r�r�getr rrr�titledforsectionhsz#parsedreleasenotes.titledforsectioncCr.)z5Returns non-titled, bulleted paragraphs in a section.r,r/r rrr�nontitledforsectionosz&parsedreleasenotes.nontitledforsectioncst�fdd�|�|�D��S)Nc3s�|]	}|d�kVqdS)rNr��.0�t�r)rr�	<genexpr>ts�z8parsedreleasenotes.hastitledinsection.<locals>.<genexpr>)�anyr1)rr!r)rr6r�hastitledinsectionssz%parsedreleasenotes.hastitledinsectionc	Cs.ts	|�td��|D]�}t|�|��t|�|��}|�|�D]>\}}|�||�r6|�td�||f�q t||fg�d}|dkrPt	|�}|rPt
|||�rPq t|||�rWq |�|||�q |�|�D]/}||�|�vrnqdt|g�d}|dkr�t	|�}|r�t
|||�r�qdt|||�r�qd|�
||�qdqdS)z{Merge another instance into this one.

        This is used to combine multiple sources of release notes together.
        sKmodule 'fuzzywuzzy' not found, merging of similar releasenotes is disabled
s*%s already exists in %s section; ignoring
rrN)�fuzz�warnr�
converttitledr1�convertnontitledr2r9�write�getissuenum�	findissue�similarr+r-)	r�ui�otherr!�
existingnotesr)r*�incoming_str�issuerrr�mergevsV��������zparsedreleasenotes.mergeN)�__name__�
__module__�__qualname__rr"r%r+r-r1r2r9rGrrrrrQsrc@s.eZdZd
dd�Zdd�Zdd�Zdd	�ZdS)�releasenotessectionsNcCsF|rt�t�}t|�}|r|�|�tt�|��|_dStt�|_dSr)	r
�sortdict�DEFAULT_SECTIONS�getcustomadmonitions�update�listr�	iteritems�	_sections)rrB�repor�custom_sectionsrrrr�s

zreleasenotessections.__init__cCs
t|j�Sr)r#rRrrrrr%�rzreleasenotessections.__iter__cCsdd�|jD�S)NcSsg|]}|d�qS)rrr3rrr�
<listcomp>�sz.releasenotessections.names.<locals>.<listcomp>�rRrrrr�names�szreleasenotessections.namescCs$|jD]\}}||kr|SqdSrrV)rr)�name�valuerrr�sectionfromtitle�s
�z%releasenotessections.sectionfromtitler)rHrIrJrr%rWrZrrrrrK�s


rKcCs>g}|D]\}}g}|D]}|�|�q|�d�|��q|S)z.
    Convert titled paragraphs to strings
    � ��extendr(�join)�titledparagraphs�string_listr)r*�lines�pararrrr<�sr<cCs:g}|D]}g}|D]}|�|�q
|�d�|��q|S)z/
    Convert non-titled bullets to strings
    r[r\)�nontitledparagraphsr`r*rarbrrrr=�sr=cCs t�t|tj�}|r|��}|S)zD
    Returns issue number from the incoming string if it exists
    )�re�search�RE_ISSUE�
IGNORECASE�group)rErFrrrr?�sr?cs0t�fdd�|D��r|�td���dSdS)z?
    Returns true if issue number already exists in notes.
    c3s�|]}�|vVqdSrr�r4�s�rFrrr7�s�zfindissue.<locals>.<genexpr>s'"%s" already exists in notes; ignoring
TF)r8r>r)rB�existingrFrrkrr@�sr@cCs<t|���dkrt||�}|s|�td�|�dSdSdS)z?
    Returns true if similar note found in existing notes.
    �
s,"%s" already exists in notes file; ignoring
TF)�len�split�similaritycheckr>r)rBrlrErGrrrrA�s
��rAcCs8tsdSd}|D]}t�||�}|dkrd}|Sq|S)zK
    Returns false when note fragment can be merged to existing notes.
    T�KF)r:�token_set_ratio)rErDrG�bullet�scorerrrrps�rpcs>�d�t���d����fdd�	�d�vr�d���d�S)N�.csB|�vr�|��}��||||��dSt�td���|���)Ns#.hgreleasenotes file '%s' not found)�data�parser�Abortr�pathto)�fr�remaprv��ctx�p�readrSrrrs�z"getcustomadmonitions.<locals>.reads.hgreleasenotesssections)NN)r�items)rSrr|rrNs	
rNcs�|D]_}||}t�t|�����ra��d�|vrq|�td���d�|��dd�f��fdd���fdd�|D�}t|�dkrO|�td	�|d
�q|rad�	t
|��}|�td�|�qdS)
a`
    Checks the commit messages for admonitions and their validity.

    .. abcd::

       First paragraph under this admonition

    For this commit message, using `hg releasenotes -r . --check`
    returns: Invalid admonition 'abcd' present in changeset 3ea92981e103

    As admonition 'abcd' is neither present in default nor custom admonitions
    r,s0Invalid admonition '%s' present in changeset %s
N�cst�d��d�|���S)Nr,)�difflib�SequenceMatcherrh�ratio)�x)�
admonitionrr�<lambda>Cs�z"checkadmonitions.<locals>.<lambda>csg|]
}�|�dkr|�qS)g333333�?rri)�simrrrUG�z$checkadmonitions.<locals>.<listcomp>s(did you mean %s?)
rs, s(did you mean one of %s?)
)rdre�RE_DIRECTIVE�descriptionrhr>rrrnr^r$)rBrS�
directives�revs�revr}rA�ssr)r�r�r�checkadmonitions+s(
����r�cCs(|D]}|�d|d|df�qdS)Ns%s: %s
rr,)r>)rBrr!rrr�_getadmonitionlistOs�r�cCs^t�}|D]�}||}tj|��|d�\}}t|�D]�\}}	|	ddkr%q|	d}
|	dr5|	dd��nd}|dt|�krJt�t	d�||
f��g}t
|dt|��D]5}
||
}|dd	krbqU|ddkrjn!|dd
kr||j�t	d�||
f�|ddkr�|�
|d�qU|s�|j�t	d
�t|����|r�|�|
||�q|�|
|�qq|S)N)�admonitions�types
admonitionsadmonitiontitle�linesrr,s6changeset %s: release notes directive %s lacks content�margin�	paragraphs=changeset %s: unexpected block in release notes directive %s
�indents.error parsing releasenotes for revision: '%s'
)rr
rwr��	enumerate�striprnrrxr�rangerBr;r(r�noder+r-)rSr�r��notesr�r}�blocks�pruned�i�block�	directiver)r*�j�pblockrrr�parsenotesfromrevisionsTs`
����
���
���6r�cst�}t�|�d�d�fdd�	}d}t��D]j\}}|ddkr"q|dd}|d	d
krR|�|�}|s>t�td�|��|}||�}	|	rQ|	D]}
|�||
�qHq|d	dkry|t	krl||�}	|	D]}
|�||
�qbq||d
�}|�
|||�qt�td�|��|S)z6Parse text content containing generated release notes.rFcs$g}t|dt���D]�}�|}|ddkrq|ddkr!|S|ddkru|ddkr4t�td���|rEd	d
�|dD�}|�|�qdd
�|dD�g}�|dd�D]}|dd
vran|ddkrn|�|d�qW|�|�q|ddkr�t�td�|d��|r�|�|d�q|S)Nr,r�r��section�bulletr�rs#indented bullet lists not supportedcS�g|]
}|dd����qS�r,N�r��r4�lrrrrU�r�zJparsereleasenotesfile.<locals>.gatherparagraphsbullets.<locals>.<listcomp>r�cSr�r�r�r�rrrrU�r�)r�r�r�s*unexpected block type in release notes: %s)r�rnrrxrr()�offsetr)�notefragmentr�r�ra�r�rr�gatherparagraphsbullets�sD�
�
���z6parsereleasenotesfile.<locals>.gatherparagraphsbulletsNr�r�r�s	underline�=s!unknown release notes section: %s�-Tsunsupported section type for %s)F)rr
rwr�rZrrxrr-�BULLET_SECTIONr+)r�textr�r��currentsectionr�r�r)rX�
bullet_pointsrbr*rr�r�parsereleasenotesfile�s<%

���
r�c
Cs�g}|D]�\}}||vr
q|�|�|�dt|��|�d�|�|�D];\}}|�|�|�dt|��|�d�t|�D]\}}|rK|�d�|�tjd�|�dd����q@|�d�q%|�	|�}	|�|�r�|	r�|�t
�|�dtt
��|�d�|	D]9}|�tjd�|d�ddd	d
����|dd�D]}|�d�|�tjd�|�dd	d	d
����q�|�d�q�q|r�|d
r�|�d�d�|�S)z�Serialize release notes from parsed fragments and notes.

    This function essentially takes the output of ``parsenotesfromrevisions()``
    and ``parserelnotesfile()`` and produces output combining the 2.
    r��r�r[�N)�widthrs* s  )r��
initindent�
hangindentr,N����
)r(rnr1r�r]r�wrapr^�
splitlinesr2r�)
rr�ra�sectionname�sectiontitler)r*r�rb�	nontitledrrr�serializenotes�sb




�


��	
��	�

r��releasenotes�r�revr�s&revisions to process for release notessREV�c�checkFs+checks for validity of admonitions (if any)�l�lists/list the available admonitions with their titles"hg releasenotes [-r REV] [-c] FILE)�helpcategoryc
Ksft�|�}t||�}t�|dddg�|�d�rt||�S|�d�}t�||p(dg�}|�d�r9t	|||�
�|�St||�
�|�}|durR|�d�|�
t||��Szt|d��}t||���}	Wd�n1sjwYWnty�}
z|
jtjkr�t�}	WYd}
~
nd}
~
ww|	�||�t|d��}|�
t||	��Wd�dS1s�wYdS)	a�	parse release notes from commit messages into an output file

    Given an output file and set of revisions, this command will parse commit
    messages for release notes then add them to the output file.

    Release notes are defined in commit messages as ReStructuredText
    directives. These have the form::

       .. directive:: title

          content

    Each ``directive`` maps to an output section in a generated release notes
    file, which itself is ReStructuredText. For example, the ``.. feature::``
    directive would map to a ``New Features`` section.

    Release note directives can be either short-form or long-form. In short-
    form, ``title`` is omitted and the release note is rendered as a bullet
    list. In long form, a sub-section with the title ``title`` is added to the
    section.

    The ``FILE`` argument controls the output file to write gathered release
    notes to. The format of the file is::

       Section 1
       =========

       ...

       Section 2
       =========

       ...

    Only sections with defined release notes are emitted.

    If a section only has short-form notes, it will consist of bullet list::

       Section
       =======

       * Release note 1
       * Release note 2

    If a section has long-form notes, sub-sections will be emitted::

       Section
       =======

       Note 1 Title
       ------------

       Description of the first long-form note.

       Note 2 Title
       ------------

       Description of the second long-form note.

    If the ``FILE`` argument points to an existing file, that file will be
    parsed for release notes having the format that would be generated by this
    command. The notes from the processed commit messages will be *merged*
    into this parsed set.

    During release notes merging:

    * Duplicate items are automatically ignored
    * Items that are different are automatically ignored if the similarity is
      greater than a threshold.

    This means that the release notes file can be updated independently from
    this command and changes should not be lost when running this command on
    that file. A particular use case for this is to tweak the wording of a
    release note after it has been added to the release notes file.

    The -c/--check option checks the commit message for invalid admonitions.

    The -l/--list option, presents the user with a list of existing available
    admonitions along with their title. This also includes the custom
    admonitions (if any).
    r�r�r�snot public()Nr��rbswb)r�byteskwargsrKr�check_incompatible_argumentsr0r�r	�revranger�rWr��pagerr>r�rr�r�IOError�errno�ENOENTrrG)rBrS�file_�optsrr�r��incoming�fhr��errr�releasenotes/s8
o





����"�r�sdebugparsereleasenotesT)�norepoc	Cs|dkr
tj��}nt|d��}|��}Wd�n1swYt||�}t||�}|D]O}|�td�|�|�|�D]\}}	|�td�|�|	D]}
|�td�d�	|
��qNq?|�
|�D]}	|�td��|	D]}
|�td�d�	|
��qnqcq/dS)	z6parse release notes and print resulting data structurer�r�Nssection: %s
s  subsection: %s
s    paragraph: %s
r[s  bullet point:
)r�stdinrrrKr�r>rr1r^r2)rB�pathrSr�r�rr�r!r)r*rbrrr�debugparsereleasenotes�s*
�

����r�r):�__doc__�
__future__rr�r�rd�mercurial.i18nr�mercurial.pycompatr�mercurial.noder�	mercurialrrrr	r
rrr
�mercurial.utilsrr�cmdtable�command�warnings�catch_warnings�filterwarnings�UserWarning�fuzzywuzzy.fuzzr:rr�ImportError�
testedwithrM�compiler�rfr��objectrrKr<r=r?r@rArprNr�r�r�r�r��CATEGORY_CHANGE_NAVIGATIONr�r�rrrr�<module>s�(


����




�
]


$COI�����
u

https://t.me/RX1948 - 2025