\x89\x50\x4E\x47\x0D\x0A\x1A\x0A PNG  \x89\x50\x4E\x47\x0D\x0A\x1A\x0A  13\c@@skdZddlmZddljZddljZddl Z ddl Z ddl Z ddl m Z ddlmZmZmZmZmZmZmZddlmZmZdZiZejeZedd d dedd d dedd d eedd d deddd deddd deddd deddd deddd deddd deddd eeddd deddd deddd deddd deddd deddd deddd ed jZd!Z ie d 6Z!d"e"fd#YZ#ddd$Z$dS(%shooks 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-coretnotifyt changegrouptdefaulttconfigtdiffstattdomaint fromauthortincomingtmaxdiffi,t maxdiffstatit 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@sYeZdZdZdZdZdZdZdZdZ d dZ RS( semail notification class.cC@s||_|jjdd}|rC|jj|dddgn||_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| rtj|pt}ntj||}tj|j|j||_dS(NR RtsectionstusersubstreposubsRRRRRRtdiffRR(tuiRt readconfigtrepotintt stripcountRtrootRRt configboolRRt _charsetstcharsetst subscriberstsubsRRtNonet 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/ii(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 @localhostit@(R temailRRR?(R7taddrta((s2/usr/lib64/python2.7/site-packages/hgext/notify.pytfixmail)s    c C@st}x|jjdD]\}}x|jdD]p}d|kre|jdd\}}nd}tj|jj|jr8|j |j ||fq8q8WqWx|jjdD]\}}d|kr|jdd\}}nd}tj|jj|rx6|jdD]"}|j |j ||fq$WqqWgt |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%t configitemstsplitR0tfnmatchR'R*RtaddRGtsortedRt addressencodeR-R( R7R/tusertpatstpattrevstuserststr((s2/usr/lib64/python2.7/site-packages/hgext/notify.pyR.5s"  ' 'c K@ss|j r&t|jdkr&tS|jj|d|jd|jjddd|j j d|j |t S(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%|jjddj}||kS(s<true if incoming changes from this source should be skipped.R R(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 ddSt j }y|j t j|} Wn%tjk r} tj| nXt j| d} t j| d} | d=| d=| js| j} | j}tj|j||j|j} x!| D]\}}|| |s, tTos*notify: sending %d subscribers %d changes R(8RJR/R0RNR'RTtrevR\R%tdebugt emailparsertParsertparsestrRt strfromlocalt emailerrorstMessageParseErrorRtAbortt strtolocalt is_multiparttitemst get_payloadRt mimeencodeR-RR tdatestrRR*t descriptiontlstripRLtrstripR(RR tellipsist headencodetusernameRGRPttimethashtsockettgetfqdntjoinROt as_stringtwritetendswithtstatustsendmailRDR(R7RbRAtdataR/tsubR;RTtptmsgtinsttsendertsubjecttheaderstpayloadtktvRVRtmsgtext((s2/usr/lib64/python2.7/site-packages/hgext/notify.pytsendYsx          ! (('( #" c C@s=t|jjdd}|jj}|rB|j}n |j}tj|j}|j|_tj|j ||d|}dj |j }|jj ddrt|jjdd}tj |} | r|dkrp| jd|d krp| jd} td } |jj| t| d |f|jjdj | | | d q|jjtd | qn|dkrdS|dkrt||krtd} |jj| t||f|| }n)|r |jjtdt|n|jjdj |dS(NR RtoptstRRis is, diffstat (truncated from %d to %d lines): iis diffstat: %ss) diffs (truncated from %d to %d lines): s diffs (%d lines): (R(R%Rtp1RdRt diffalloptsRR$R'Rt splitlinesR+RRARLRRR\( R7RbtrefRtprevtdiffoptstchunkst difflinesRRVR((s2/usr/lib64/python2.7/site-packages/hgext/notify.pyR$s8  % $(     #N( t__name__t __module__t__doc__R<RRGR.RdRgRR0R$(((s2/usr/lib64/python2.7/site-packages/hgext/notify.pyR s    Sc K@sTt|||}|j|}|jsC|jd|jdS|j|rg|jd|dS|jd}d} d} |dks|dkr_x|jjd|j D]} |j || r| d 7} | s;|| j } q;q||j 7}|j td | || jd f|jqW| r|j||d qn|j |kr|j |s|j |j td |j |jd fdS| d 7} |j|| s|j } qn||j 7}|jd d} | r4| r4djd| |g}n| rP|j|| |ndS(ssend 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 RiR Rtstartis1notify: suppressing notification for merge %d:%s i ttipR Rs sFrom: %s(R t unfilteredR/RoR*Rgt pushbuffert changelogRTRnRdRQt popbuffertnoteRthexR$RRR( R%R'R8RdRetkwargstnRbRRAtauthorRnR((s2/usr/lib64/python2.7/site-packages/hgext/notify.pythooksP  "     (%Rt __future__Rt email.errorsterrorsRtt email.parsertparserRpRMRRtmercurial.i18nRt mercurialRRRRRRRtmercurial.utilsR R t testedwitht configtablet configitemR0RaR~R3tmultiple_templateR1tobjectR R(((s2/usr/lib64/python2.7/site-packages/hgext/notify.pytsl   4