�
#�@s�dZddkZddkZddkZddklZlZlZlZddkl Z
ddklZhZ
eie
�Zdefd��YZd�Zd �Zd
�Zedged��d
��Zedged��d��Zd�Zedddded�fddded�fddded�fddded�ed�fd d!ded"�ed#�fgeied$��d%��Zd&�ZdS('s&commands to sign and verify changesetsi�N(tutiltcommandstmatchtcmdutil(tnode(t_tgpgcBs&eZdd�Zd�Zd�ZRS(cCs(||_|od|pd|_dS(Ns --local-user "%s"t(tpathtkey(tselfRR ((s8/sys/lib/python/lib/python2.5/site-packages/hgext/gpg.pyt__init__s cCs&d|i|if}ti||�S(Ns%s --sign --detach-sign%s(RR Rtfilter(R
tdatatgpgcmd((s8/sys/lib/python/lib/python2.5/site-packages/hgext/gpg.pytsignsc
Cs_d }}z�tidddd�\}}ti|d�}|i|�|i�tidddd�\}}ti|d�}|i|�|i�d|i||f}ti d|�}Wd x:||fD],} y| oti
| �nWq�q�Xq�WXg}
d\}}d}
x�i�D]�|id
�pq*n|d}|id�ot
d
�}
Pq*|id�o|i�d}q*|id�p0|id�p |id�p|id�oA|d j o|
i||g�n|idd�}d }q*q*W|
o|
gfSn|d j o|
i||g�n|
|
fS(s' returns of the good and bad signaturestprefixshg-gpg-tsuffixs.sigtwbs.txts1%s --logger-fd 1 --status-fd 1 --verify "%s" "%s"RNs[GNUPG:]i tERRSIGserror while verifying signaturetVALIDSIGi
tGOODSIGtEXPSIGt EXPKEYSIGtBADSIGt i(NN(tNonettempfiletmkstemptostfdopentwritetcloseRRRtunlinkt
splitlinest
startswithRtsplittappend(R
R
tsigtsigfiletdatafiletfdtfpRtrettftkeysR tfingerprintterrtl((s8/sys/lib/python/lib/python2.5/site-packages/hgext/gpg.pytverifys\
N(t__name__t
__module__RRRR1(((s8/sys/lib/python/lib/python2.5/site-packages/hgext/gpg.pyRs cKsQ|iddd�}|id�}|p|iddd�}nt||�S(screate a new gpg instanceRtcmdR N(tconfigtgetRR(tuitoptstgpgpathtgpgkey((s8/sys/lib/python/lib/python2.5/site-packages/hgext/gpg.pytnewgpgMs
ccs�d�}|id�}x[t|i��D]G}dti|�}x+||i|�i�|�D]}|VqcWq+Wy2d}x%||i|�|�D]}|Vq�WWntj
onXdS(sb
walk over every sigs, yields a couple
((node, version, sig), (filename, linenumber))
cssPd}xC|D];}|pq
n|idd�||ffV|d7}q
WdS(NiRi(R$(tfileitertcontexttlnR0((s8/sys/lib/python/lib/python2.5/site-packages/hgext/gpg.pyt parsefileZss.hgsigss
.hgsigs|%st localsigsN( tfiletreversedtheadsthgnodetshorttreadR"topenertIOError(trepoR?tfltrtfntitem((s8/sys/lib/python/lib/python2.5/site-packages/hgext/gpg.pytsigwalkUs
cCs~|\}}|\}}} d||f}
ti|�}t|||�}ti| �} |i|| �\}}
|o"|id|||f�d
Sng}x�|
D]�}|ddjo(|it d�|
|df�q�n|ddjo%|it d�|
|df�n7|dd jo%|it d
�|
|df�n|i
|d|d|df�q�W|S(sget the keys who signed a datas%s:%ds %s:%d %s
iRs%s Bad signature from "%s"
iRs1%s Note: Signature has expired (signed by: "%s")
Rs0%s Note: This key has expired (signed by: "%s")
iiN(RDtbintnode2txttbinasciit
a2b_base64R1twarnRRRR%(R7RItmygpgtsigdataR=RLR>RtversionR&RR
R/R-t validkeysR ((s8/sys/lib/python/lib/python2.5/site-packages/hgext/gpg.pytgetkeysps0!&tsigsshg sigsc
Csgt|�}h}x�t|�D]�\}}|\}}}|\} }
y|i|�}Wn3tj
o'|itd�| |
f�qnX|ii|�}t|||||�}
|
pqn|i |g�||i
|
�qWxtt|dt�D]`}xW||D]K}d|t
i|ii|��f}|idt||�|f�qWq�S(slist signed changesetss%s:%d node does not exist
treverses%5d:%ss %-30s %s
N(R;RNtlookuptKeyErrorRSRt changelogtrevRXt
setdefaulttextendtsortedtTrueRDthexRRtkeystr(R7RIRTtrevsR
R=RRVR&RLR>tnRKR-R^tk((s8/sys/lib/python/lib/python2.5/site-packages/hgext/gpg.pyRY�s.
%tsigcheckshg sigcheck REVISIONc
Cst|�}|i|�}ti|�}g}xjt|�D]\\}}|\}} }
||jo4t|||||�}|o|i|�q�q=q=W|p(|itd�ti |��dSn|idti |��x(|D] }|idt
||��q�dS(s@verify all the signatures there may be for a particular revisionsNo valid signature for %s
Ns%s is signed by:
s %s
(R;R[RDRcRNRXR`RRRERd(
R7RIR^RTthexrevR-R
R=RRVR&RgR ((s8/sys/lib/python/lib/python2.5/site-packages/hgext/gpg.pytcheck�s$
cCsE|\}}}|id|d�}|od||fSn|SdS(s/associate a string to a key (username, comment)Rs%s (%s)N(R5R(R7R tkeyidtuserR.tcomment((s8/sys/lib/python/lib/python2.5/site-packages/hgext/gpg.pyRd�s
RR0tlocalsmake the signature localR,tforces$sign even if the sigfile is modifiedRs no-commits'do not commit the sigfile after signingRgR sthe key id to sign withtIDtmtmessagescommit messagetTEXTs!hg sign [OPTION]... [REVISION]...cOsmt||�}d}d}|id�}|oti|�|d<n|o.g}|D]} ||i| �qZ~}
n�g}|ii�D]!}|tijo||q�q�~}
t |
�djoti
td���n|
p|ii
�g}
nx�|
D]�} ti| �}
|itd�|ii| �ti| �f�t|| |�}|i|�}|pti
td���nti|�}|idd�}|d |
||f7}qW|d
o|iid|�dSnti|idd
g�}|id|dtdt�d }ti|�o%|doti
td���n|id
d�}|i|�|i �d
|ijo|di"d
g�n|dodSn|d}|p;di#g}|
D]} |dti| �q��}ny%|i$||d|dd|�Wn*t%j
o}ti
t&|���nXdS(s�add a signature for the current or given revision
If no revision is given, the parent of the working directory is used,
or tip if no revision is checked out.
See :hg:`help dates` for a list of formats valid for -d/--date.
t0Rtdateis6uncommitted merge - please provide a specific revisionsSigning %d:%s
serror while signings
s %s %s %s
RnR@Ns.hgsigsRtunknowntignorediRosRworking copy of .hgsigs is changed (please commit .hgsigs manually or use --force)tabt no_commitRrs Added signature for changeset %sRl('R;R6Rt parsedateR[tdirstatetparentsRDtnullidtlentAbortRR]ttipRcRR^RERPRRQt
b2a_base64treplaceRGR%RtexacttroottstatusRbtanytwfileR Rtaddtjointcommitt
ValueErrortstr(R7RIReR8RTtsigvert
sigmessageRut_[1]Rftnodest_[2]RthexnodeR
R&tmsigststsigsfileRrt_[3]tinst((s8/sys/lib/python/lib/python2.5/site-packages/hgext/gpg.pyR�s`.$"
.%cCs;|djodti|�Sntitd���dS(smap a manifest into some textRts%s
sunknown signature versionN(RDRcRRR(RIRtver((s8/sys/lib/python/lib/python2.5/site-packages/hgext/gpg.pyRPs
(t__doc__RRRQt mercurialRRRRRRDtmercurial.i18nRtcmdtabletcommandtobjectRR;RNRXRYRjRdRtcommitopts2RRP(((s8/sys/lib/python/lib/python2.5/site-packages/hgext/gpg.pys<module>s0$"= !! K
|