KGRKJGETMRETU895U-589TY5MIGM5JGB5SDFESFREWTGR54TY
Server : Apache
System : Linux cs317.bluehost.com 4.19.286-203.ELK.el7.x86_64 #1 SMP Wed Jun 14 04:33:55 CDT 2023 x86_64
User : andertr9 ( 1047)
PHP Version : 8.2.18
Disable Function : NONE
Directory :  /lib64/python2.7/site-packages/hgext/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib64/python2.7/site-packages/hgext/bugzilla.pyo
�
Hq�Qc@svdZddlmZddlmZddlmZmZmZm	Z	ddl
Z
ddlZddlZddl
Z
dZdefd��YZd	efd
��YZdefd��YZd
efd��YZdefd��YZdee
jfd��YZdee
jfd��YZdefd��YZdefd��YZdefd��YZdd�ZdS(s>'hooks for integrating with the Bugzilla bug tracker

This hook extension adds comments on bugs in Bugzilla when changesets
that refer to bugs by Bugzilla ID are seen. The comment is formatted using
the Mercurial template mechanism.

The bug references can optionally include an update for Bugzilla of the
hours spent working on the bug. Bugs can also be marked fixed.

Three basic modes of access to Bugzilla are provided:

1. Access via the Bugzilla XMLRPC interface. Requires Bugzilla 3.4 or later.

2. Check data via the Bugzilla XMLRPC interface and submit bug change
   via email to Bugzilla email interface. Requires Bugzilla 3.4 or later.

3. Writing directly to the Bugzilla database. Only Bugzilla installations
   using MySQL are supported. Requires Python MySQLdb.

Writing directly to the database is susceptible to schema changes, and
relies on a Bugzilla contrib script to send out bug change
notification emails. This script runs as the user running Mercurial,
must be run on the host with the Bugzilla install, and requires
permission to read Bugzilla configuration details and the necessary
MySQL user and password to have full access rights to the Bugzilla
database. For these reasons this access mode is now considered
deprecated, and will not be updated for new Bugzilla versions going
forward. Only adding comments is supported in this access mode.

Access via XMLRPC needs a Bugzilla username and password to be specified
in the configuration. Comments are added under that username. Since the
configuration must be readable by all Mercurial users, it is recommended
that the rights of that user are restricted in Bugzilla to the minimum
necessary to add comments. Marking bugs fixed requires Bugzilla 4.0 and later.

Access via XMLRPC/email uses XMLRPC to query Bugzilla, but sends
email to the Bugzilla email interface to submit comments to bugs.
The From: address in the email is set to the email address of the Mercurial
user, so the comment appears to come from the Mercurial user. In the event
that the Mercurial user email is not recognized by Bugzilla as a Bugzilla
user, the email associated with the Bugzilla username used to log into
Bugzilla is used instead as the source of the comment. Marking bugs fixed
works on all supported Bugzilla versions.

Configuration items common to all access modes:

bugzilla.version
  The access type to use. Values recognized are:

  :``xmlrpc``:       Bugzilla XMLRPC interface.
  :``xmlrpc+email``: Bugzilla XMLRPC and email interfaces.
  :``3.0``:          MySQL access, Bugzilla 3.0 and later.
  :``2.18``:         MySQL access, Bugzilla 2.18 and up to but not
                     including 3.0.
  :``2.16``:         MySQL access, Bugzilla 2.16 and up to but not
                     including 2.18.

bugzilla.regexp
  Regular expression to match bug IDs for update in changeset commit message.
  It must contain one "()" named group ``<ids>`` containing the bug
  IDs separated by non-digit characters. It may also contain
  a named group ``<hours>`` with a floating-point number giving the
  hours worked on the bug. If no named groups are present, the first
  "()" group is assumed to contain the bug IDs, and work time is not
  updated. The default expression matches ``Bug 1234``, ``Bug no. 1234``,
  ``Bug number 1234``, ``Bugs 1234,5678``, ``Bug 1234 and 5678`` and
  variations thereof, followed by an hours number prefixed by ``h`` or
  ``hours``, e.g. ``hours 1.5``. Matching is case insensitive.

bugzilla.fixregexp
  Regular expression to match bug IDs for marking fixed in changeset
  commit message. This must contain a "()" named group ``<ids>` containing
  the bug IDs separated by non-digit characters. It may also contain
  a named group ``<hours>`` with a floating-point number giving the
  hours worked on the bug. If no named groups are present, the first
  "()" group is assumed to contain the bug IDs, and work time is not
  updated. The default expression matches ``Fixes 1234``, ``Fixes bug 1234``,
  ``Fixes bugs 1234,5678``, ``Fixes 1234 and 5678`` and
  variations thereof, followed by an hours number prefixed by ``h`` or
  ``hours``, e.g. ``hours 1.5``. Matching is case insensitive.

bugzilla.fixstatus
  The status to set a bug to when marking fixed. Default ``RESOLVED``.

bugzilla.fixresolution
  The resolution to set a bug to when marking fixed. Default ``FIXED``.

bugzilla.style
  The style file to use when formatting comments.

bugzilla.template
  Template to use when formatting comments. Overrides style if
  specified. In addition to the usual Mercurial keywords, the
  extension specifies:

  :``{bug}``:     The Bugzilla bug ID.
  :``{root}``:    The full pathname of the Mercurial repository.
  :``{webroot}``: Stripped pathname of the Mercurial repository.
  :``{hgweb}``:   Base URL for browsing Mercurial repositories.

  Default ``changeset {node|short} in repo {root} refers to bug
  {bug}.\ndetails:\n\t{desc|tabindent}``

bugzilla.strip
  The number of path separator characters to strip from the front of
  the Mercurial repository path (``{root}`` in templates) to produce
  ``{webroot}``. For example, a repository with ``{root}``
  ``/var/local/my-project`` with a strip of 2 gives a value for
  ``{webroot}`` of ``my-project``. Default 0.

web.baseurl
  Base URL for browsing Mercurial repositories. Referenced from
  templates as ``{hgweb}``.

Configuration items common to XMLRPC+email and MySQL access modes:

bugzilla.usermap
  Path of file containing Mercurial committer email to Bugzilla user email
  mappings. If specified, the file should contain one mapping per
  line::

    committer = Bugzilla user

  See also the ``[usermap]`` section.

The ``[usermap]`` section is used to specify mappings of Mercurial
committer email to Bugzilla user email. See also ``bugzilla.usermap``.
Contains entries of the form ``committer = Bugzilla user``.

XMLRPC access mode configuration:

bugzilla.bzurl
  The base URL for the Bugzilla installation.
  Default ``http://localhost/bugzilla``.

bugzilla.user
  The username to use to log into Bugzilla via XMLRPC. Default
  ``bugs``.

bugzilla.password
  The password for Bugzilla login.

XMLRPC+email access mode uses the XMLRPC access mode configuration items,
and also:

bugzilla.bzemail
  The Bugzilla email address.

In addition, the Mercurial email settings must be configured. See the
documentation in hgrc(5), sections ``[email]`` and ``[smtp]``.

MySQL access mode configuration:

bugzilla.host
  Hostname of the MySQL server holding the Bugzilla database.
  Default ``localhost``.

bugzilla.db
  Name of the Bugzilla database in MySQL. Default ``bugs``.

bugzilla.user
  Username to use to access MySQL server. Default ``bugs``.

bugzilla.password
  Password to use to access MySQL server.

bugzilla.timeout
  Database connection timeout (seconds). Default 5.

bugzilla.bzuser
  Fallback Bugzilla user name to record comments with, if changeset
  committer cannot be found as a Bugzilla user.

bugzilla.bzdir
   Bugzilla install directory. Used by default notify. Default
   ``/var/www/html/bugzilla``.

bugzilla.notify
  The command to run to get Bugzilla to send bug change notification
  emails. Substitutes from a map with 3 keys, ``bzdir``, ``id`` (bug
  id) and ``user`` (committer bugzilla email). Default depends on
  version; from 2.18 it is "cd %(bzdir)s && perl -T
  contrib/sendbugmail.pl %(id)s %(user)s".

Activating the extension::

    [extensions]
    bugzilla =

    [hooks]
    # run bugzilla hook on every change pulled or pushed in here
    incoming.bugzilla = python:hgext.bugzilla.hook

Example configurations:

XMLRPC example configuration. This uses the Bugzilla at
``http://my-project.org/bugzilla``, logging in as user
``bugmail@my-project.org`` with password ``plugh``. It is used with a
collection of Mercurial repositories in ``/var/local/hg/repos/``,
with a web interface at ``http://my-project.org/hg``. ::

    [bugzilla]
    bzurl=http://my-project.org/bugzilla
    user=bugmail@my-project.org
    password=plugh
    version=xmlrpc
    template=Changeset {node|short} in {root|basename}.
             {hgweb}/{webroot}/rev/{node|short}\n
             {desc}\n
    strip=5

    [web]
    baseurl=http://my-project.org/hg

XMLRPC+email example configuration. This uses the Bugzilla at
``http://my-project.org/bugzilla``, logging in as user
``bugmail@my-project.org`` with password ``plugh``. It is used with a
collection of Mercurial repositories in ``/var/local/hg/repos/``,
with a web interface at ``http://my-project.org/hg``. Bug comments
are sent to the Bugzilla email address
``bugzilla@my-project.org``. ::

    [bugzilla]
    bzurl=http://my-project.org/bugzilla
    user=bugmail@my-project.org
    password=plugh
    version=xmlrpc
    bzemail=bugzilla@my-project.org
    template=Changeset {node|short} in {root|basename}.
             {hgweb}/{webroot}/rev/{node|short}\n
             {desc}\n
    strip=5

    [web]
    baseurl=http://my-project.org/hg

    [usermap]
    user@emaildomain.com=user.name@bugzilladomain.com

MySQL example configuration. This has a local Bugzilla 3.2 installation
in ``/opt/bugzilla-3.2``. The MySQL database is on ``localhost``,
the Bugzilla database name is ``bugs`` and MySQL is
accessed with MySQL username ``bugs`` password ``XYZZY``. It is used
with a collection of Mercurial repositories in ``/var/local/hg/repos/``,
with a web interface at ``http://my-project.org/hg``. ::

    [bugzilla]
    host=localhost
    password=XYZZY
    version=3.0
    bzuser=unknown@domain.com
    bzdir=/opt/bugzilla-3.2
    template=Changeset {node|short} in {root|basename}.
             {hgweb}/{webroot}/rev/{node|short}\n
             {desc}\n
    strip=5

    [web]
    baseurl=http://my-project.org/hg

    [usermap]
    user@emaildomain.com=user.name@bugzilladomain.com

All the above add a comment to the Bugzilla bug record of the form::

    Changeset 3b16791d6642 in repository-name.
    http://my-project.org/hg/repository-name/rev/3b16791d6642

    Changeset commit comment. Bug 1234.
i����(t_(tshort(tcmdutiltmailt	templatertutilNtinternaltbzaccesscBsDeZdZd�Zd�Zd�Zd�Zd�Zd�ZRS(s"Base class for access to Bugzilla.cCsD||_|jjdd�}|r@|jj|ddg�ndS(Ntbugzillatusermaptsections(tuitconfigt
readconfig(tselfRR	((s4/usr/lib64/python2.7/site-packages/hgext/bugzilla.pyt__init__"s	cCsCx<|jjd�D](\}}|j�|j�kr|SqW|S(s,map name of committer to Bugzilla user name.R	(Rtconfigitemstlower(Rtusert	committertbzuser((s4/usr/lib64/python2.7/site-packages/hgext/bugzilla.pyt
map_committer(scCsdS(s7remove bug IDs that do not exist in Bugzilla from bugs.N((Rtbugs((s4/usr/lib64/python2.7/site-packages/hgext/bugzilla.pytfilter_real_bug_ids7scCsdS(s;remove bug IDs where node occurs in comment text from bugs.N((RtnodeR((s4/usr/lib64/python2.7/site-packages/hgext/bugzilla.pytfilter_cset_known_bug_ids;scCsdS(s�update the specified bug. Add comment text and set new states.

        If possible add the comment as being from the committer of
        the changeset. Otherwise use the default Bugzilla user.
        N((RtbugidtnewstatettextR((s4/usr/lib64/python2.7/site-packages/hgext/bugzilla.pyt	updatebug?scCsdS(s�Force sending of Bugzilla notification emails.

        Only required if the access method does not trigger notification
        emails automatically.
        N((RRR((s4/usr/lib64/python2.7/site-packages/hgext/bugzilla.pytnotifyGs(	t__name__t
__module__t__doc__RRRRRR(((s4/usr/lib64/python2.7/site-packages/hgext/bugzilla.pyRs					tbzmysqlcBsteZdZed��ZdZd�Zd�Zd�Z	d�Z
d�Zd�Zd�Z
d	�Zd
�ZRS(s�Support for direct MySQL access to Bugzilla.

    The earliest Bugzilla version this is tested with is version 2.16.

    If your Bugzilla is version 3.4 or above, you are strongly
    recommended to use the XMLRPC access method instead.
    cCsddjtt|��dS(s#return SQL-friendly list of bug idst(t,t)(tjointmaptstr(tids((s4/usr/lib64/python2.7/site-packages/hgext/bugzilla.pytsql_buglistYsc	Csjyddl}|t_Wn,tk
rG}tjtd�|��nXtj||�|j	j
ddd�}|j	j
ddd�}|j	j
dd�}|j	j
dd	d�}t|j	j
dd
d��}|j	jtd�|||d
t
|�f�tjjd|d|d|d	|d|�|_|jj�|_|j�|_i|_d|_dS(Ni����s&python mysql support not available: %sRthostt	localhostRRtpasswordtdbttimeoutis'connecting to %s:%s as %s, password %s
t*tpasswdtconnect_timeouts-cd %(bzdir)s && ./processmail %(id)s %(user)s(tMySQLdbR"t_MySQLdbtImportErrorRtAbortRRRRRtinttnotetlentconnecttconntcursortget_longdesc_idtlongdesc_idtuser_idstdefault_notify(	RRtmysqlterrR+RR1R.R/((s4/usr/lib64/python2.7/site-packages/hgext/bugzilla.pyR`s*
	cOsx|jjtd�||f�y|jj||�Wn:tjjk
rs|jjtd�||f��nXdS(srun a query.s
query: %s %s
sfailed query: %s %s
N(RR8RR<texecuteR"R4t
MySQLError(Rtargstkwargs((s4/usr/lib64/python2.7/site-packages/hgext/bugzilla.pytrunys  cCsR|jd�|jj�}t|�dkrFtjtd���n|ddS(sget identity of longdesc fields5select fieldid from fielddefs where name = "longdesc"isunknown database schemai(RGR<tfetchallR9RR6R(RR)((s4/usr/lib64/python2.7/site-packages/hgext/bugzilla.pyR=�s

cCs�|jdtj|j���g|jj�D]\}|^q0}xD|j�D]6}||krR|jjtd�|�||=qRqRWdS(s"filter not-existing bugs from set.s*select bug_id from bugs where bug_id in %ssbug %d does not exist
N(	RGR"R*tkeysR<RHRtstatusR(RRtidtexisting((s4/usr/lib64/python2.7/site-packages/hgext/bugzilla.pyR�s	%cCsz|jdtj|j��t|�f�xG|jj�D]6\}|jjt	d�|t|�f�||=q<WdS(s=filter bug ids that already refer to this changeset from set.s]select bug_id from longdescs where
                    bug_id in %s and thetext like "%%%s%%"s(bug %d already knows about changeset %s
N(
RGR"R*RIRR<RHRRJR(RRRRK((s4/usr/lib64/python2.7/site-packages/hgext/bugzilla.pyR�s#cCsn|jjtd��|j|�\}}x&|j�D]}|jjtd�|�|jjdd|j�}|jjddd�}y||}Wn0tk
r�|i|d6|d6|d6}nX|jjtd	�|�t	j
d
|�}	|	j�}
|	j�}|r8|jj
|
�t	jtd�t	j|�d��q8q8W|jjtd
��dS(stell bugzilla to send mail.stelling bugzilla to send mail:
s	  bug %s
RRtbzdirs/var/www/html/bugzillaRKRsrunning notify command %s
s	(%s) 2>&1sbugzilla notify command %sisdone
N(RRJRtget_bugzilla_userRIRR@t	TypeErrorR8RtpopentreadtclosetwarnR6texplainexit(RRRRtuseridRKtcmdfmtRMtcmdtfptouttret((s4/usr/lib64/python2.7/site-packages/hgext/bugzilla.pyR�s(	
#cCs�y|j|SWn�tk
r�yt|�}Wntk
r�|jjtd�|�|jd|�|jj	�}t
|�dkr�t|��nt|dd�}nX||j|<|SXdS(s!look up numeric bugzilla user id.slooking up user %s
sPselect userid from profiles
                            where login_name like %siiN(R?tKeyErrorR7t
ValueErrorRR8RRGR<RHR9(RRRUtall((s4/usr/lib64/python2.7/site-packages/hgext/bugzilla.pytget_user_id�s



cCs�|j|�}y|j|�}Wn�tk
r�yP|jjdd�}|sltjtd�|��n|j|�}|}Wq�tk
r�tjtd�||f��q�XnX||fS(s�See if committer is a registered bugzilla user. Return
        bugzilla username and userid if so. If not, return default
        bugzilla username and userid.RRs#cannot find bugzilla user id for %ss)cannot find bugzilla user id for %s or %s(RR^R[RRRR6R(RRRRUtdefaultuser((s4/usr/lib64/python2.7/site-packages/hgext/bugzilla.pyRN�s



cCs�t|�dkr+|jjtd��n|j|�\}}tjd�}|jd||||f�|jd||||jf�|j	j
�dS(s�update bug state with comment text.

        Try adding comment as committer of changeset, otherwise as
        default bugzilla user.is'Bugzilla/MySQL cannot update bug state
s%Y-%m-%d %H:%M:%Ssvinsert into longdescs
                    (bug_id, who, bug_when, thetext)
                    values (%s, %s, %s, %s)sfinsert into bugs_activity (bug_id, who, bug_when, fieldid)
                    values (%s, %s, %s, %s)N(R9RRSRRNttimetstrftimeRGR>R;tcommit(RRRRRRRUtnow((s4/usr/lib64/python2.7/site-packages/hgext/bugzilla.pyR�sN(RR R!tstaticmethodR*tNoneR4RRGR=RRRR^RNR(((s4/usr/lib64/python2.7/site-packages/hgext/bugzilla.pyR"Ps					
	
			tbzmysql_2_18cBseZdZd�ZRS(s!support for bugzilla 2.18 series.cCstj||�d|_dS(Ns>cd %(bzdir)s && perl -T contrib/sendbugmail.pl %(id)s %(user)s(R"RR@(RR((s4/usr/lib64/python2.7/site-packages/hgext/bugzilla.pyR�s(RR R!R(((s4/usr/lib64/python2.7/site-packages/hgext/bugzilla.pyRf�stbzmysql_3_0cBs eZdZd�Zd�ZRS(s support for bugzilla 3.0 series.cCstj||�dS(N(RfR(RR((s4/usr/lib64/python2.7/site-packages/hgext/bugzilla.pyR�scCsR|jd�|jj�}t|�dkrFtjtd���n|ddS(sget identity of longdesc fields0select id from fielddefs where name = "longdesc"isunknown database schemai(RGR<RHR9RR6R(RR)((s4/usr/lib64/python2.7/site-packages/hgext/bugzilla.pyR=�s

(RR R!RR=(((s4/usr/lib64/python2.7/site-packages/hgext/bugzilla.pyRg�s	tcookietransportrequestcBs)eZdZgZd�Zdd�ZRS(s�A Transport request method that retains cookies over its lifetime.

    The regular xmlrpclib transports ignore cookies. Which causes
    a bit of a problem when you need a cookie-based login, as with
    the Bugzilla XMLRPC interface.

    So this is a helper for defining a Transport which looks for
    cookies being set in responses and saves them to add to all future
    requests.
    cCs4|jr0x$|jD]}|jd|�qWndS(NtCookie(tcookiest	putheader(Rt
connectiontcookie((s4/usr/lib64/python2.7/site-packages/hgext/bugzilla.pytsend_cookiess	ic
Cs�||_t|_|j|�}|r7|jd�n|j|||�|j||�|j|�|j|�|j	||�y|j
�}Wn tk
r�|jj
�}nXxV|j
jd�D]B}|jdd�d}|jdd�d}	|jj|	�q�W|jdkrJtj|||j|j|j
j��n|j�}
|j�\}}|j|
�|j�|j�S(Nis
Set-Cookies: t;ii�(tverbosetFalsetaccept_gzip_encodingtmake_connectiontset_debugleveltsend_requestt	send_hostRntsend_user_agenttsend_contenttgetresponsetAttributeErrort_conntmsgtgetallmatchingheaderstsplitRjtappendRJt	xmlrpclibt
ProtocolErrortreasontheadersRQt	getparsertfeedRR(
RR+thandlertrequest_bodyRpthtresponsetheadertvalRmtpayloadtparsertunmarshaller((s4/usr/lib64/python2.7/site-packages/hgext/bugzilla.pytrequests4		




(RR R!RjRnR�(((s4/usr/lib64/python2.7/site-packages/hgext/bugzilla.pyRh	s
	tcookietransportcBseZdd�ZRS(icCs/tjtjd�r+tjj||�ndS(NR(RtsafehasattrR�t	TransportR(Rtuse_datetime((s4/usr/lib64/python2.7/site-packages/hgext/bugzilla.pyRNs(RR R(((s4/usr/lib64/python2.7/site-packages/hgext/bugzilla.pyR�MstcookiesafetransportcBseZdd�ZRS(icCs/tjtjd�r+tjj||�ndS(NR(RR�R�R�t
SafeTransportR(RR�((s4/usr/lib64/python2.7/site-packages/hgext/bugzilla.pyRSs(RR R(((s4/usr/lib64/python2.7/site-packages/hgext/bugzilla.pyR�RstbzxmlrpccBsDeZdZd�Zd�Zd�Zd�Zd�Zd�ZRS(snSupport for access to Bugzilla via the Bugzilla XMLRPC API.

    Requires a minimum Bugzilla version 3.4.
    cCs'tj||�|jjddd�}|jd�d}|jjddd�}|jjdd�}|jjdd	d
�|_|jjddd�|_tj||j	|��|_
|j
jj�d
j
d�}t|d�|_t|d�|_|j
jjtd|d|��dS(NRtbzurlshttp://localhost/bugzilla/t/s/xmlrpc.cgiRRR-t	fixstatustRESOLVEDt
fixresolutiontFIXEDtversiont.iitlogin(RRRRtrstripR�R�R�tServerProxyt	transporttbzproxytBugzillaR�R~R7t
bzvermajort
bzverminortUserR�tdict(RRtbzwebRR1tver((s4/usr/lib64/python2.7/site-packages/hgext/bugzilla.pyR]s	cCs.tj|d�ddkr#t�St�SdS(Nthttpithttps(turlparseR�R�(Rturi((s4/usr/lib64/python2.7/site-packages/hgext/bugzilla.pyR�qscCs`|jjjtd|gddg��}djg|dt|�dD]}|d^qI�S(s0Return a string with all comment text for a bug.R)tinclude_fieldsRtRtcomments(R�tBugR�R�R&R((RRKtctt((s4/usr/lib64/python2.7/site-packages/hgext/bugzilla.pytget_bug_commentsws*cCsz|jjjtdt|j��dgdt��}x=|dD]1}|d}|jjt	d�|�||=qAWdS(NR)R�t
permissivetfaultsRKsbug %d does not exist
(
R�R�tgetR�tsortedRItTrueRRJR(RRtprobetbadbugRK((s4/usr/lib64/python2.7/site-packages/hgext/bugzilla.pyR|s$
cCsuxnt|j��D]Z}|j|�jt|��dkr|jjtd�|t|�f�||=qqWdS(Ni����s(bug %d already knows about changeset %s
(R�RIR�tfindRRRJR(RRRRK((s4/usr/lib64/python2.7/site-packages/hgext/bugzilla.pyR�s
$cCs�i}d|kr#|d|d<n|jdkr�|g|d<i|d6|d<d|kry|j|d<|j|d	<n|jjj|�nLd|kr�|jjtd
��n||d<||d<|jjj	|�dS(Nthourst	work_timeiR)tbodytcommenttfixRJt
resolutions?Bugzilla/XMLRPC needs Bugzilla 4.0 or later to mark bugs fixed
RK(
R�R�R�R�R�tupdateRRSRtadd_comment(RRRRRRE((s4/usr/lib64/python2.7/site-packages/hgext/bugzilla.pyR�s



(	RR R!RR�R�RRR(((s4/usr/lib64/python2.7/site-packages/hgext/bugzilla.pyR�Ws						t
bzxmlrpcemailcBs2eZdZd�Zd�Zd�Zd�ZRS(s�Read data from Bugzilla via XMLRPC, send updates via email.

    Advantages of sending updates via email:
      1. Comments can be added as any user, not just logged in user.
      2. Bug statuses or other fields not accessible via XMLRPC can
         potentially be updated.

    There is no XMLRPC function to change bug status before Bugzilla
    4.0, so bugs cannot be marked fixed via XMLRPC before Bugzilla 4.0.
    But bugs can be marked fixed via email from 3.4 onwards.
    cCs]tj||�|jjdd�|_|jsItjtd���ntj	|j�dS(NRtbzemailsconfiguration 'bzemail' missing(
R�RRRR�RR6RRtvalidateconfig(RR((s4/usr/lib64/python2.7/site-packages/hgext/bugzilla.pyR�s
	cCsP|jdkr#d|t|�fS|dkr8d}nd|t|�fSdS(Nis@%s %sRKtbug_ids@%s = %s(R�R((Rt	fieldnametvalue((s4/usr/lib64/python2.7/site-packages/hgext/bugzilla.pytmakecommandline�s
	cCs�|j|�}|jjjtd|g��}|ds�|jjddd�}|jjjtd|g��}|ds�tjt	d�|��q�n|ddd}|j
|jd	|��d
j|�d|}t
j|j�}t
j|j||�}t
j|j|j|�}	t
j|j||�}
||
d<|	|
d
<t
j|jd|�|
d<t
j|j�}|||	|
j��dS(s�send modification message to Bugzilla bug via email.

        The message format is documented in the Bugzilla email_in.pl
        specification. commands is a list of command lines, comment is the
        comment text.

        To stop users from crafting commit comments with
        Bugzilla commands, specify the bug ID via the message body, rather
        than the subject line, and leave a blank line after it.
        tmatchtusersRRRs(default bugzilla user %s email not founditemailRKs
s

tFromtTosBug modificationtSubjectN(RR�R�R�R�RRRR6RRR�R&Rt	_charsetst
addressencodeR�t
mimeencodet
headencodeR:t	as_string(RRtcommandsR�RRtmatchesRR�R�R|tsendmail((s4/usr/lib64/python2.7/site-packages/hgext/bugzilla.pytsend_bug_modify_email�s(!
!


cCs�g}d|kr2|j|jd|d��nd|kry|j|jd|j��|j|jd|j��n|j||||�dS(NR�R�R�t
bug_statusR�(RR�R�R�R�(RRRRRtcmds((s4/usr/lib64/python2.7/site-packages/hgext/bugzilla.pyR�s (RR R!RR�R�R(((s4/usr/lib64/python2.7/site-packages/hgext/bugzilla.pyR��s
				"RcBs�eZied6ed6ed6ed6ed6ZdZdZ	dZd�Zd�Z
d	�ZdZdZdZd
�Zd�ZRS(
s2.16s2.18s3.0txmlrpcsxmlrpc+emails�bugs?\s*,?\s*(?:#|nos?\.?|num(?:ber)?s?)?\s*(?P<ids>(?:\d+\s*(?:,?\s*(?:and)?)?\s*)+)\.?\s*(?:h(?:ours?)?\s*(?P<hours>\d*(?:\.\d+)?))?s�fix(?:es)?\s*(?:bugs?\s*)?,?\s*(?:nos?\.?|num(?:ber)?s?)?\s*(?P<ids>(?:#?\d+\s*(?:,?\s*(?:and)?)?\s*)+)\.?\s*(?:h(?:ours?)?\s*(?P<hours>\d*(?:\.\d+)?))?cCs||_||_dS(N(Rtrepo(RRR�((s4/usr/lib64/python2.7/site-packages/hgext/bugzilla.pyRs	cCs~tjdkrw|jjdd�}ytj|}Wn*tk
ratjt	d�|��nX||j�t_ntjS(sHreturn object that knows how to talk to bugzilla version in
        use.RR�s!bugzilla version %s not supportedN(
Rt_bzReRRt	_versionsR[RR6R(Rt	bzversiontbzclass((s4/usr/lib64/python2.7/site-packages/hgext/bugzilla.pytbz	s
cCst|j�|�S(N(tgetattrR�(Rtkey((s4/usr/lib64/python2.7/site-packages/hgext/bugzilla.pyt__getattr__scCs�tjdkr~tj|jjddtj�tj�t_tj|jjddtj	�tj�t_
tjd�t_nd}d}i}tjj|j
�|�}tj
j|j
�|�}x�tr�i}|r�|r�Pn|s�|}n6|s|}n'|j�|j�kr&|}n|}|j�}||krxtjj|j
�|�}d|kr�|d=q�n%tj
j|j
�|�}d|d<y|jd�}	Wn tk
r�|jd	�}	nXy#t|jd
��}||d
<WnTtk
r	nDtk
rn4tk
rL|jjtd�|jd
��nXx6tjj|	�D]"}
|
srq`n||t|
�<q`Wq�W|r�|j|�n|r�|j|j�|�n|S(
s�return bugs dictionary created from commit comment.

        Extract bug info from changeset comments. Filter out any that are
        not known to Bugzilla, and any that already have a reference to
        the given changeset in their comments.
        Rtregexpt	fixregexps\D+igR�R)iR�s%s: invalid hours
N(Rt_bug_reRetretcompileRRt_default_bug_ret
IGNORECASEt_default_fix_ret_fix_ret	_split_retsearchtdescriptionR�tstarttendtgroupt
IndexErrortfloatROR\RJRR~R7RRR(RtctxR�R�Rtbugmatchtfixmatcht
bugattribstmR)RK((s4/usr/lib64/python2.7/site-packages/hgext/bugzilla.pyt	find_bugssj				





'c	sB�fd�}�jjdd�}�jjdd�}tj�j�jtd|t�}|rz|rztd�}n|r�tj	|dt�}|j
|�n�jj�|j|d|j
�dt|�d	�jjd
d�d�jjd
|�jj���jj�}�j|||tj|j���dS(s0update bugzilla bug with reference to changeset.cs{t�jjddd��}tj|�}xG|dkrv|jd�}|dkr[Pn||d}|d8}q0W|S(sJstrip leading prefix of repo root and turn into
            url-safe path.RtstripiR�i����i(R7RRRtpconvertR�(troottcountR�(R(s4/usr/lib64/python2.7/site-packages/hgext/bugzilla.pytwebrootcsRtstylettemplatesUchangeset {node|short} in repo {root} refers to bug {bug}.
details:
	{desc|tabindent}tquotedtchangestbugthgwebtwebtbaseurlRRN(RRRtchangeset_templaterR�RqReRRtparsestringtuse_templatet
pushbuffertshowt	changesetR(Rt	popbufferRRR�R(	RRRR�RtmapfilettmplR�tdata((Rs4/usr/lib64/python2.7/site-packages/hgext/bugzilla.pyR�`s$

N(RR R"RfRgR�R�R�R�R�ReR�RR�R�R�R�R�R�R�(((s4/usr/lib64/python2.7/site-packages/hgext/bugzilla.pyR�s"
				Bc
Ks�|dkr(tjtd�|��ny|t||�}||}|j|�}|r�x%|D]}|j||||�q`W|j|tj|j	���nWn,t
k
r�}	tjtd�|	��nXdS(s�add comment to bugzilla for each changeset that refers to a
    bugzilla bug id. only add a comment once per bug, so same change
    seen multiple times does not fill bug with duplicate data.s)hook type %s does not pass a changeset idsBugzilla error: %sN(ReRR6RRR�R�RR�Rt	Exception(
RR�thooktypeRRFR�R�RRte((s4/usr/lib64/python2.7/site-packages/hgext/bugzilla.pythook�s


&(R!tmercurial.i18nRtmercurial.nodeRt	mercurialRRRRR�R`R�R�t
testedwithtobjectRR"RfRgRhR�R�R�R�R�R�RReR(((s4/usr/lib64/python2.7/site-packages/hgext/bugzilla.pyt<module>s "01�DIO�

Anon7 - 2021