ó œt•Pc@sdZddlmZddlmZmZddlmZmZm Z m Z m Z ddl Z ddlZddlZddlmZdZdZe jed ƒr¶ejeƒnd Zd Zd 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%s(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(Nss%ss%ss%ss 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ïdt j |ƒ|fpòd}d tt j tƒt j |jj ƒ||||||jƒ|f } | S( NR(R)is%d:%siÿÿÿÿRs%s/rev/%sRsP Mercurial (hgcia) %s %s %s %s %s %s %s %s %s %d (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 ƒ|_ |jjd d ƒ|_ 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 dstemplatet deftemplateRt parsestringtFalseRtchangeset_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*s( rE