§
    cÌc…  ã                   óŒ   — d Z ddlZddlZddlmZmZmZ ddlmZ  G d„ d¦  «        Z	 G d„ d	e	¦  «        Z
 G d
„ de	¦  «        ZdS )z3Helper functions for adding files to working trees.é    Né   )ÚerrorsÚosutilsÚui)Úgettextc                   ó6   — e Zd ZdZdd„Zej        fd„Zdd„ZdS )Ú	AddActionz=A class which defines what action to take when adding a file.Nc                 ó^   — || _         |€t          j        | _         d| _        |�	|| _        dS dS )a*  Initialize an action which prints added files to an output stream.

        :param to_file: The stream to write into. This is expected to take
            Unicode paths. If not supplied, it will default to ``sys.stdout``.
        :param should_print: If False, printing will be suppressed.
        NF)Ú_to_fileÚsysÚstdoutÚshould_print)ÚselfÚto_filer   s      ú,/usr/lib/python3/dist-packages/breezy/add.pyÚ__init__zAddAction.__init__!   s=   € ð  ˆŒØˆ?ÝœJˆDŒMØ!ˆÔØÐ#Ø ,ˆDÔÐÐð $Ð#ó    c                 ó`   — | j         r&| j                             d ||¦  «        z  ¦  «         dS )zèAdd path to inventory.

        The default action does nothing.

        :param inv: The inventory we are working with.
        :param path: The FastPath being added
        :param kind: The kind of the object being added.
        z
adding %s
N)r   r   Úwrite)r   ÚinvÚ	parent_ieÚpathÚkindÚ_quotes         r   Ú__call__zAddAction.__call__/   s7   € ð Ôð 	>ØŒM×Ò °°°t±´Ñ <Ñ=Ô=Ð=Øˆtr   c                 ó   — dS )a¸  Test whether the given file should be skipped or not.

        The default action never skips. Note this is only called during
        recursive adds

        :param tree: The tree we are working in
        :param path: The path being added
        :param kind: The kind of object being added.
        :param stat: Stat result for this file, if available already
        :return bool. True if the file should be skipped (not added)
        F© )r   Útreer   r   Ú
stat_values        r   Ú	skip_filezAddAction.skip_file<   s	   € ð ˆur   ©NN©N)	Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   Úquotefnr   r    r   r   r   r	   r	      s^   € € € € € ØGÐGð-ð -ð -ð -ð ;B¼/ð ð ð ð ðð ð ð ð ð r   r	   c                   ó   — e Zd ZdZdZdd„ZdS )ÚAddWithSkipLargeActionzCA class that can decide to skip a file if it's considered too largeNc                 ó’  — |dk    rdS d}| j         €.|                     ¦   «         }|                     |¦  «        | _         |€ t          j                             |¦  «        }n|j        }| j         dk    rS|| j         k    rHt          j         	                    t          d¦  «                             ||| j         ¦  «        ¦  «         dS dS )NÚfileFzadd.maximum_file_sizer   z+skipping {0} (larger than {1} of {2} bytes)T)Ú_maxSizeÚget_config_stackÚgetÚosr   ÚgetsizeÚst_sizer   Ú
ui_factoryÚshow_warningr   Úformat)r   r   r   r   r   Úopt_nameÚconfigÚ	file_sizes           r   r    z AddWithSkipLargeAction.skip_fileP   sÌ   € Ø�6Š>ˆ>Ø�5Ø*ˆØŒ=Ð Ø×*Ò*Ñ,Ô,ˆFØ"ŸJšJ xÑ0Ô0ˆDŒMØÐÝœŸš¨Ñ-Ô-ˆIˆIà"Ô*ˆIØŒ=˜1ÒÐ ¨T¬]Ò!:Ð!:ÝŒM×&Ò&¥wØ=ñ(?ô (?ß?EºvØ�h ¤ñ@/ô @/ñ0ô 0ð 0ð �4Øˆur   r"   )r#   r$   r%   r&   r,   r    r   r   r   r)   r)   K   s3   € € € € € ØMÐMà€Hðð ð ð ð ð r   r)   c                   ó4   ‡ — e Zd ZdZdˆ fd„	Zˆ fd„Zd„ Zˆ xZS )ÚAddFromBaseActionz:This class will try to extract file ids from another tree.Nc                 ój   •— t          ¦   «                              ||¬¦  «         || _        || _        d S )N)r   r   )Úsuperr   Ú	base_treeÚ	base_path)r   r<   r=   r   r   Ú	__class__s        €r   r   zAddFromBaseAction.__init__f   s>   ø€ Ý‰Œ×Ò Ø=Ið 	ñ 	Kô 	Kð 	Kà"ˆŒØ"ˆŒˆˆr   c                 óØ   •— |                       ||¦  «        \  }}|�)| j        r!| j                             d|›d|›d�¦  «         n$t	          ¦   «                              ||||¦  «        }|S )Nzadding z w/ file id from ú
)Ú_get_base_file_idr   r   r   r;   r   )r   r   r   r   r   Úfile_idr=   r>   s          €r   r   zAddFromBaseAction.__call__l   s‰   ø€ ð "×3Ò3°D¸)ÑDÔDÑˆ�ØÐØÔ ð 9Ø”×#Ò#Ð#Ø'+ t t¨Y¨Y¨Yð%8ñ 9ô 9ð 9øõ
 ‘g”g×&Ò&Ø�Y  dñ,ô ,ˆGàˆr   c                 óh  — 	 | j                              |j        ¦  «        }t          j        |t          j        |¦  «        ¦  «        }| j                              |¦  «        }|�||fS n# t          j        $ r Y nw xY wt          j        | j	        |¦  «        }| j                              |¦  «        |fS )zóLook for a file id in the base branch.

        First, if the base tree has the parent directory,
        we look for a file with the same name in that directory.
        Else, we look for an entry in the base tree with the same path.
        )
r<   Úid2pathrB   r   ÚpathjoinÚbasenameÚpath2idr   ÚNoSuchIdr=   )r   r   r   Úparent_pathr=   Úbase_idÚfull_base_paths          r   rA   z#AddFromBaseAction._get_base_file_id{   s¾   € ð	,Øœ.×0Ò0°Ô1BÑCÔCˆKõ  Ô(¨µgÔ6FÀtÑ6LÔ6LÑMÔMˆIØ”n×,Ò,¨YÑ7Ô7ˆGØÐ"Ø Ð+Ð+ð #øõ Œð 	ð 	ð 	ØˆDð	øøøõ !Ô)¨$¬.¸$Ñ?Ô?ˆàŒ~×%Ò% nÑ5Ô5°~ÐEÐEs   ‚A) Á)A;Á:A;r!   )r#   r$   r%   r&   r   r   rA   Ú__classcell__)r>   s   @r   r9   r9   c   sr   ø€ € € € € ØDÐDð#ð #ð #ð #ð #ð #ðð ð ð ð ðFð Fð Fð Fð Fð Fð Fr   r9   )r&   r   r/   Ú r   r   r   Úi18nr   r	   r)   r9   r   r   r   ú<module>rO      sö   ðð" :Ð 9à 
€
€
€
Ø 	€	€	€	ðð ð ð ð ð ð ð ð ð ð
 Ð Ð Ð Ð Ð ð*ð *ð *ð *ð *ñ *ô *ð *ðZð ð ð ð ˜Yñ ô ð ð0*Fð *Fð *Fð *Fð *F˜	ñ *Fô *Fð *Fð *Fð *Fr   