HEX
Server: Apache
System: Linux p102.lithium.hosting 4.18.0-553.141.1.el8_10.x86_64 #1 SMP Fri Jul 10 17:48:02 UTC 2026 x86_64
User: bvzmoamr (9955)
PHP: 8.1.34
Disabled: syslog
Upload Files
File: //proc/self/root/proc/thread-self/root/lib64/python2.7/site-packages/hgext/notify.pyo
�
1�3\c@@skdZddlmZddljZddljZddl	Z	ddl
Z
ddlZddlm
Z
ddlmZmZmZmZmZmZmZddlmZmZdZiZeje�Zedd	d
d�eddd
d�eddd
e�edd
d
d�eddd
d�eddd
d�eddd
d�eddd
d�eddd
d�eddd
d�eddd
e�eddd
d�eddd
d�eddd
d�eddd
d�eddd
d�eddd
d�eddd
e�d j�Zd!Z ie d	6Z!d"e"fd#��YZ#ddd$�Z$dS(%s�hooks for sending email push notifications

This extension implements hooks to send email notifications when
changesets are sent from or received by the local repository.

First, enable the extension as explained in :hg:`help extensions`, and
register the hook you want to run. ``incoming`` and ``changegroup`` hooks
are run when changesets are received, while ``outgoing`` hooks are for
changesets sent to another repository::

  [hooks]
  # one email for each incoming changeset
  incoming.notify = python:hgext.notify.hook
  # one email for all incoming changesets
  changegroup.notify = python:hgext.notify.hook

  # one email for all outgoing changesets
  outgoing.notify = python:hgext.notify.hook

This registers the hooks. To enable notification, subscribers must
be assigned to repositories. The ``[usersubs]`` section maps multiple
repositories to a given recipient. The ``[reposubs]`` section maps
multiple recipients to a single repository::

  [usersubs]
  # key is subscriber email, value is a comma-separated list of repo patterns
  user@host = pattern

  [reposubs]
  # key is repo pattern, value is a comma-separated list of subscriber emails
  pattern = user@host

A ``pattern`` is a ``glob`` matching the absolute path to a repository,
optionally combined with a revset expression. A revset expression, if
present, is separated from the glob by a hash. Example::

  [reposubs]
  */widgets#branch(release) = qa-team@example.com

This sends to ``qa-team@example.com`` whenever a changeset on the ``release``
branch triggers a notification in any repository ending in ``widgets``.

In order to place them under direct user management, ``[usersubs]`` and
``[reposubs]`` sections may be placed in a separate ``hgrc`` file and
incorporated by reference::

  [notify]
  config = /path/to/subscriptionsfile

Notifications will not be sent until the ``notify.test`` value is set
to ``False``; see below.

Notifications content can be tweaked with the following configuration entries:

notify.test
  If ``True``, print messages to stdout instead of sending them. Default: True.

notify.sources
  Space-separated list of change sources. Notifications are activated only
  when a changeset's source is in this list. Sources may be:

  :``serve``: changesets received via http or ssh
  :``pull``: changesets received via ``hg pull``
  :``unbundle``: changesets received via ``hg unbundle``
  :``push``: changesets sent or received via ``hg push``
  :``bundle``: changesets sent via ``hg unbundle``

  Default: serve.

notify.strip
  Number of leading slashes to strip from url paths. By default, notifications
  reference repositories with their absolute path. ``notify.strip`` lets you
  turn them into relative paths. For example, ``notify.strip=3`` will change
  ``/long/path/repository`` into ``repository``. Default: 0.

notify.domain
  Default email domain for sender or recipients with no explicit domain.

notify.style
  Style file to use when formatting emails.

notify.template
  Template to use when formatting emails.

notify.incoming
  Template to use when run as an incoming hook, overriding ``notify.template``.

notify.outgoing
  Template to use when run as an outgoing hook, overriding ``notify.template``.

notify.changegroup
  Template to use when running as a changegroup hook, overriding
  ``notify.template``.

notify.maxdiff
  Maximum number of diff lines to include in notification email. Set to 0
  to disable the diff, or -1 to include all of it. Default: 300.

notify.maxdiffstat
  Maximum number of diffstat lines to include in notification email. Set to -1
  to include all of it. Default: -1.

notify.maxsubject
  Maximum number of characters in email's subject line. Default: 67.

notify.diffstat
  Set to True to include a diffstat before diff content. Default: True.

notify.showfunc
  If set, override ``diff.showfunc`` for the diff content. Default: None.

notify.merge
  If True, send notifications for merge changesets. Default: True.

notify.mbox
  If set, append mails to this mbox file instead of sending. Default: None.

notify.fromauthor
  If set, use the committer of the first changeset in a changegroup for
  the "From" field of the notification mail. If not set, take the user
  from the pushing repo.  Default: False.

If set, the following entries will also be used to customize the
notifications:

email.from
  Email ``From`` address to use if none can be found in the generated
  email content.

web.baseurl
  Root repository URL to combine with repository paths when making
  references. See also ``notify.strip``.

i(tabsolute_importN(t_(tencodingterrort
logcmdutiltmailtpatcht	registrartutil(tdateutilt
stringutilsships-with-hg-coretnotifytchangegrouptdefaulttconfigtdiffstattdomaint
fromauthortincomingtmaxdiffi,tmaxdiffstati����t
maxsubjectiCtmboxtmergetoutgoingtsourcestservetshowfunctstriptstylettemplatettests�
Subject: changeset in {webroot}: {desc|firstline|strip}
From: {author}

changeset {node|short} in {root}
details: {baseurl}{webroot}?cmd=changeset;node={node|short}
description:
	{desc|tabindent|strip}
sx
changeset {node|short} in {root}
details: {baseurl}{webroot}?cmd=changeset;node={node|short}
summary: {desc|firstline}
tnotifiercB@sYeZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d	d�ZRS(
semail notification class.cC@s�||_|jjdd�}|rC|jj|dddg�n||_t|jjdd��|_|j|jj�|_|jjdd�|_|jjdd�|_	|jj
dd	�|_tj
|j�|_|j�|_|jj
dd
�|_|jj
dd�|_|jdkrH|jj
dd�|_nd}|jjd|�pu|jjdd
�}|s�|jjdd�}n|r�|r�tj|�p�t}ntj||�}tj|j|j|�|_dS(NRRtsectionstusersubstreposubsRRRRRRtdiffRR(tuiRt
readconfigtrepotintt
stripcountRtrootRRt
configboolRRt	_charsetstcharsetstsubscriberstsubsRRtNonetdeftemplatestgettsingle_templateRttemplatespectchangesettemplatertt(tselfR%R'thooktypetcfgtmapfileRtspec((s2/usr/lib64/python2.7/site-packages/hgext/notify.pyt__init__s2		cC@sftj|�}|j}xG|dkra|jd�}|dkrFPn||d}|d8}qW|S(s?strip leading slashes from local path, turn into web-safe path.it/i����i(RtpconvertR)tfind(R7tpathtcounttc((s2/usr/lib64/python2.7/site-packages/hgext/notify.pyRs	cC@shtj|j��}|jrd|jd�}|dkrF|| }nd|krd|d|jSn|S(s try to clean up email addresses.s
@localhosti����t@(R
temailRRR?(R7taddrta((s2/usr/lib64/python2.7/site-packages/hgext/notify.pytfixmail)s	
c	C@s�t�}x�|jjd�D]�\}}x�|jd�D]p}d|kre|jdd�\}}nd}tj|jj|j��r8|j	|j
|�|f�q8q8WqWx�|jjd�D]�\}}d|kr�|jdd�\}}nd}tj|jj|�r�x6|jd�D]"}|j	|j
|�|f�q$Wq�q�Wgt|�D]3\}}tj
|j||j|j�|f^q^S(s;return list of email addresses of subscribers to this repo.R"t,t#iR#N(tsetR%tconfigitemstsplitR0tfnmatchR'R*RtaddRGtsortedRt
addressencodeR-R(	R7R/tusertpatstpattrevstuserststr((s2/usr/lib64/python2.7/site-packages/hgext/notify.pyR.5s"	''cK@ss|jr&t|j��dkr&tS|jj|d|j�d|jjdd�d|j	j
d|j
|�tS(s6format one changeset, unless it is a suppressed merge.itchangestbaseurltwebR*twebroot(RtlentparentstFalseR6tshowt	changesetR%RR'R*tTrue(R7tctxtprops((s2/usr/lib64/python2.7/site-packages/hgext/notify.pytnodeKs"cC@s%|jjdd�j�}||kS(s<true if incoming changes from this source should be skipped.RR(R%RRL(R7tsourcet
ok_sources((s2/usr/lib64/python2.7/site-packages/hgext/notify.pyt
skipsourceTscC@s9t�}xs|jD]h\}}|dkr>|j|�qn|jjd||j��}t|�r|j|�qqqWt|�dkr�|jj	d�dSt
j�}y|jt
j|��}	Wn%tjk
r�}
tj|
��nXt
j|	d�}t
j|	d�}|	d=|	d=|	j�s�|	j�}
|	j�}tj|j||j|j�}	x!|
D]\}}||	|<quWnt
jtjdd��|	d	<|s|d
kr�td�|j|f}q|j�j �j!dd
�dj"�}d
|j|f}nt#|jj$dd��}|rSt%j&||�}nt
jtj'|j||j|j��|	d<|s�|jj$dd�p�|jj(�}nd|ks�d|kr�|j)|�}nt
jtj*|j||j|j��|	d<d||	d<|	dskt
jd|t#t+j+��t,|jj�t
jt-j.��f�|	d<nt
jdj/t0|���|	d<t
j|	j1��}|jr�|jj2|�|j3d�s5|jj2d�q5nU|jj4td�t|�|f�tj5|jt%j6|	d�||d|j7�dS(s
send message.s
%r and %d:is3notify: no subscribers to selected repo and revset
NtFromtSubjecttformats%a, %d %b %Y %H:%M:%S %1%2tDateis%s: %d new changesetss
s%s: %sRRRDtfromRCs
@localhostschangeset %ssX-Hg-Notifications
Message-Ids<hg.%s.%d.%d@%s>s, tTos*notify: sending %d subscribers %d changes
R(8RJR/R0RNR'RTtrevR\R%tdebugtemailparsertParsertparsestrRtstrfromlocaltemailerrorstMessageParseErrorRtAbortt
strtolocaltis_multiparttitemstget_payloadRt
mimeencodeR-RR	tdatestrRR*tdescriptiontlstripRLtrstripR(RR
tellipsist
headencodetusernameRGRPttimethashtsockettgetfqdntjoinROt	as_stringtwritetendswithtstatustsendmailRDR(R7RbRAtdataR/tsubR;RTtptmsgtinsttsendertsubjecttheaderstpayloadtktvRVRtmsgtext((s2/usr/lib64/python2.7/site-packages/hgext/notify.pytsendYsx	


!(('(
#"	cC@s=t|jjdd��}|j�j�}|rB|j�}n|j�}tj|j�}|j|_tj|j	||d|�}dj
|�j�}|jjdd�r�t|jjdd��}tj
|�}	|	r�|dkrp|	jd�|d	krp|	jd�}	td
�}
|jj|
t|	�d|f�|jjdj
|	| |	d��q�|jjtd
�|	�q�n|dkr�dS|dkr�t|�|kr�td�}
|jj|
t|�|f�|| }n)|r |jjtd�t|��n|jjdj
|��dS(NRRtoptstRRis
is,
diffstat (truncated from %d to %d lines):

ii����s
diffstat:

%ss)
diffs (truncated from %d to %d lines):

s
diffs (%d lines):

(R(R%Rtp1RdRtdiffalloptsRR$R'R�t
splitlinesR+RRARLRR�R\(R7RbtrefRtprevtdiffoptstchunkst	difflinesRRVR�((s2/usr/lib64/python2.7/site-packages/hgext/notify.pyR$�s8%$(  
#N(t__name__t
__module__t__doc__R<RRGR.RdRgR�R0R$(((s2/usr/lib64/python2.7/site-packages/hgext/notify.pyR �s		
						Sc
K@sTt|||�}|j�|}|jsC|jd|j�dS|j|�rg|jd|�dS|j�d}d}	d}
|dks�|dkr_x�|jjd|j	��D]�}|j
||�r�|	d	7}	|
s;||j�}
q;q�||j�7}|j
td
�|||j�d f�|j�q�W|	r�|j||d�q�n�|j	�|kr�|j
|�s�|j�|j
td
�|j	�|j�d f�dS|	d	7}	|j|�|
s�|j�}
q�n||j�7}|jd
d�}|
r4|r4djd|
|g�}n|	rP|j||	|�ndS(s�send email notifications to interested subscribers.

    if used as changegroup hook, send one email for all changesets in
    changegroup. else send one email per changeset.s(notify: no subscribers to repository %s
Ns,notify: changes have source "%s" - skipping
R�iRRtstartis1notify: suppressing notification for merge %d:%s
ittipRRs
sFrom: %s(R t
unfilteredR/RoR*Rgt
pushbuffert	changelogRTRnRdRQt	popbuffertnoteRthexR$RR�R�(
R%R'R8RdRetkwargstnRbR�RAtauthorRnR((s2/usr/lib64/python2.7/site-packages/hgext/notify.pythook�sP	
"



(%R�t
__future__Rtemail.errorsterrorsRttemail.parsertparserRpRMR�R�tmercurial.i18nRt	mercurialRRRRRRRtmercurial.utilsR	R
t
testedwithtconfigtablet
configitemR0RaR~R3tmultiple_templateR1tobjectR R�(((s2/usr/lib64/python2.7/site-packages/hgext/notify.pyt<module>�sl4			
�