Plan 9 from Bell Labs’s /usr/web/sources/contrib/jas/root/sys/lib/python2.7/site-packages/hgext/hgcia.pyc

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


�t�c@sdZddlmZddlmZmZddlmZmZm	Z	m
Z
mZddlZ
ddlZddlZddlmZdZdZe
jed	�r�eje�nd
ZdZdefd
��YZdefd��YZddd�ZdS(s:hooks for integrating with the CIA.vc notification service

This is meant to be run as a changegroup or incoming hook. To
configure it, set the following options in your hgrc::

  [cia]
  # your registered CIA user name
  user = foo
  # the name of the project in CIA
  project = foo
  # the module (subproject) (optional)
  #module = foo
  # Append a diffstat to the log message (optional)
  #diffstat = False
  # Template to use for log messages (optional)
  #template = {desc}\n{baseurl}{webroot}/rev/{node}-- {diffstat}
  # Style to use (optional)
  #style = foo
  # The URL of the CIA notification service (optional)
  # You can use mailto: URLs to send by email, e.g.
  # mailto:cia@cia.vc
  # Make sure to set email.from if you do this.
  #url = http://cia.vc/
  # print message instead of sending it (optional)
  #test = False
  # number of slashes to strip for url paths
  #strip = 0

  [hooks]
  # one of these:
  changegroup.cia = python:hgcia.hook
  #incoming.cia = python:hgcia.hook

  [web]
  # If you want hyperlinks (optional)
  baseurl = http://server/path/to/repo
i�(t_(tbintshort(tcmdutiltpatcht	templatertutiltmailN(tsaxutilstinternalitsetdefaulttimeouts0.1s$http://hg.kublai.com/mercurial/hgciatciamsgcBsSeZdZd�Zd�Zd�Zddd�Zd�Zd�Z	d�Z
RS(	s A CIA message cCsF||_||_|jj|_|jrB|j|jj7_ndS(N(tciatctxturltroot(tselfRR
((s//sys/lib/python2.7/site-packages/hgext/hgcia.pyt__init__As
			cCs?|rdtj|�}nd|tj|�tj|�fS(Ns uri=%ss<file%s action=%s>%s</file>(Rt	quoteattrtescape(Rtpathturitaction((s//sys/lib/python2.7/site-packages/hgext/hgcia.pytfileelemHsc	CsL|jj�}|jjj|jj�j�|�}|jpBd}|rh|ddkrh|d }ng}xM|dD]A}d|t|�|f}|j|j	||o�|d��qyWxM|dD]A}d|t|�|f}|j|j	||o|d	��q�Wx.|d
D]"}|j|j	|dd��qWdj
|�S(
Nti�t/is
%s/diff/%s/%stmodifyis
%s/file/%s/%stadditremoves
(R
tnodeRtrepotstatustp1RRtappendRtjoin(RtntfRtelemsRR((s//sys/lib/python2.7/site-packages/hgext/hgcia.pyt	fileelemsNs'
&& cCsyddtj|�g}|r<|jdtj|��n|r_|jdtj|��n|jd�dj|�S(Ns<source>s<project>%s</project>s<module>%s</module>s<branch>%s</branch>s	</source>s
(RRR!R"(Rtprojecttmoduletbranchtmsg((s//sys/lib/python2.7/site-packages/hgext/hgcia.pyt
sourceelemas
cCscdtfd��Y}|jj�}|�}tj|jj|gd|�tj|j	�pbdS(NtpatchbufcBs#eZd�Zd�Zd�ZRS(cSsg|_d|_dS(NR(tlinestname(R((s//sys/lib/python2.7/site-packages/hgext/hgcia.pyRms	cSs|j|jt�7_dS(N(R-t
splitlinestTrue(Rtdata((s//sys/lib/python2.7/site-packages/hgext/hgcia.pytwriteqscSsdS(N((R((s//sys/lib/python2.7/site-packages/hgext/hgcia.pytclosess(t__name__t
__module__RR2R3(((s//sys/lib/python2.7/site-packages/hgext/hgcia.pyR,ls		tfpR(
tobjectR
RRtexportRRRtdiffstatR-(RR,R#tpbuf((s//sys/lib/python2.7/site-packages/hgext/hgcia.pyR9ks

	cCs�|jjr|j�pd}|jjj�|jjj|jd|jj�d|jjjdd�d|j	d|d|jj
�|jjj�S(NRtchangestbaseurltwebRR9twebroot(RR9tuit
pushbufferRtshowR
t	changesettconfigRRt	popbuffer(RR9((s//sys/lib/python2.7/site-packages/hgext/hgcia.pytlogmsg{s$
c
Cs?t|jj��}|j|jjd|jjd|jj��}|jj�}|d}t	j
|jj��}d|jj�|f}t	j
|j
��}|j}|r�|ddkr�|d }n|r�t	j
|�|fp�}d	tt	j
t�t	j
|jj�||||||j�|f
}	|	S(
NR(R)is%d:%si�Rs<url>%s/rev/%s</url>RsP
<message>
  <generator>
    <name>Mercurial (hgcia)</name>
    <version>%s</version>
    <url>%s</url>
    <user>%s</user>
  </generator>
  %s
  <body>
    <commit>
      <author>%s</author>
      <version>%s</version>
      <log>%s</log>
      %s
      <files>%s</files>
    </commit>
  </body>
  <timestamp>%d</timestamp>
</message>
(RR
RR+RR'R(R)tdateRRtusertrevRERt
HGCIA_VERSIONt	HGCIA_URLR&(
RR#tsrctdtt	timestamptauthorRHtlogRR*((s//sys/lib/python2.7/site-packages/hgext/hgcia.pytxml�s"
	
%!N(R4R5t__doc__RRR&tNoneR+R9RERP(((s//sys/lib/python2.7/site-packages/hgext/hgcia.pyR?s			
			thgciacBs>eZdZdZdZd�Zd�Zd�Zd�ZRS(s CIA notification class s{desc}s{desc}
-- 
{diffstat}c	Cs�||_||_|jjddd�|_|jjdd�|_|jjdd�|_|jjdd�|_|jjdd�|_|jjdd	�|_	|jjdd
�|_
|jjdd�|_t|jjdd
d��|_
|j|jj�|_|jjdd�}|jjdd�}|s\|jrP|jpV|j}ntj|dt�}tj|j|jtd|t�}|j|�||_dS(NRRs
http://cia.vcRGR'R(R9temailtfromttestR=R<tstripi�tstylettemplatetquoted(R?RRCtciaurlRGR'R(t
configboolR9t	emailfromtdryrunRtintt
stripcountRWRt
dstemplatetdeftemplateRtparsestringtFalseRtchangeset_templaterRRtuse_template(RR?RRXRYtt((s//sys/lib/python2.7/site-packages/hgext/hgcia.pyR�s*		!
cCsvtj|�}|j}|dkr(dSxG|dkrq|jd�}|dkrVPn||d}|d8}q+W|S(s?strip leading slashes from local path, turn into web-safe path.iRRi�i(RtpconvertR`tfind(RRtcounttc((s//sys/lib/python2.7/site-packages/hgext/hgcia.pyRW�s	cCsetj|j�}|jj|�}|tk	ra|dkratjtd�|j|f��ndS(Nsqueued.s%s returned an error: %s(	t	xmlrpclibtServerR[thubtdeliverR0RtAbortR(RR*tsrvtres((s//sys/lib/python2.7/site-packages/hgext/hgcia.pytsendrpc�s
cCs�tjj�}|j|�}tjdd�|d<||d<|j|d<d|d<d|d	<|j�}|jjt	d
�|�t
j|jtj|j�|g|�dS(Ntformats%a, %d %b %Y %H:%M:%S %1%2tDatetTotFromt
DeliverXMLtSubjectstext/xmlsContent-typeshgcia: sending update to %s
(RTtParsertparsestrRtdatestrR]t	as_stringR?RRRtsendmail(RtaddressR1tpR*tmsgtext((s//sys/lib/python2.7/site-packages/hgext/hgcia.pyt	sendemail�s



(	R4R5RQRbRaRRWRsR�(((s//sys/lib/python2.7/site-packages/hgext/hgcia.pyRS�s			c
s��fd�}t|�}t�|�}|jsD�jd�dS|js^�jd�dS|dkr�|jj|�}	t|j�}
xdt|	|
�D]4}|jj	|�}|j
|�}|||�q�Wn|j
|�}|||�dS(s send CIA notification cs�t||�j�}|jr.�j|�nZ|jjd�r{|jsatjt	d���n|j
|jd|�n
|j|�dS(Nsmailto:s0email.from must be defined when sending by emaili(RRPR^R2R[t
startswithR]RRpRR�Rs(RR
R*(R?(s//sys/lib/python2.7/site-packages/hgext/hgcia.pytsendmsg�s		scia: no user specifiedNscia: no project specifiedtchangegroup(RRSRGtdebugR't	changelogRHtlentxrangeRt	changectx(
R?RthooktypeRRtkwargsR�R#RtstarttendRHR
((R?s//sys/lib/python2.7/site-packages/hgext/hgcia.pythook�s$	
	
(RQtmercurial.i18nRtmercurial.nodeRRt	mercurialRRRRRtemail.ParserRTtsocketRltxml.saxRt
testedwithtsocket_timeouttsafehasattrR
RIRJR7RRSRRR�(((s//sys/lib/python2.7/site-packages/hgext/hgcia.pyt<module>*s(rE

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.