
    wi                        d dl mZ d dlZd dlmZ d dlmZ d dl	m
Z
 d dlmZ d dlmZ d dlmZ d dlmZ d d	lmZ d d
lmZ d dlmZ d dlmZ ddZddZddZdS )    )annotationsN)Any)output)InvalidConfigError)InvalidManifestError)load_config)load_manifest)LOCAL)META)Store)rmtreestorer   	all_reposdict[tuple[str, str], str]unused_reposset[tuple[str, str]]repodict[str, Any]returnNonec                   |d         t           k    rd S |d         t          k    r]|d         D ]R}|                    d          }|                    |                     |d         |          t
          j        f           Sd S |d         |d         f}|                    |          }|d S 	 t          t          j	        
                    |t
          j                            }|                    |           d |D             }	n# t          $ r Y d S w xY w|d         D ]l}|d         |	vr|                    d|	|d                  d                   }|                    |                     |d         |          |d         f           md S )Nr   hooksadditional_dependenciesrevc                     i | ]}|d          |S )id ).0hooks     f/root/.openclaw/workspace/chatterbox_venv_py311/lib/python3.11/site-packages/pre_commit/commands/gc.py
<dictcomp>z$_mark_used_repos.<locals>.<dictcomp>.   s    ;;;$T$Z;;;    r   )r   r
   getdiscarddb_repo_nameCLOCAL_REPO_VERSIONr	   ospathjoinMANIFEST_FILEr   )
r   r   r   r   r   depskeyr)   manifestby_ids
             r    _mark_used_reposr0      s    F|t	f		M 	 	D88566D  ""4<66$"    	 	 F|T%[)}}S!!<F	<$RW\\$%H%HIIH   %%%;;(;;;EE	 $ 	 	 	FF	 M 
	 
	DDz&&88)d4j!";< D   ""4<66U"    
	 
	s   ,7D 
DDintc           
     r   |                                  5  |                                 5 }|                     |           |                    d                                          }d |D             }t          |          }|                    d                                          }d |D             }g }|D ]T}	 t          |          }	|	d         D ]}
t          | |||
           0# t          $ r |	                    |           Y Qw xY wd |D             }|
                    d|           |
                    dt          |                     |D ]}t          ||                    t          |          cd d d            cd d d            S # 1 swxY w Y   d d d            d S # 1 swxY w Y   d S )	Nz!SELECT repo, ref, path FROM reposc                     i | ]\  }}}||f|S r   r   )r   r   refr)   s       r    r!   z_gc.<locals>.<dictcomp>B   s$    DDD?4ddC[$DDDr"   zSELECT path FROM configsc                    g | ]\  }|S r   r   r   r)   s     r    
<listcomp>z_gc.<locals>.<listcomp>F   s    222ED4222r"   reposc                    g | ]}|fS r   r   r6   s     r    r7   z_gc.<locals>.<listcomp>S   s    222T$222r"   z"DELETE FROM configs WHERE path = ?z,DELETE FROM repos WHERE repo = ? and ref = ?)exclusive_lockconnect_create_configs_tableexecutefetchallsetr   r0   r   appendexecutemanysortedr   len)r   dbr8   r   r   configs_rowsconfigsdead_configsconfig_pathconfigr   pathsks                r    _gcrL   =   s   					 ! ! !B##B'''

>??HHJJDDeDDD	9~~zz"<==FFHH22\222" 	K 	KKK$[11
 #7O K KD$UI|TJJJJK	 &   ##K000 32\222
;UCCC
:<  	
 	
 	
  	! 	!A9Q<    <  ?! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! !sZ   F,BF<C)F)D	F
D	A0F;F,F	F,F	F,,F03F0c                N    t          j        t          |            d           dS )Nz repo(s) removed.r   )r   
write_linerL   )r   s    r    gcrO   `   s'    
U6667771r"   )
r   r   r   r   r   r   r   r   r   r   )r   r   r   r1   )
__future__r   os.pathr(   typingr   pre_commit.constants	constantsr&   
pre_commitr   pre_commit.clientlibr   r   r   r	   r
   r   pre_commit.storer   pre_commit.utilr   r0   rL   rO   r   r"   r    <module>rY      s.   " " " " " "                          3 3 3 3 3 3 5 5 5 5 5 5 , , , , , , . . . . . . & & & & & & % % % % % % " " " " " " " " " " " "( ( ( (V !  !  !  !F     r"   