U
    æ¥¡cp
  ã                   @   sh   d dl mZmZ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ZdZG dd	„ d	eeeƒZdS )
é    )Ú
CompoundDBÚ	ObjectDBWÚ
FileDBBase)ÚLooseObjectDB)ÚPackedDB)ÚReferenceDB)ÚInvalidDBRootN)ÚGitDBc                       sf   e Zd ZdZeZeZeZ	dZ
dZej dd¡Z‡ fdd„Z‡ fdd	„Zd
d„ Zdd„ Zdd„ Z‡  ZS )r	   a  A git-style object database, which contains all objects in the 'objects'
    subdirectory

    ``IMPORTANT``: The usage of this implementation is highly discouraged as it fails to release file-handles.
    This can be a problem with long-running processes and/or big repositories.
    ÚpackÚ ÚinfoZ
alternatesc                    s   t ƒ  |¡ dS )z/Initialize ourselves on a git objects directoryN)ÚsuperÚ__init__)ÚselfÚ	root_path©Ú	__class__© ú0/tmp/pip-unpacked-wheel-jjg5dubb/gitdb/db/git.pyr   (   s    zGitDB.__init__c                    sÆ   |dks|dkr¶t ƒ | _d }| j| jf| j| jf| j| jffD ]B\}}|  |¡}t	j
 |¡r>| j ||ƒ¡ || jkr>| jd }q>| js”t|  ¡ ƒ‚|d k	r¦t|dƒs®tdƒ‚|| _ntƒ  |¡ d S )NÚ_dbsÚ	_loose_dbéÿÿÿÿÚstorez(First database needs store functionality)Úlistr   Ú	packs_dirÚ	PackDBClsÚ	loose_dirÚ
LooseDBClsÚalternates_dirÚReferenceDBClsZdb_pathÚosÚpathÚexistsÚappendr   r   ÚhasattrÚAssertionErrorr   r   Ú_set_cache_)r   ÚattrZloose_dbÚsubpathZdbclsr!   r   r   r   r&   ,   s"    


þ

zGitDB._set_cache_c                 C   s   | j  |¡S ©N)r   r   )r   Zistreamr   r   r   r   L   s    zGitDB.storec                 C   s
   | j  ¡ S r)   )r   Úostream)r   r   r   r   r*   O   s    zGitDB.ostreamc                 C   s   | j  |¡S r)   )r   Úset_ostream)r   r*   r   r   r   r+   R   s    zGitDB.set_ostream)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r   r   r   r   r   r    r!   Újoinr   r   r&   r   r*   r+   Ú__classcell__r   r   r   r   r	      s    r	   )Zgitdb.db.baser   r   r   Zgitdb.db.looser   Zgitdb.db.packr   Zgitdb.db.refr   Z	gitdb.excr   r    Ú__all__r	   r   r   r   r   Ú<module>   s   