o ]Lb@sdZddlmZddlmZddlmZddl m Z ddl m Z m Z mZmZmZmZmZddlmZddlmZiZeeZed d dd ed d dd ed d dd ddZdddZdS)awchangeset_published is a hook to send a mail when an existing draft changeset is moved to the public phase. Correct message threading requires the same messageidseed to be used for both the original notification and the new mail. Usage: [notify] messageidseed = myseed [hooks] txnclose-phase.changeset_published = python:hgext.hooklib.changeset_published.hook )absolute_importN)_)encodingerror formatter logcmdutilmailpycompat registrar)dateutil)notifynotify_publisheddomain)default messageidseedtemplatesASubject: changeset published This changeset has been published. c Cs\|ddp |dd}|ddp|dd}|dd}t|}t|||}|t||d}t} |j D]!\} }|durI| | q;| d|| } t | r\| | q;q;t | dkrj|d dS|j|||d d |j|jd |} zt| } Wntjy}zt|d}~wwt|||| d <t|||d| d<ttjdd| d<| ds|ddp|}d|vsd|vr||}t |||j!|j"| d<d#t$| | d<t%j&r| 'n| (}|)ddr|*||+ds |*ddSdS|,t-d| tj.|t/0| dd| ||j1ddS)Nrrsnotifyrrsincomings %r and %d:rs=notify_published: no subscribers to selected repo and revset swebsbaseurl)changesbaseurlrootwebrootz In-reply-tos -publishedz Message-Ids%a, %d %b %Y %H:%M:%S %1%2)formatDateFromsemailsfrom@s @localhostz, Tostest s&notify_published: sending mail for %d )mbox)2configrliteral_templatespecrchangesettemplater pushbufferr notifiersetsubsaddrevsrevlendebugshow changesetr popbufferr parsebytes emailerrorsMessageParseErrorrAbort messageidr strfromlocalr datestrusernamefixmail addressencodecharsetstestjoinsortedr ispy3as_bytes as_string configboolwriteendswithstatusrsendmail emailutils parseaddrr)uirepoctxdomain messageidseedtemplatespec templaternr%subr'datamsginstsendermsgtextrUC/usr/lib/python3/dist-packages/hgext/hooklib/changeset_published.py_report_commit=s              rWcKs\|dkrttdt|||}|ddkr*|ddkr,t|||dSdSdS)Nstxnclose-phasesUnsupported hook type %roldphasesdraftphasespublic)rr1rr bytestr unfilteredrW)rFrGhooktypenodekwargsrHrUrUrVhooks r_)N)__doc__ __future__r email.errorserrorsr/ email.utilsutilsrDmercurial.i18nr mercurialrrrrrr r mercurial.utilsr r configtable configitemrWr_rUrUrUrVs6    $   D