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

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


��c@s�dZddlZddlZddlZddlZddlZddlZddlZddl	Zddl
ZddlZddlm
Z
mZmZmZmZmZddlmZddlmZddlmZiZe
je�ZdZddd	�Zd
�Zdd�Zdd
ded�fddded�fddded�fddged�fddged�fddded�fddded�fddded �fdd!ded"�fd#d$ded%�fd&d'ded(�fd)d*ded+�fdd,ged-�fd.d/ded0�fdd1ded2�fdd3ged4�fd5d6ged7�fgZed8d9d:ded;�fdd<ded=�fd>d?ded@�fdAdBdedC�fddDdBedE�edF�fdGdHgedI�edJ�fddKdedL�fddMgedN�edJ�fddOdedP�fg	eej edQ��dR��Z!dS(Ssucommand to send changesets as (a series of) patch emails

The series is started off with a "[PATCH 0 of N]" introduction, which
describes the series as a whole.

Each patch email has a Subject line of "[PATCH M of N] ...", using the
first line of the changeset description as the subject text. The
message contains two or three body parts:

- The changeset description.
- [Optional] The result of running diffstat on the patch.
- The patch itself, as generated by :hg:`export`.

Each message refers to the first in the series using the In-Reply-To
and References headers, so they will show up as a sequence in threaded
mail and news readers, and in mail archives.

To configure other defaults, add a section like this to your
configuration file::

  [email]
  from = My Name <my@email>
  to = recipient1, recipient2, ...
  cc = cc1, cc2, ...
  bcc = bcc1, bcc2, ...
  reply-to = address1, address2, ...

Use ``[patchbomb]`` as configuration section name if you need to
override global ``[email]`` address settings.

Then you can use the :hg:`email` command to mail a series of
changesets as a patchbomb.

You can also either configure the method option in the email section
to be a sendmail compatible mailer or fill out the [smtp] section so
that the patchbomb extension can automatically send patchbombs
directly from the commandline. See the [email] and [smtp] sections in
hgrc(5) for details.
i�N(tcmdutiltcommandsthgtmailtpatchtutil(tscmutil(t_(tbintinternalt:cCs+|r|d|7}n|j|||�S(Ns [%s](tprompt(tuiRtdefaulttrest((s3/sys/lib/python2.7/site-packages/hgext/patchbomb.pyR<scCs(|dkp'|jd�p'|jd�S(s-is an introductory message apparently wanted?itintrotdesc(tget(toptstnumber((s3/sys/lib/python2.7/site-packages/hgext/patchbomb.pytintrowantedAsc	Cs>g}	d}
d}xt|D]l}|jd�rV|jd�r|j�d}
qqn|jd�st|jd�rxPn|	j|�qW|r�|
r�t�n|jd�r�jd�r�	j|	d
�j�p�d}|d7}n|jd
�rkx*|r&|djd�r&|jd�q�r=|jd�nx+|rg|dj�rg|jd�q@Wnt	j
|d|jd��}
|jd�r�||
d7}n|jd�p�|jd�}|s�|jd�r�d	j|�7}n|rMtjj�}|r9|j
tj||||jd���ntjd	j|�d|jd��}t|
�}|s
g|j|�D]*}|jd�s�|jd�r�|^q�}|r�|d}q
|d
kr�j|d|d|d|�}q
tj|d|�}nd}|jd�r+d}n|d||d<|j
|�ntj|d|jd��}d j|jd!��}|r�d |}n|	dj�jd"�}|s�d#||jd$�p�|f}n+tt|��}d%|||||f}tj||||jd��|d&<|
|d'<|||
fS((Ntt#s	# Node IDi�sdiff -rs
diff --gittattachtbodys
is"Patch subject is complete summary.s


tplainis# tgittdiffstats

tinlinettestsx-patchs.patchs.diffs%b-%n.patchtseqnottotals%b.patcht
attachments; filename=sContent-Dispositiontdisplayt tflags. s[PATCH%s] %stsubjects[PATCH %0*d of %d%s] %stSubjectsX-Mercurial-Node(tNonet
startswithtsplittappendt
ValueErrorRtjointstriptpopRRtemailt
MIMEMultipartRRt
mimeencodet
mimetextpatchRtnodetagstendswithRtmakefilenametrstriptlentstrt
headencode(Rtrepot
patchlinesRt	_charsetstidxRtnumberedt	patchnameRtnodeRtlinetdst
addattachmenttmsgtptbinnodettt	patchtagstdispositionR#tsubjttlen((s3/sys/lib/python2.7/site-packages/hgext/patchbomb.pyt	makepatchEs�
	
+*
	
"%
RRs-send patches as inline message text (default)taRssend patches as attachmentstiRs"send patches as inline attachmentstbccs/email addresses of blind carbon copy recipientstctccs"email addresses of copy recipientstconfirms#ask for confirmation before sendingtdRsadd diffstat output to messagestdates&use the given date as the sending dateRs,use the given file as the series descriptiontftfromsemail address of sendertnRs!print messages that would be senttmtmboxs3write messages to mbox file instead of sending themsreply-tos)email addresses replies should be sent totsR$s0subject of first message (intro or single patch)sin-reply-tosmessage identifier to reply toR#s flags to add in subject prefixesRFttosemail addresses of recipientsR.tgRsuse git extended diff formatRsomit hg patch headertotoutgoings/send changes not found in the target repositorytbtbundles-send changes not in target as a binary bundlet
bundlenames"name of the bundle attachment filetNAMEtrtrevsa revision to sendtREVtforces?run even when remote repository is unrelated (with -b/--bundle)tbasesGa base changeset to specify instead of a destination (with -b/--bundle)Rs-send an introduction email for a single patchshg email [OPTION]... [DEST]...c#s�tj����jd�}�jd�}�jd�}�jd�}�jd�}�jd�}	��fd�}
���fd�}���fd	�}�jd
�p�|s�tj��n|p�p�p�p�	stjtd���n|r$|r$tjtd���n|s0|ryt|�d
krZtjtd���n|rj|dpmdE}
g}n|r�|r�tjtd���n|}n|r�|
|
|�}n|r�|�d<n|r�j	|��ntj
���fd�}���fd��dE�����fd�}�����fd�������fd�}�jd�p��jdd�p��jdd�p�t�d�j
���|	r�||	�jd��}n3|r�||
��}n|t||���}g�tdE����fd�}|ddt�}|s`tjtd���n|d dtd!d"�p{g}|d#�p�g}|d$�}�jd%�s��jd&�r��jtd'���jd(��x�D]}�jd)|�q�x>|D]6\}}}�jd*|�|r�j|�qqW�jd+��jtd,�td-�td.�f�r�tjtd/���q�n�jd+��jd0�p�dE}|dEk	r�jd1�s�d1|}n|jd2�s�d27}q�tjj��d
}tj����jd
���dE}x_t|�D]Q\}\}}}y||d3�|d4<Wn!tk
r�|d�|d4<nX|r�||d5<||d6<n|s�d3|kr�|d4}nd7tj�|d8<tjj�dd9t�|d:<�dd
�d
f��|d<d;j|�|d<|rYd;j|�|d <n|rud;j|�|d#<n|r�d;j|�|d$<n�jd
�r��jtd<�|d=��j�d>t j!kr�j"�r�j#t j!d>d?�}n�}tj$j$|d@t�} y!| j%|d�|jd+�Wn+t&k
rg}!|!j't'j(krh�qhnX|�k	r�|j)�q�qF|s�jdAdB�}"�jdC�r��j*dAdBdD�nztj+�d|�}WdE�j*dAdB|"�Xn�jtdF�|d=��j,tdG�|dH|dIt|��|sE|d#=nt-j.�}tj$j$|d@t�} | j%|d�||||||j/��qFW�j,tdJ�dE��j,tdG�dE�dES(Ksasend changesets by email

    By default, diffs are sent in the format generated by
    :hg:`export`, one per message. The series starts with a "[PATCH 0
    of N]" introduction, which describes the series as a whole.

    Each patch email has a Subject line of "[PATCH M of N] ...", using
    the first line of the changeset description as the subject text.
    The message contains two or three parts. First, the changeset
    description.

    With the -d/--diffstat option, if the diffstat program is
    installed, the result of running diffstat on the patch is inserted.

    Finally, the patch itself, as generated by :hg:`export`.

    With the -d/--diffstat or --confirm options, you will be presented
    with a final summary of all messages and asked for confirmation before
    the messages are sent.

    By default the patch is included as text in the email body for
    easy reviewing. Using the -a/--attach option will instead create
    an attachment for the patch. With -i/--inline an inline attachment
    will be created. You can include a patch both as text in the email
    body and as a regular or an inline attachment by combining the
    -a/--attach or -i/--inline with the --body option.

    With -o/--outgoing, emails will be generated for patches not found
    in the destination repository (or only those which are ancestors
    of the specified revisions if any are provided)

    With -b/--bundle, changesets are selected as for --outgoing, but a
    single email containing a binary Mercurial bundle as an attachment
    will be sent.

    With -m/--mbox, instead of previewing each patchbomb message in a
    pager or sending the messages directly, it will create a UNIX
    mailbox file with the patch emails. This mailbox file can be
    previewed with any mail user agent which supports UNIX mbox
    files.

    With -n/--test, all steps will run, but mail will not be sent.
    You will be prompted for an email recipient address, a subject and
    an introductory message describing the patches of your patchbomb.
    Then when all is done, patchbomb messages are displayed. If the
    PAGER environment variable is set, your pager will be fired up once
    for each patchbomb message, so you can verify everything is alright.

    In case email sending fails, you will find a backup of your series
    introductory message in ``.hg/last-email.txt``.

    Examples::

      hg email -r 3000          # send patch 3000 only
      hg email -r 3000 -r 3001  # send patches 3000 and 3001
      hg email -r 3000:3005     # send patches 3000 through 3005
      hg email 3000             # send patch 3000 (deprecated)

      hg email -o               # send all patches not in default
      hg email -o DEST          # send all patches not in DEST
      hg email -o -r 3000       # send all ancestors of 3000 not in default
      hg email -o -r 3000 DEST  # send all ancestors of 3000 not in DEST

      hg email -b               # send bundle of all patches not in default
      hg email -b DEST          # send bundle of all patches not in DEST
      hg email -b -r 3000       # bundle of all ancestors of 3000 not in default
      hg email -b -r 3000 DEST  # bundle of all ancestors of 3000 not in DEST

      hg email -o -m mbox &&    # generate an mbox file...
        mutt -R -f mbox         # ... and view it with mutt
      hg email -o -m mbox &&    # generate an mbox file ...
        formail -s sendmail \   # ... and use formail to send from the mbox
          -bm -t < mbox         # ... using sendmail

    Before using this command, you will need to enable email in your
    hgrc. See the [email] section in hgrc(5) for details.
    R_RSRXR]Rctpatchescs��j|pd|pd�}tj|�d}�jtd�tj|��gtj�|�D]}|dkrd|^qd}|s�t	��dg}n�j
d|p�d|�}|s��jtd��gSg|D]}t|�^q�S(	s4Return the revisions present locally but not in destsdefault-pushR
iscomparing with %s
isoutgoing(%s) and ::%ldRsno changes found
(t
expandpathRtparseurltstatusRRthidepasswordRtrevrangeR6trevsR7(tdestRmturlRb(R9R(s3/sys/lib/python2.7/site-packages/hgext/patchbomb.pytgetoutgoings 1c
3slxetj�|�D]Q}tj�}tj�|gd|dtj����|j�j	d�VqWdS(NtfpRs
(
RRlt	cStringIOtStringIORtexportRtdiffoptstgetvalueR((RmRbtoutput(RR9R(s3/sys/lib/python2.7/site-packages/hgext/patchbomb.pyt
getpatches!s
cs�tjdd�}tjj|d�}zFtj��||��t|d�}|j�}|j	�|SWdytj
|�Wntk
r�nXtj|�XdS(Ntprefixshg-email-bundle-R_trb(
ttempfiletmkdtemptostpathR+RR_topentreadtclosetunlinktOSErrortrmdir(RnttmpdirttmpfnRqtdata(RR9R(s3/sys/lib/python2.7/site-packages/hgext/patchbomb.pyt	getbundle(s

Rs,specify at least one changeset with -r or -osE--outgoing mode always on with --bundle; do not re-specify --outgoingistoo many destinationsis)use only one form to specify the revisionRmcs%d|d t�d�tj�fS(Ns
<%s.%s@%s>ii(tinttsockettgetfqdn(tid(t
start_time(s3/sys/lib/python2.7/site-packages/hgext/patchbomb.pytgenmsgidYscs�jd�r-t�jd��j�}nN�jtd���j||�}�jdd�}|j|�|j�|S(NRs7
Write the introductory message for the patch series.

slast-email.txttwb(RRR�twriteRtedittopenerR�(Rtsendertmsgfile(RR9R(s3/sys/lib/python2.7/site-packages/hgext/patchbomb.pytgetdescription\s

cs�g}�jtd�t|��t�t|��r]�|�}|r]|j|�q]nt|�t|�dk}d}xht|�D]Z\}}|r�||}nt��|��|dt|�||�}|j|�q�W|S(Ns+this patch series consists of %d patches.

i(R�RR6RR)R&t	enumerateRK(Rgt
patchnamestmsgsRCR=tnameRMRD(R;t	makeintroRR9R(s3/sys/lib/python2.7/site-packages/hgext/patchbomb.pytgetpatchmsgsis 
c	sIttt|���}�jd�p*d}|rIddj|�}nd|dt|�|f}�jd�p�t�dd|d	d�}|s�dS|d|}d}�jd
�r�jt|g��}d|}nd}�|��}t	j
�|��jd��}t	j�|��jd��|d
<|||fS(NR#RR"s[PATCH %0*d of %d%s]iR$s(optional) Subject: RR
Rs
RR%(R6R7RR+RR&RRtsumRR0R8(RgRJR#RyRIRRRC(R;R�RR�R(s3/sys/lib/python2.7/site-packages/hgext/patchbomb.pyR��s(
!cs�jd�pt�dd�}�d��}tjj�}|rp|jtj�|��jd���ntjjdd�}|j|�d�jd	d
�}|j	ddd
|�tj
j|�|j|�tj�|��jd��|d<||dfgS(NR$sSubject:sA bundle for your repositoryRRtapplicationsx-mercurial-bundles%s.hgR`R_sContent-DispositionR tfilenameR%(RRR.R/RRR0tMIMEBasetset_payloadt
add_headertEncoderst
encode_base64R8R&(R_RIRRCtdatapartR`(R;R�RR�R(s3/sys/lib/python2.7/site-packages/hgext/patchbomb.pyt
getbundlemsgs�s+

%RUR.t	patchbombtFromR�c	s|j�}|jdd�j�}�j|�}|rx�jd|dj|�f�tj�|��jd��S�jd|�p��jd|�p�d}|r�|r�t�|d	|�}n|r�jd||f�tj�|g��jd��S|SdS(
Nt-Rs%s: %ss, RR.R�RR
(	tlowertreplaceRR)R+RtaddrlistencodetconfigR(theadertaskR
t	configkeytopttaddrstaddr(R;Rt	showaddrsR(s3/sys/lib/python2.7/site-packages/hgext/patchbomb.pytgetaddrs�s 
"tToR�sno recipient addresses providedtCcR
RtBccsReply-ToRRQs
Final summary:

s	From: %s
s%s
sSubject: %s
s
s#are you sure you want to send (yn)?s&Yess&Nospatchbomb canceledtin_reply_tot<t>sX-Mercurial-Nodes
Message-IdsIn-Reply-Tot
ReferencessMercurial-patchbomb/%ss
User-Agentt	localtimetDates, sdisplaying s ...
tPAGERtwtmangle_from_tsmtpt
verifycerttinsecuretlooseNssending tsendingtitemRtwriting(0RR;RtvalidateconfigRtAbortRR6R&t	parsedatetmakedateR�RtusernametlisttFalsetTrueR�tpromptchoiceR'R3R.tUtilst	parseaddrt
addressencodeR�t	TypeErrortversiont
formatdateR+RjtflushR}tenvironRtpopent	GeneratortflattentIOErrorterrnotEPIPER�t	setconfigtconnecttprogressRrRsRv(#RR9RmRR_RSRXR]RcRgRpRxR�RnR�R�R�R�R�RZRPRNtreplytoR�RWRIRAtparenttsender_addrtsendmailRMRqt	generatortinstR�((	R;R�R�RR9R�R�R�Rs3/sys/lib/python2.7/site-packages/hgext/patchbomb.pyR��s_		

!



!"



 


(
"("t__doc__R}R�R�R{Rrtemail.MIMEMultipartR.temail.MIMEBasetemail.Utilstemail.Encoderstemail.Generatort	mercurialRRRRRRRtmercurial.i18nRtmercurial.nodeRtcmdtabletcommandt
testedwithR&RRRKt	emailoptst
remoteoptsR�(((s3/sys/lib/python2.7/site-packages/hgext/patchbomb.pyt<module>.sB<$.	Q

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to [email protected].