§
    cÌcû!  ã                   ót   — d Z ddlZddlZddlZddlZddlmZmZmZm	Z	 	 	 	 dd„Z
dd„Zd	„ Zdd„Z	 	 	 dd„ZdS )zEExport trees to tarballs, non-controlled directories, zipfiles, etc.
é    Né   )ÚarchiveÚerrorsÚosutilsÚtraceFc           	      óì  — |€|�t          |¦  «        }|€t          |¦  «        }|s}t          j        ¦   «         }t          | dd¦  «        rX	 | j                             |                      ¦   «         ¦  «        j        }n(# t          j	        $ r Y nt          j
        $ r Y nw xY wnd}t          j        d| ¦  «         |dk    rG|                      ¦   «         5  t          | |||||¬¦  «        D ]}	Œ	 ddd¦  «         n# 1 swxY w Y   dS |                      ¦   «         5  |                      ||||||¬¦  «        }
|dk    r>|
D ]:}t          t           j        dt           j        ¦  «                             |¦  «         Œ;n`|�|
D ]}|                     |¦  «         ŒnCt'          |d	¦  «        5 }|
D ]}|                     |¦  «         Œ	 ddd¦  «         n# 1 swxY w Y   ddd¦  «         dS # 1 swxY w Y   dS )
aB  Export the given Tree to the specific destination.

    Args:
      tree: A Tree (such as RevisionTree) to export
      dest: The destination where the files,etc should be put
      format: The format (dir, zip, etc), if None, it will check the
              extension on dest, looking for a match
      root: The root location inside the format.
            It is common practise to have zipfiles and tarballs
            extract into a subdirectory, rather than into the
            current working directory.
            If root is None, the default root will be
            selected as the destination without its
            extension.
      subdir: A starting directory within the tree. None means to export the
              entire tree, and anything else should specify the relative path
              to a directory to start exporting from.
      per_file_timestamps: Whether to use the timestamp stored in the tree
          rather than now(). This will do a revision lookup for every file so will
          be significantly slower.
      fileobj: Optional file object to use
    NÚ_repositoryzexport version %rÚdir©Úrecurse_nested)ÚrootÚsubdirÚforce_mtimer   ú-ÚbufferÚwb)Úguess_formatÚget_root_nameÚtimeÚgetattrr	   Úget_revisionÚget_revision_idÚ	timestampr   ÚNoSuchRevisionÚUnsupportedOperationr   ÚmutterÚ	lock_readÚdir_exporter_generatorr   ÚsysÚstdoutÚwriteÚopen)ÚtreeÚdestÚformatr   r   Úper_file_timestampsÚfileobjr   r   ÚunusedÚchunksÚchunkÚfs                ú//usr/lib/python3/dist-packages/breezy/export.pyÚexportr-   !   s1  € ð2 €~˜$Ð*Ý˜dÑ#Ô#ˆð €|Ý˜TÑ"Ô"ˆàð Ý”i‘k”kˆÝ�4˜¨Ñ-Ô-ð 	ðØ"Ô.×;Ò;Ø×(Ò(Ñ*Ô*ñ,ô ,Ü,5ð �øåÔ(ð ð ð Ø�ÝÔ.ð ð ð Ø�ðøøøð	ð ˆå	„LÐ$ dÑ+Ô+Ð+à�‚€ð �^Š^ÑÔð 	ð 	Ý0°°t¸TÀ6Ø1<Ø@NðPñ Pô Pð ð �ð ðð	ð 	ð 	ñ 	ô 	ð 	ð 	ð 	ð 	ð 	ð 	øøøð 	ð 	ð 	ð 	ð
 	ˆà	�ŠÑ	Ô	ð #ð #Ø—’˜f d°Ø%+¸Ø-;ð ñ =ô =ˆð �3Š;ˆ;Øð Gð G�Ý�œ
 H­c¬jÑ9Ô9×?Ò?ÀÑFÔFÐFÐFðGàÐ Øð %ð %�Ø—’˜eÑ$Ô$Ð$Ð$ð%õ �d˜DÑ!Ô!ð # QØ#ð #ð #�EØ—G’G˜E‘N”N�N�Nð#ð#ð #ð #ñ #ô #ð #ð #ð #ð #ð #ð #øøøð #ð #ð #ð #ð#ð #ð #ñ #ô #ð #ð #ð #ð #ð #ð #ð #øøøð #ð #ð #ð #ð #ð #sa   Á1A> Á>B ÂB ÂB ÃC;Ã;C?ÄC?ÄBG)Æ)GÇG)ÇG	ÇG)ÇG	ÇG)Ç)G-Ç0G-r
   c                 óL   — t           j                             | ¦  «        }|€|}|S )z«Guess the export format based on a file name.

    :param filename: Filename to guess from
    :param default: Default format to fall back to
    :return: format name
    )r   Úformat_registryÚget_format_from_filename)ÚfilenameÚdefaultr%   s      r,   r   r   k   s)   € õ Ô$×=Ò=¸hÑGÔG€FØ€~ØˆØ€Mó    c                 óÚ   — | dk    rdS t           j                             | ¦  «        } t          j        j        D ]1}|                      |¦  «        r| dt          |¦  «         …         c S Œ2| S )z+Get just the root name for an export.

    r   Ú N)ÚosÚpathÚbasenamer   r/   Ú
extensionsÚendswithÚlen)r$   Úexts     r,   r   r   x   sw   € ð
 ˆs‚{€{àˆrÝŒ7×Ò˜DÑ!Ô!€DÝÔ&Ô1ð $ð $ˆØ�=Š=˜ÑÔð 	$Ø˜
�#˜c™(œ(˜˜
Ô#Ð#Ð#Ð#ð	$à€Kr3   Tc              #   ó   K  — |dk    rd}|�|                      d¦  «        }|                      |¬¦  «        }|D ]“\  }}|dk    rŒ|r|                      |¦  «        rŒ$||k    r|j        dk    rŒ6|j        }n8|�4|                     |dz   ¦  «        r|t          |¦  «        dz   d…         }nŒt|}|                      |¦  «        sŒŒ|||fV — Œ”dS )aG  Iter the entries for tree suitable for exporting.

    :param tree: A tree object.
    :param subdir: None or the path of an entry to start exporting from.
    :param skip_special: Whether to skip .bzr files.
    :return: iterator over tuples with final path, tree path and inventory
        entry for each entry to export
    r5   Nú/r   Ú	directoryr   )ÚrstripÚiter_entries_by_dirÚis_special_pathÚkindÚnameÚ
startswithr;   Úhas_filename)r#   r   Úskip_specialr   Úentriesr7   ÚentryÚ
final_paths           r,   Ú_export_iter_entriesrK   ‡   s  è è € ð �‚|€|ØˆØÐØ—’˜sÑ#Ô#ˆØ×&Ò&°nÐ&ÑEÔE€GØð &ð &‰ˆˆeØ�2Š:ˆ:Øàð 	˜D×0Ò0°Ñ6Ô6ð 	ØØ�6Š>ˆ>ØŒz˜[Ò(Ð(ØØœˆJˆJØÐØ�Š˜v¨™|Ñ,Ô,ð Ø!¥# f¡+¤+°¡/Ð"2Ð"2Ô3�
�
ààˆJØ× Ò  Ñ&Ô&ð 	Øà˜$ Ð%Ð%Ð%Ð%Ð%ð)&ð &r3   c           
   #   ó  K  — 	 t          j        |¦  «         nZ# t          $ rM}|j        t          j        k    r-t          j        |¦  «        g k    rt          j        d¦  «        ‚n‚ Y d}~nd}~ww xY wg }t          | ||¬¦  «        D ]è\  }	}
}t          j
        ||	¦  «        }|j        dk    r|                     |
|	|
dff¦  «         n£|j        dv rt          j        |¦  «         n…|j        dk    r[	 |                      |
¦  «        }t          j        ||¦  «         nN# t          $ r"}t          j        d|›d|›d	|›�¦  «        ‚d}~ww xY wt          j        d
|
›d|j        ›�¦  «        ‚dV — Œét           j        t           j        z  t           j        z  t%          t           dd¦  «        z  }|                      |¦  «        D ]Â\  \  }}}}t          j
        ||¦  «        }d}|                      |¦  «        rd}t          j        t          j        |||¦  «        d¦  «        5 }|                     |¦  «         ddd¦  «         n# 1 swxY w Y   |�|}n|                      |¦  «        }t          j        |||f¦  «         dV — ŒÃdS )a\  Return a generator that exports this tree to a new directory.

    `dest` should either not exist or should be empty. If it does not exist it
    will be created holding the contents of this tree.

    :note: If the export fails, the destination directory will be
           left in an incompletely exported state: export is not transactional.
    z)Can't export tree to non-empty directory.Nr   Úfile)r?   ztree-referenceÚsymlinkzFailed to create symlink z -> z	, error: zdon't know how to export {z
} of kind ÚO_BINARYr   i¶  iÿ  r   )r6   ÚmkdirÚOSErrorÚerrnoÚEEXISTÚlistdirr   ÚBzrErrorrK   r   ÚpathjoinrC   ÚappendÚget_symlink_targetrN   ÚO_CREATÚO_TRUNCÚO_WRONLYr   Úiter_files_bytesÚis_executableÚfdopenr"   Ú
writelinesÚget_file_mtimeÚutime)r#   r$   r   r   r   r'   r   ÚeÚto_fetchÚdpÚtpÚieÚfullpathÚsymlink_targetÚflagsÚrelpathÚtreepathÚunused_noner)   ÚmodeÚoutÚmtimes                         r,   r   r   ¬   s2  è è € ð	Ý
Œ�‰ŒˆˆøÝð ð ð ØŒ7•e”lÒ"Ð"åŒz˜$ÑÔ 2Ò%Ð%Ý”oØ?ñAô Að Að &ð ð	 &Ð%Ð%Ð%Ð%øøøøðøøøð €HÝ*Ø�&¨ð9ñ 9ô 9ð ð ‰
ˆˆB�åÔ# D¨"Ñ-Ô-ˆØŒ7�fÒÐØ�OŠO˜R " b¨$ Ð0Ñ1Ô1Ð1Ð1ØŒWÐ7Ð7Ð7ÝŒH�XÑÔÐÐØŒW˜	Ò!Ð!ð5Ø!%×!8Ò!8¸Ñ!<Ô!<�Ý”
˜>¨8Ñ4Ô4Ð4Ð4øÝð 5ð 5ð 5Ý”o�oà�x�x   °°ð4ñ5ô 5ð 5øøøøð5øøøõ
 ”/�/Ø#% 2 2 r¤w wð#0ñ 1ô 1ð 1ð 	ˆˆˆˆõ ŒJ�œÑ#¥b¤kÑ1µG½BÀ
ÈAÑ4NÔ4NÑN€EØ48×4IÒ4IÈ(Ñ4SÔ4Sð ð Ñ0Ñ(ˆ�(˜K¨&ÝÔ# D¨'Ñ2Ô2ˆàˆØ×Ò˜hÑ'Ô'ð 	ØˆDÝŒY•r”w˜x¨°Ñ5Ô5°tÑ<Ô<ð 	#ÀØ�NŠN˜6Ñ"Ô"Ð"ð	#ð 	#ð 	#ñ 	#ô 	#ð 	#ð 	#ð 	#ð 	#ð 	#ð 	#øøøð 	#ð 	#ð 	#ð 	#àÐ"ØˆEˆEà×'Ò'¨Ñ1Ô1ˆEÝ
Œ�˜E 5˜>Ñ*Ô*Ð*àˆˆˆˆðð s?   „ ™
A0£AA+Á+A0Ã2*DÄ
E	Ä'EÅE	È"IÉI	ÉI	)NNNFNF)r
   )TF)NNNF)Ú__doc__rR   r6   r   r   r5   r   r   r   r   r-   r   r   rK   r   © r3   r,   ú<module>rr      sü   ðð"ð ð €€€Ø 	€	€	€	Ø 
€
€
€
Ø €€€ðð ð ð ð ð ð ð ð ð ð ð ð 7;Ø.2ØðG#ð G#ð G#ð G#ðT
ð 
ð 
ð 
ðð ð ð"&ð "&ð "&ð "&ðJ 59Ø59Ø*/ðAð Að Að Að Að Ar3   