a
    &0É_Ž{  ã                   @   s  d Z ddlmZ ddlmZ ddlm  mZ	 ddl
m  mZ ddlmZ ddlZddlZddlZddlmZ ddlmZ ddlmZmZmZmZmZmZmZmZ m!Z!m"Z"m#Z#m$Z$m%Z%m&Z& ddl'm(Z( e&j)Z)i Z*e# +e*¡Z+i Z,e# -e,¡Z-e-dd	dd
 e-dddd
 e-dddd
 e-dddd
 e-dddd
 e-dddd
 e-dddd
 e-dddd
 e-dddd
 e-dddd
 dZ.dd„ Z/dd„ Z0dd„ Z1d„dd„Z2d d!„ Z3d"d#„ Z4d$d%„ Z5d…d&d'„Z6d(d)„ Z7d*d+„ Z8d,d-„ Z9d.d/„ Z:d0d1„ Z;d†d2d3„Z<d4d5„ Z=d6d7„ Z>d8d9ded:ƒfd;d<ded=ƒfd>d?ded@ƒfd8dg edAƒedBƒfdCdg edDƒedBƒfd8ddedEƒfdFdGdedHƒfd8dId8edJƒedKƒfd8dLd8edMƒedNƒfdOdd8edPƒedBƒfdQdRdedSƒfdTdUd8edVƒedNƒfd8dg edWƒedBƒfdXdYd8edZƒed[ƒfd8d\d8ed]ƒed^ƒfd8d_g ed`ƒedaƒfdbdg edcƒedBƒfgZ?e+dddedfdedgƒfd8dhdediƒfdjdkdedlƒfdmdndedoƒfdpdqd8edrƒedsƒfd8dtdneduƒedvƒfdwdxg edyƒedzƒfd8d{ded|ƒfd8d}g ed~ƒedzƒfd8ddedƒfg
e? ej@ ed€ƒe+jAdd‚dƒ„ ƒZBdS )‡as	  command 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.

By default, :hg:`email` will prompt for a ``To`` or ``CC`` header if
you do not supply one via configuration or the command line.  You can
override this to never prompt by configuring an empty value::

  [email]
  cc =

You can control the default inclusion of an introduction message with the
``patchbomb.intro`` configuration option. The configuration is always
overwritten by command line flags like --intro and --desc::

  [patchbomb]
  intro=auto   # include introduction message if more than 1 patch (default)
  intro=never  # never include an introduction message
  intro=always # always include an introduction message

You can specify a template for flags to be added in subject prefixes. Flags
specified by --flag option are exported as ``{flags}`` keyword::

  [patchbomb]
  flagtemplate = "{separate(' ',
                            ifeq(branch, 'default', '', branch|upper),
                            flags)}"

You can set patchbomb to always ask for confirmation by setting
``patchbomb.confirm`` to true.
é    )Úabsolute_importN)Ú_)Úopen)ÚcmdutilÚcommandsÚencodingÚerrorÚ	formatterÚhgÚmailÚnodeÚpatchÚpycompatÚ	registrarÚscmutilÚ	templaterÚutil)Údateutiló	   patchbombó
   bundletype©Údefaults   bccs   ccó   confirmFó   flagtemplateó   fromó   introó   autoó	   publicurls   reply-tos   tos   ships-with-hg-corec                 C   s,   |  ¡ }|j dd¡}|r(d|||f S dS )zKAdd a header pointing to a public URL where the changeset is available
    r   r   s/   Available At %s
#              hg pull %s -r %sN)ÚrepoÚuiÚconfig)ÚseqÚctxr   Ú	publicurl© r$   ú1/usr/lib/python3/dist-packages/hgext/patchbomb.pyÚ_addpullheader–   s    ýr&   c                 C   s   t j d¡ tt jd< d S )Ns   pullurl)r   ZextraexportÚappendr&   Zextraexportmap)r   r$   r$   r%   Úuisetup§   s    r(   c                 C   s   |  ¡ sd S |j d¡ d S )Nó   last-email.txt)ZlocalZ_wlockfreeprefixÚadd)r   r   r$   r$   r%   Ú	reposetup¬   s    r+   ó   :c                 C   s    |r|d| 7 }|   || |¡S )Ns    [%s])Úprompt)r   r-   r   Úrestr$   r$   r%   r-   ²   s    r-   c                 C   s€   |   dd¡}| d¡s | d¡r&d}nV|dkr4d}nH|dkrBd}n:|dkrT|d	k}n(|  td
ƒ| ¡ |  tdƒ¡ |d	k}|S )z-is an introductory message apparently wanted?r   r   ó   descTs   alwayss   neverFr   é   s,   warning: invalid patchbomb.intro value "%s"
s'   (should be one of always, never, auto)
)r    ÚgetÚ	write_errr   )r   ÚoptsZnumberZintroconfigZintror$   r$   r%   Úintrowanted¸   s    

ÿr4   c              	   C   sœ   |   dd¡}|sd |¡S t ¡ }t t |¡¡}t | |di |¡@}| 	¡  |j
|| d | dd|j|dd	¡ W d
  ƒ n1 sŠ0    Y  | ¡ S )z(build flag string optionally by templater   r   ó    s   patchbombflag)r"   s   flagss   %só   flag)ÚnameN)r    Újoinr   Ústringior	   Zliteral_templatespecr   ZunquotestringZtemplateformatterZ	startitemÚcontextÚwriteZ
formatlistÚgetvalue)r   r   ÚrevÚflagsZtmplÚoutÚspecZfmr$   r$   r%   Ú_formatflagsÌ   s    
6rA   c           	      C   sF   t | |||ƒ}|rd| }|s&d| S td| ƒ}d||||f S dS )zbuild prefix to patch subjectr5   s	   [PATCH%s]ó   %ds   [PATCH %0*d of %d%s]N)rA   Úlen)	r   r   r=   r>   ÚidxÚtotalÚnumberedÚflagZtlenr$   r$   r%   Ú_formatprefixÚ   s    rH   c
              
   C   sæ  g }
d }d}|D ]H}|  d¡r6|  d¡r| ¡ d }q|  d¡sJ|  d¡rN qZ|
 |¡ q|	sf|sft‚| d¡rœ| d¡sœd	 |
d
d … ¡ ¡ p’d}|d7 }| d¡rî|rÄ|d   d¡rÄ| d¡ q¦|rÒ| d¡ |rî|d  ¡ sî| d¡ qÒt 	|¡}| d¡r||d 7 }| d¡p$| d¡}|r8| d¡rF|d	 |¡7 }|r,t
 ¡ }|rv| t | ||| d¡¡¡ t d	 |¡d| d¡¡}t |¡}|	södd„ | |¡D ƒ}|rÄ|d }	n2|d
krætj|| d||d}	nt || d¡}	d}| d¡r
d}|d t |	¡ |d< | |¡ ntj|| d¡d}t| ||| d¡|||ƒ}|
d  ¡  d ¡}|sŽd! || d"¡p†|g¡}nd! ||g¡}t | ||| d¡¡|d#< t |¡|d$< d%| |d&< d%| |d'< |||fS )(Nó    ó   #s	   # Node IDéÿÿÿÿs   diff -rs
   diff --gitó   attachó   bodyó   
r0   s"   Patch subject is complete summary.s   


ó   plainr   s   # ó   diffstats   

ó   inlineó   testzx-patchc                 S   s$   g | ]}|  d ¡s|  d¡r|‘qS )s   .patchs   .diff)Úendswith)Ú.0Útr$   r$   r%   Ú
<listcomp>%  s   þzmakepatch.<locals>.<listcomp>s   %b-%n.patch)ZseqnorE   s   %b.patchZinlineÚ
attachmentz; filename=úContent-Disposition)Zdisplayr6   s   . r5   ó   subjectÚSubjectúX-Mercurial-Nodez%izX-Mercurial-Series-IndexzX-Mercurial-Series-Total)Ú
startswithÚsplitr'   Ú
ValueErrorr1   r8   ÚstripÚpopr   ÚdiffstatÚemimemultipartÚMIMEMultipartÚattachr   Ú
mimeencodeZmimetextpatchÚnodemodÚbinZnodetagsr   Zmakefilenamer   ÚstrfromlocalrH   ÚrstripÚ
headencoder   Zsysstr)r   r   r=   Z
patchlinesr3   Ú	_charsetsrD   rE   rF   Z	patchnameÚdescr   ÚbodyÚlineÚdsZaddattachmentÚmsgÚpZbinnodeZ	patchtagsZdispositionÚprefixÚsubjr$   r$   r%   Ú	makepatchç   sŠ    

þ


ÿ
þ

ÿÿÿrt   c              
   k   s„   | j }| d  ¡ }|D ]h}||krH| d  ¡ s:| d  ¡ rH| tdƒ¡ tƒ }tj| |g|t	j
||ddd | ¡  d¡V  qdS )zlreturn a list of patches for a list of revisions

    Each patch in the list is itself a list of lines.
    ó   .Ns3   warning: working directory has uncommitted changes
T)Zgit)r3   rN   )r   r=   ÚfilesZdeletedÚwarnr   r9   r   Z
exportfiler   Zdifffeatureoptsr<   r]   )r   Úrevsr3   r   ÚprevÚrÚoutputr$   r$   r%   Ú_getpatchesK  s     ÿr|   c                 K   sê   | j }tjdd}tj |d¡}| dd¡}|r8||d< z~tj|| ||fi |¤Ž t	 
|¡W zt |¡ W n ty|   Y n0 t |¡ S zt |¡ W n tyª   Y n0 t |¡ n.zt |¡ W n tyØ   Y n0 t |¡ 0 dS )zÝreturn a bundle containing changesets missing in "dest"

    The `opts` keyword-arguments are the same as the one accepted by the
    `bundle` command.

    The bundle is a returned as a single in-memory binary blob.
    s   hg-email-bundle-)rr   ó   bundler   r   ÚtypeN)r   r   ZmkdtempÚosÚpathr8   r    r   Úbundler   ZreadfileÚunlinkÚOSErrorÚrmdir)r   Údestr3   r   ZtmpdirZtmpfnZbtyper$   r$   r%   Ú
_getbundle\  s2    

úür†   c                 K   sh   | j }| d¡r$t| d¡ƒ ¡ }n@| tdƒ¡ |j||| jdd}|  dd¡}| |¡ | 	¡  |S )zõobtain the body of the introduction message and return it

    This is also used for the body of email with an attached bundle.

    The body can be obtained either from the command line option or entered by
    the user through the editor.
    rl   s7   
Write the introductory message for the patch series.

s   patchbombbody)ZrepopathÚactionr)   s   wb)
r   r1   r   Úreadr;   r   Zeditr€   ZvfsÚclose)r   ZdefaultbodyÚsenderr3   r   rm   Zmsgfiler$   r$   r%   Ú_getdescriptionu  s    
ÿ
ÿ
r‹   c              
   K   sØ   | j }t |¡}| d¡p$t|ddƒ}t| d|fi |¤Ž}t ¡ }|rb| t 	|||| d¡¡¡ t
 dd¡}	|	 |¡ d| d	d
¡ }
|	jddt |
¡d t |	¡ | |	¡ t |||| d¡¡|d< ||dfgS )z¶Get the full email for sending a given bundle

    This function returns a list of "email" tuples (subject, content, None).
    The list is always one message long in that case.
    Úsubjects   Subject:s   A bundle for your repositoryrI   ÚtestZapplicationzx-mercurial-bundles   %s.hgÚ
bundlenamer}   rX   rW   )ÚfilenamerZ   N)r   r   rk   r1   r-   r‹   rb   rc   rd   re   Ú	emimebaseZMIMEBaseZset_payloadZ
add_headerr   rh   ÚemailencodersZencode_base64rj   )r   rŠ   r   r3   r   rk   rs   rm   rp   ZdatapartrŽ   r$   r$   r%   Ú_getbundlemsgsŽ  s*    
ÿ
ý

r’   c              	   K   sÜ   | j }t |¡}t|| | ¡ | d¡dt|ƒdd}| d¡pLt|d|dd}|sVd	S |d
 | }d}	| d¡rŠt 	t
|g ƒ¡}
d|
 }	nd	}
t| |	|fi |¤Ž}	t ||	|| d¡¡}t |||| d¡¡|d< |||
fS )z€make an introduction email, asking the user for content if needed

    email is returned as (subject, body, cumulative-diffstat)rG   r   T)rF   rŒ   s   (optional) Subject: rI   )r.   r   Nr5   ra   rN   r   rZ   )r   r   rk   rH   Zlastr1   rC   r-   r   ra   Úsumr‹   re   rj   )r   rŠ   rx   Úpatchesr3   r   rk   rr   rs   rm   ra   rp   r$   r$   r%   Ú
_makeintro¬  s(    
ÿÿ

r•   c                 K   s  t  |¡}| j}t |¡}tt| |fi |¤Žƒ}g }	| tdƒt	|ƒ ¡ t
||t	|ƒƒr~t| |||fi |¤Ž}
|
r~|	 |
¡ t	|	ƒt	|ƒ dk}d}t	|ƒt	|ƒksªJ ‚tt||ƒƒD ]D\}\}}|rÐ|| }t|| |||||d t	|ƒ||ƒ
}
|	 |
¡ q¸|	S )zÀreturn a list of emails from a list of patches

    This involves introduction message creation if necessary.

    This function returns a list of "email" tuples (subject, content, None).
    s+   this patch series consists of %d patches.

r0   N)r   Úbyteskwargsr   r   rk   Úlistr|   r;   r   rC   r4   r•   r'   Ú	enumerateÚziprt   )r   rŠ   rx   Z
patchnamesr3   Z	bytesoptsr   rk   r”   Úmsgsrp   rF   r7   Úirz   rq   r$   r$   r%   Ú_getpatchmsgsÍ  s<    


örœ   c                 C   s†   | j }| |pd|pd¡}t |¡d }| tdƒt |¡ ¡ dd„ |D ƒ}|s^| j 	¡ g}|  
d|pjd|¡}|s‚| td	ƒ¡ |S )
z4Return the revisions present locally but not in dests   default-pushs   defaultr   s   comparing with %s
c                 S   s   g | ]}|d kr|‘qS )r   r$   ©rT   rz   r$   r$   r%   rV     rI   z _getoutgoing.<locals>.<listcomp>s   outgoing(%s) and ::%ldrI   s   no changes found
)r   Z
expandpathr
   ZparseurlÚstatusr   r   ZhidepasswordZ	changelogZtiprevrx   )r   r…   rx   r   Zurlr$   r$   r%   Ú_getoutgoingü  s    rŸ   c                 C   s>   zt  t jd ¡}W n ty.   t ¡ }Y n0 d| ||f S )Ns
   HGHOSTNAMEz
<%s.%d@%s>)r   rh   ÚenvironÚKeyErrorÚsocketZgetfqdn)r   Z	timestampZhostnamer$   r$   r%   Ú_msgid  s
    r£   rI   rM   s-   send patches as inline message text (default)ó   arL   s   send patches as attachmentsó   irQ   s"   send patches as inline attachmentss/   email addresses of blind carbon copy recipientss   EMAILó   cs"   email addresses of copy recipientss#   ask for confirmation before sendingó   drP   s   add diffstat output to messagesó   dates&   use the given date as the sending dates   DATEr/   s,   use the given file as the series descriptions   FILEó   fs   email address of senderó   nrR   s!   print messages that would be sentó   mó   mboxs3   write messages to mbox file instead of sending thems)   email addresses replies should be sent toó   srY   s0   subject of first message (intro or single patch)s   TEXTs   in-reply-tos   message identifier to reply tos   MSGIDr6   s    flags to add in subject prefixess   FLAGó   ts   email addresses of recipientsó   emailó   gs   gits   use git extended diff formatrO   s   omit hg patch headeró   oó   outgoings/   send changes not found in the target repositoryó   br}   s-   send changes not in target as a binary bundleó   Bó   bookmarks-   send changes only reachable by given bookmarks   BOOKMARKs
   bundlenames"   name of the bundle attachment files   NAMEó   ró   revs   a revision to sends   REVs   forces?   run even when remote repository is unrelated (with -b/--bundle)s   basesG   a base changeset to specify instead of a destination (with -b/--bundle)s-   send an introduction email for a single patchs   hg email [OPTION]... [DEST]...)Zhelpcategoryc           0         s–  t  ˆ¡‰t ˆ¡‰ ˆ d¡}ˆ d¡}ˆ d¡}ˆ d¡}ˆ d¡}ˆ d¡}	ˆ d¡sh|sht ˆ¡ |sŠ|sŠ|sŠ|sŠ|	sŠt tdƒ¡‚|r |r t td	ƒ¡‚t	 
ˆdd¡ |s¶|ræt|ƒd
krÐt tdƒ¡‚|rÞ|d }
nd}
g }|r|rþt tdƒ¡‚|}n0|	r4|	ˆjvr(t tdƒ|	 ¡‚t ˆ|	¡}t ˆ|¡}|rRtˆ|
|ƒ}|rjdd„ |D ƒˆd< ˆj dd¡}|rÎˆj d¡ zt ˆi |¡}W n, tjyÈ   ˆj tdƒ| ¡ ‚ Y n0 | d¡säˆj d¡ nê‡fdd„|D ƒ}| dd„ |D ƒ¡}g }t|ƒD ]\}}|| s| |¡ q|rÎt|ƒd
krntdƒ}|||d t|ƒd
 f; }ntdƒ}|||d f; }dd„ |D ƒ}d d d„ ˆ d!|¡D ƒ¡}td"ƒ||f }tj||d#‚|ràt |¡‰nt  ¡ ‰‡fd$d%„}ˆ d&¡p*ˆ d'd&¡p*ˆ dd&¡p*t!ˆd(ˆ "¡ ƒ}|rxt  #ˆ¡}t$ˆ|
fi |¤Ž}| %¡ }| &d)d¡ t'ˆ||fi |¤Ž}nt(ˆ||fi t  #ˆ¡¤Ž}g ‰da‡ ‡‡‡fd+d,„	}|d-d.d/}|sÊt td0ƒ¡‚|d1d.d2d3}|d4ƒ}|d5ƒ} ˆ )dd6¡}!|!t*ˆ d7¡pˆ d6¡ƒO }!|!rºˆj+td8ƒd9d: ˆj+d;| d<d: ˆD ]}"ˆj+d=|" d>d: q@|D ]2\}#}$}%ˆj+d?|$ d@d: |%r^ˆj+|%dAd: q^ˆ +dB¡ ˆ ,tdCƒ¡rºt tdDƒ¡‚ˆ +dB¡ ˆ dE¡pÒd}&|&durt- .|&¡}&|& /dF¡südF|& }&|& 0dG¡s|&dG7 }&t1 2t- .|¡¡d
 }'t 3ˆ|ˆ ˆ d¡¡}d}(d})ˆj4tdHƒtdIƒt|ƒdJ}*t|ƒD ] \}+\}#}$}%z*||#dK ƒ|#dL< |)s–|#dL })|)|#dM< W n  t5yÀ   |dNƒ|#dL< Y n0 |&rØ|&|#dO< |&|#dP< |&rèdK|#vrð|#dL }&dQt6 7¡  8¡  |#dR< t1j9ˆd d.dS|#dT< ˆd d
 ˆd
 f‰||#dU< dV |¡|#dW< |rXdV |¡|#dX< |rldV |¡|#dY< | r€dV | ¡|#dZ< ˆ d¡r
ˆ :td[ƒ|$d\¡ ˆ ;d'¡ tj<ˆd*d]},z|, =|#d*¡ ˆ +dB¡ W n6 t>y }- z|-j?t?j@krò‚ W Y d}-~-n
d}-~-0 0 n||(stjAˆ|d^}(ˆ :td_ƒ|$d\¡ |*jB|+|$d` |sJ|#dY= tCƒ }.tj<|.d*d]},|, =|#d*¡ || | }/|(|'|/|. D¡ ƒ qf|* E¡  dS )baQ  send 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 -B/--bookmark changesets reachable by the given bookmark are
    selected.

    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. Use the ``patchbomb.bundletype`` config option to
    control the bundle type as with :hg:`bundle --type`.

    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.

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

    The default behavior of this command can be customized through
    configuration. (See :hg:`help patchbomb` for details)

    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 feature       # send all ancestors of feature bookmark

      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}   r¨   r¬   r²   r·   rµ   rR   s0   specify at least one changeset with -B, -r or -osE   --outgoing mode always on with --bundle; do not re-specify --outgoingr0   s   too many destinationsr   Ns)   use only one form to specify the revisions   bookmark '%s' not foundc                 S   s   g | ]}d | ‘qS )rB   r$   r   r$   r$   r%   rV     rI   zemail.<locals>.<listcomp>s   revsr   r   s0   checking that revision exist in the public repo
s!   unable to access public repo: %s
s   knowns/   skipping existence checks: public repo too old
c                    s   g | ]}ˆ | ‘qS r$   r$   r   )r   r$   r%   rV   *  rI   c                 s   s   | ]}|  ¡ V  qd S )N)r   ©rT   Úhr$   r$   r%   Ú	<genexpr>+  rI   zemail.<locals>.<genexpr>s'   public "%s" is missing %s and %i otherss   public url %s is missing %sc                 S   s   g | ]}|  ¡ ‘qS r$   )r=   )rT   r"   r$   r$   r%   rV   7  rI   r5   c                 s   s   | ]}d | V  qdS )s   -r %sNr$   r¸   r$   r$   r%   rº   8  s   s
   heads(%ld)s   use 'hg push %s %s')Úhintc                    s   t | d d… tˆ d ƒƒS )Né   r   )r£   Úint)Úid)Ú
start_timer$   r%   ÚgenmsgidD  s    zemail.<locals>.genmsgidr   r¯   s   Fromr   Fc                    sì   |   ¡ }|  dd¡  ¡ }ˆ |¡}|rTˆ d| d |¡f ¡ t ˆ|ˆ ˆ d¡¡S ˆ d|¡pjˆ d|¡}|sžˆ d|¡p†ˆ d|¡}|sž|ržt	ˆ| |d}|rÌˆ d| |f ¡ t ˆ|gˆ ˆ d¡¡S |rèt ˆ|gˆ ˆ d¡¡S g S )	Nó   -ó   _s   %s: %ss   , rR   r¯   r   r   )
ÚlowerÚreplacer1   r'   r8   r   Zaddrlistencoder    Z	hasconfigr-   )ÚheaderÚaskr   Z	configkeyZoptZaddrsÚaddrZ	specified)rk   r3   Ú	showaddrsr   r$   r%   ÚgetaddrsZ  s.    
ÿÿÿzemail.<locals>.getaddrss   ToT)rÆ   s   no recipient addresses provideds   CcrI   )rÆ   r   s   Bccs   Reply-Tor   rP   s   
Final summary:

s   patchbomb.finalsummary)Zlabels	   From: %s
s   patchbomb.froms   %s
s   patchbomb.tos   Subject: %s
s   patchbomb.subjects   patchbomb.diffstatsrN   s1   are you sure you want to send (yn)?$$ &Yes $$ &Nos   patchbomb canceleds   in_reply_toú<ú>s   sendings   emails)ZunitrE   r[   z
Message-IdzX-Mercurial-Series-IdZ	patchbombzIn-Reply-ToZ
ReferenceszMercurial-patchbomb/%sz
User-Agent)Ú	localtimeZDateZFromz, ZToZCcZBcczReply-Tos   displaying s    ...
)Zmangle_from_)Úmboxs   sending )Úitem)FN)Fr   r–   r   rk   r1   Zvalidateconfigr   ZAbortr   r   Zcheck_at_most_one_argrC   Z
_bookmarksr   ZbookmarkrevsZrevrangerŸ   r   r    Údebugr
   ZpeerZ	RepoErrorr2   ZcapableÚknownr˜   r'   r8   Úsetr   Z	parsedateZmakedater-   ZusernameZ	strkwargsr†   Úcopyr`   r’   rœ   Z
configboolÚboolr;   Zpromptchoicer   rh   r\   rS   ÚeutilZ	parseaddrZaddressencodeZmakeprogressÚ	TypeErrorr   ÚversionÚdecodeZ
formatdaterž   ZpagerÚ	GeneratorZflattenÚIOErrorÚerrnoZEPIPEZconnectÚupdater9   r<   Zcomplete)0r   r   rx   r3   r   ÚdaterÍ   Zoutgoingr=   Zbookmarkr…   r#   Z
publicpeerr?   rÐ   ZmissingrD   r¹   rp   ZmissingrevsZrevhintr»   rÀ   rŠ   ZstroptsZ
bundledataZ
bundleoptsrš   rÉ   ÚtoZccZbccZreplytoZconfirmrÇ   Úmrs   ro   ÚparentZsender_addrZsendmailZ
firstpatchZprogressr›   Ú	generatorÚinstÚfpZalldestsr$   )rk   r3   r   rÈ   r¿   r   r%   ÚemailS  s^    








ÿÿÿ

ÿ


ÿ
ÿ
þü

ÿ


ÿ
rã   )Nr,   )N)N)CÚ__doc__Z
__future__r   Zemail.encodersZencodersr‘   Zemail.mime.baseZmimeÚbaser   Zemail.mime.multipartZ	multipartrb   Zemail.utilsZutilsrÔ   rÚ   r   r¢   Zmercurial.i18nr   Zmercurial.pycompatr   Z	mercurialr   r   r   r   r	   r
   r   r   rf   r   r   r   r   r   r   Zmercurial.utilsr   r9   ZcmdtableZcommandZconfigtableZ
configitemZ
testedwithr&   r(   r+   r-   r4   rA   rH   rt   r|   r†   r‹   r’   r•   rœ   rŸ   r£   Z	emailoptsZ
remoteoptsZCATEGORY_IMPORT_EXPORTrã   r$   r$   r$   r%   Ú<module>   s\  B@

ÿÿÿÿÿÿÿÿÿÿ
 ö
d!
/	ûûûûûûûÅ?üüûûÿü
ÿøüÏ8È9Ç:Ã?