https://t.me/RX1948
Server : Apache
System : Linux iad1-shared-b8-43 6.6.49-grsec-jammy+ #10 SMP Thu Sep 12 23:23:08 UTC 2024 x86_64
User : dh_edsupp ( 6597262)
PHP Version : 8.2.26
Disable Function : NONE
Directory :  /lib/python3/dist-packages/hgext/infinitepush/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib/python3/dist-packages/hgext/infinitepush/__pycache__/sqlindexapi.cpython-310.pyc
o

�]Lb�&�@s�ddlmZddlZddlZddlZddlZddlZddlm	Z	ddl
mZdd�ZGdd	�d	ej�Z
Gd
d�dejjj�ZdS)�)�absolute_importN)�pycompat�)�indexapicCs6|�dd�}|�dd�}|�d�r|dd�d}|S)N�_s\_�%s\%�*���)�replace�endswith)�pattern�r
�@/usr/lib/python3/dist-packages/hgext/infinitepush/sqlindexapi.py�_convertbookmarkpatterns

rcs�eZdZdZ		d�fdd�	Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Z�ZS)�sqlindexapiz<
    Sql backend for infinitepush index. See schema.sql
    �,�xcsttt|���||_|||||d�|_d|_d|_|stj}t	j
|d�t	��|_|j�
|�d|_|	|_|
|_dS)N)shostsportsdatabasesuserspassword)�filenameF)�superr�__init__�reponame�sqlargs�sqlconn�	sqlcursor�os�devnull�logging�basicConfig�	getLogger�log�setLevel�
_connected�_waittimeout�_locktimeout)�selfr�host�port�database�user�password�logfile�loglevel�waittimeout�locktimeout��	__class__r
rr#s$
�

zsqlindexapi.__init__cCs�|jrt�d��|jrt�d��d}	ztjjdi|j��|_|j�t	�d|j_
WntjjjyD|d8}|dkr=�t
�d�Ynwq|jj�d	|j�}|j��|_|j�d
|�|j�d|j�d|_dS)
NsSQL connection already opens*SQL cursor already open without connection�TFrrg�������?s%ssSET wait_timeout=%ssSET innodb_lock_wait_timeout=%sr
)rr�indexexceptionr�mysql�	connector�connectr�set_converter_class�CustomConverter�
autocommit�errors�Error�time�sleep�	converter�escaper"�cursor�executer#r!)r$�retryr,r
r
r�
sqlconnectDs6
����
zsqlindexapi.sqlconnectcCsVt���t�d�|j��|j��Wd�n1swYd|_d|_dS)z(Cleans up the metadata store connection.signoreN)�warnings�catch_warnings�simplefilterr�closer�r$r
r
rrEhs


�
zsqlindexapi.closecCs|js|��|S�N)r!rArFr
r
r�	__enter__qszsqlindexapi.__enter__cCs$|dur|j��dS|j��dSrG)r�commit�rollback)r$�exc_type�exc_val�exc_tbr
r
r�__exit__vszsqlindexapi.__exit__c	Cs�|js|��|j�d|j|f�|jjd||jfd�|D]N}|jjd|��||jfd�|��}|�	�}|�
d|�	��}t|��d�}t|�
d|��}|jjd|��|�
�|����|����|||||jf	d�qdS)	NsADD BUNDLE %r %rs5INSERT INTO bundles(bundle, reponame) VALUES (%s, %s)��paramsssINSERT INTO nodestobundle(node, bundle, reponame) VALUES (%s, %s, %s) ON DUPLICATE KEY UPDATE bundle=VALUES(bundle)s	committerrscommitter_dates�INSERT IGNORE INTO nodesmetadata(node, message, p1, p2, author, committer, author_date, committer_date, reponame) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s))r!rAr�inforrr?�hex�extrar(�get�int�date�description�p1�p2)	r$�bundleid�nodesctx�ctxrS�author_name�committer_name�author_date�committer_dater
r
r�	addbundle|s>��

���zsqlindexapi.addbundlecCsB|js|��|j�d|j||f�|jjd|||jfd�dS)zRTakes a bookmark name and hash, and records mapping in the metadata
        store.s&ADD BOOKMARKS %r bookmark: %r node: %rssINSERT INTO bookmarkstonode(bookmark, node, reponame) VALUES (%s, %s, %s) ON DUPLICATE KEY UPDATE node=VALUES(node)rON�r!rArrQrrr?)r$�bookmark�noder
r
r�addbookmark�s
��

�zsqlindexapi.addbookmarkcCsh|js|��g}g}t�|�D]\}}|�d�|�|||jf�qd�|�}|jj	d||d�dS)Ns(%s, %s, %s)�,siINSERT INTO bookmarkstonode(bookmark, node, reponame) VALUES %s ON DUPLICATE KEY UPDATE node=VALUES(node)rO)
r!rAr�	iteritems�append�extendr�joinrr?)r$�	bookmarks�args�valuesrcrdr
r
r�addmanybookmarks�s

�
�zsqlindexapi.addmanybookmarkscCsJ|js|��|j�d|�|D]}t|�}|jjd||jfd�qdS)z�Accepts list of bookmark patterns and deletes them.
        If `commit` is set then bookmark will actually be deleted. Otherwise
        deletion will be delayed until the end of transaction.
        sDELETE BOOKMARKS: %ssFDELETE from bookmarkstonode WHERE bookmark LIKE (%s) and reponame = %srON)r!rArrQrrr?r)r$�patternsrr
r
r�deletebookmarks�s��zsqlindexapi.deletebookmarkscC�|js|��|j�d|j|f�|jjd||jfd�|j��}t|�dks0t|d�dkr8|j�d�dS|dd}|j�d|�|S)	zAReturns the bundleid for the bundle that contains the given node.sGET BUNDLE %r %rsBSELECT bundle from nodestobundle WHERE node = %s AND reponame = %srOrrsNo matching nodeNsFound bundle %r�	r!rArrQrrr?�fetchall�len)r$rd�result�bundler
r
r�	getbundle�s�
zsqlindexapi.getbundlecCrq)	zBReturns the node for the given bookmark. None if it doesn't exist.s"GET NODE reponame: %r bookmark: %rsFSELECT node from bookmarkstonode WHERE bookmark = %s AND reponame = %srOrrsNo matching bookmarkNs
Found node %rrr)r$rcrurdr
r
r�getnode�s ��
zsqlindexapi.getnodecCs�|js|��|j�d|j|f�t|�}|jjd|j|fd�|j��}i}|D]}t	|�dkr;|j�d|�q*|d||d<q*|S)Ns&QUERY BOOKMARKS reponame: %r query: %rsSSELECT bookmark, node from bookmarkstonode WHERE reponame = %s AND bookmark LIKE %srO�sBad row returned: %srr)
r!rArrQrrrr?rsrt)r$�queryrurk�rowr
r
r�getbookmarks�s$��
zsqlindexapi.getbookmarkscCsB|js|��|j�d|j||f�|jjd||j|fd�dS)NsHINSERT METADATA, QUERY BOOKMARKS reponame: %r node: %r, jsonmetadata: %ssPUPDATE nodesmetadata SET optional_json_metadata=%s WHERE reponame=%s AND node=%srOrb)r$rd�jsonmetadatar
r
r�saveoptionaljsonmetadata
s
��

�z$sqlindexapi.saveoptionaljsonmetadata)rr)�__name__�
__module__�__qualname__�__doc__rrArErHrNrarernrprwrxr|r~�
__classcell__r
r
r.rrs"�!$	'rc@s.eZdZdZd	dd�Zd	dd�Zd	dd�ZdS)
r6ziEnsure that all values being returned are returned as python string
    (versus the default byte arrays).NcC�t|�SrG��str�r$�value�dscr
r
r�_STRING_to_python#�z!CustomConverter._STRING_to_pythoncCr�rGr�r�r
r
r�_VAR_STRING_to_python&r�z%CustomConverter._VAR_STRING_to_pythoncCr�rGr�r�r
r
r�_BLOB_to_python)r�zCustomConverter._BLOB_to_pythonrG)rr�r�r�r�r�r�r
r
r
rr6s


r6)�
__future__rrrr:rB�mysql.connectorr2�	mercurialr�rrrr3�
conversion�MySQLConverterr6r
r
r
r�<module>s

https://t.me/RX1948 - 2025