§
    cÌcŽ  ã                   ó  — d Z ddlmZmZ ddlmZ  e e¦   «         d¦  «          ej        ddd¬	¦  «        Z ej	        d
dd¬	¦  «        Z
 ej        ddd¬	¦  «        Z ej        ddd¬	¦  «        Z G d„ dej        ¦  «        ZdS )z Merge logic for po_merge plugin.é   )ÚconfigÚmergeé    )Úlazy_importzs
import fnmatch
import subprocess
import tempfile

from breezy import (
    cmdline,
    osutils,
    trace,
    )
úpo_merge.commandz<msgmerge -N "{other}" "{pot_file}" -C "{this}" -o "{result}"a  Command used to create a conflict-free .po file during merge.

The following parameters are provided by the hook:
``this`` is the ``.po`` file content before the merge in the current branch,
``other`` is the ``.po`` file content in the branch merged from,
``pot_file`` is the path to the ``.pot`` file corresponding to the ``.po``
file being merged.
``result`` is the path where ``msgmerge`` will output its result. The hook will
use the content of this file to produce the resulting ``.po`` file.

All paths are absolute.
)ÚdefaultÚhelpúpo_merge.po_dirszpo,debian/poz;List of dirs containing .po files that the hook applies to.úpo_merge.po_globz*.poz?Glob matching all ``.po`` files in one of ``po_merge.po_dirs``.úpo_merge.pot_globz*.potz?Glob matching the ``.pot`` file in one of ``po_merge.po_dirs``.c                   ó:   ‡ — e Zd ZdZˆ fd„Zd„ Zd„ Zd„ Zd„ Zˆ xZ	S )ÚPoMergerzMerge .po files.c                 óÜ  •— t          t          j        | ¦  «                             |¦  «         |j                             ¦   «         | _        | j                             d¦  «        | _        | j                             d¦  «        | _	        | j                             d¦  «        | _
        | j                             dd¬¦  «        | _        d | _        t                               d¦  «         d S )Nr
   r   r   r   F)ÚexpandzPoMerger created)Úsuperr   ÚPerFileMergerÚ__init__Úthis_branchÚget_config_stackÚconfÚgetÚpo_dirsÚpo_globÚpot_globÚcommandÚpot_file_abspathÚtraceÚmutter)ÚselfÚmergerÚ	__class__s     €úB/usr/lib/python3/dist-packages/breezy/plugins/po_merge/po_merge.pyr   zPoMerger.__init__J   s¹   ø€ Ý�eÔ! 4Ñ(Ô(×1Ò1°&Ñ9Ô9Ð9ð Ô&×7Ò7Ñ9Ô9ˆŒ	à”y—}’}Ð%7Ñ8Ô8ˆŒà”y—}’}Ð%7Ñ8Ô8ˆŒàœ	ŸšÐ&9Ñ:Ô:ˆŒØ”y—}’}Ð%7À�}ÑFÔFˆŒà $ˆÔÝ�ŠÐ'Ñ(Ô(Ð(Ð(Ð(ó    c                 óâ  — | j         r| j        sdS d}|j        }| j         D ]m}t                               || j        ¦  «        }t                               ||¦  «        r0t                               d 	                    ||¦  «        ¦  «          n-Œnt                               d| j         ›d| j        ›�¦  «         dS | j
        j                             |d¬¦  «        D ]’\  }}}}||}
}	t                               |	| j        ¦  «        rgt                               ||	¦  «        }| j
        j                             |¦  «        | _        t                               d|›d| j        ›�¦  «          d	S Œ“dS )
z<Return True if merge_matching should be called on this file.FNzpo {} matches: {}zPoMerger did not match for z and )Úfrom_dirÚ	recursivezwill msgmerge z using T)r   r   Ú	this_pathÚosutilsÚpathjoinr   Úfnmatchr   r   Úformatr    Ú	this_treeÚ
list_filesr   Úabspathr   )r   ÚparamsÚpo_dirÚpo_pathÚglobÚpathÚ
file_classÚkindÚentryÚpot_nameÚpot_file_idÚrelpaths               r"   Úfile_matcheszPoMerger.file_matches]   s“  € àŒ|ð 	 4¤<ð 	à�5ØˆØÔ"ˆØ”lð 	ð 	ˆFÝ×#Ò# F¨D¬LÑ9Ô9ˆDÝ�Š˜w¨Ñ-Ô-ð Ý—’Ð0×7Ò7¸ÀÑFÔFÑGÔGÐGØ�ðõ �LŠLˆLØ œL˜L˜L¨$¬,¨,ð8ñ 9ô 9ð 9à�5à-1¬[Ô-B×-MÒ-MØ¨5ð .Nñ .2ô .2ð 	ð 	Ñ)ˆD�*˜d Eà$(¨%�kˆHÝ�Š˜x¨¬Ñ7Ô7ð Ý!×*Ò*¨6°8Ñ<Ô<�Ø(,¬Ô(=×(EÒ(EÀgÑ(NÔ(N�Ô%õ —’�Ø '  ¨Ô)>Ð)>ð@ñ Aô Að Aà�t�tðð �5r#   c                 óF  — t                                d                     |¦  «        ¦  «         t                               t
                               |¦  «        t          j        t          j        t          j        ¬¦  «        }|                     ¦   «         \  }}|j	        ||fS )NzWill msgmerge: {})ÚstdoutÚstderrÚstdin)
r   r   r+   Ú
subprocessÚPopenÚcmdlineÚsplitÚPIPEÚcommunicateÚ
returncode)r   r   ÚprocÚoutÚerrs        r"   Ú_invokezPoMerger._invoke�   s€   € Ý�ŠÐ(×/Ò/°Ñ8Ô8Ñ9Ô9Ð9å×Ò¥§¢¨gÑ 6Ô 6Ý'1¤Ý'1¤Ý&0¤oð  ñ 7ô 7ˆð ×#Ò#Ñ%Ô%‰ˆˆSØŒ  SÐ(Ð(r#   c                 ó,   — |                       |¦  «        S )N)Ú
merge_text)r   r/   s     r"   Úmerge_matchingzPoMerger.merge_matching‹   s   € Ø�Š˜vÑ&Ô&Ð&r#   c                 óì  — t                                d¬¦  «        }i }t                               |d¦  «        |d<   t                               |d¦  «        |d<   t                               |d¦  «        |d<   | j        |d<   	 t          |d         d¦  «        5 }|                     |j        ¦  «         ddd¦  «         n# 1 swxY w Y   t          |d         d¦  «        5 }|                     |j        ¦  «         ddd¦  «         n# 1 swxY w Y   | j	         
                    | j        |¦  «        }|                      |¦  «        \  }}}t          |d         d	¦  «        5 }d
t          |                     ¦   «         ¦  «        fcddd¦  «         t                               |¦  «         S # 1 swxY w Y   	 t                               |¦  «         n# t                               |¦  «         w xY wdg fS )zrCalls msgmerge when .po files conflict.

        This requires a valid .pot file to reconcile both sides.
        Úpo_merge)ÚprefixÚthisÚotherÚresultÚpot_fileÚwbNÚrbÚsuccessznot applicable)ÚtempfileÚmkdtempr(   r)   r   ÚopenÚ
writelinesÚ
this_linesÚother_linesr   Úexpand_optionsr   rI   ÚlistÚ	readlinesÚrmtree)	r   r/   ÚtmpdirÚenvÚfr   ÚretcoderG   rH   s	            r"   rK   zPoMerger.merge_textŽ   sx  € õ ×!Ò!¨Ð!Ñ4Ô4ˆØˆÝ×&Ò& v¨vÑ6Ô6ˆˆF‰Ý×'Ò'¨°Ñ8Ô8ˆˆG‰Ý×(Ò(¨°Ñ:Ô:ˆˆH‰ØÔ/ˆˆJ‰ð	#Ý�c˜&”k 4Ñ(Ô(ð 0¨AØ—’˜VÔ.Ñ/Ô/Ð/ð0ð 0ð 0ñ 0ô 0ð 0ð 0ð 0ð 0ð 0ð 0øøøð 0ð 0ð 0ð 0å�c˜'”l DÑ)Ô)ð 1¨QØ—’˜VÔ/Ñ0Ô0Ð0ð1ð 1ð 1ñ 1ô 1ð 1ð 1ð 1ð 1ð 1ð 1øøøð 1ð 1ð 1ð 1à”i×.Ò.¨t¬|¸SÑAÔAˆGØ $§¢¨WÑ 5Ô 5ÑˆG�S˜#Ý�c˜(”m TÑ*Ô*ð 6¨að !¥$ q§{¢{¡}¤}Ñ"5Ô"5Ð5ð6ð 6ð 6ð 6ñ 6ô 6ð 6õ �NŠN˜6Ñ"Ô"Ð"Ð"ð6ð 6ð 6ð 6øøøð 6ð 6ð 6ð 6ð 6õ �NŠN˜6Ñ"Ô"Ð"Ð"ø�G�NŠN˜6Ñ"Ô"Ð"Ð"øøøØ Ð#Ð#sy   ÂG ÂC Â4G Ã CÃG ÃCÃG Ã!DÃ<G ÄDÄG ÄDÄAG Å"#F,ÆG Æ,F0Æ0G Æ3F0Æ4G ÇG/)
Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r:   rI   rL   rK   Ú__classcell__)r!   s   @r"   r   r   G   s{   ø€ € € € € ØÐð)ð )ð )ð )ð )ð&"ð "ð "ðH)ð )ð )ð'ð 'ð 'ð$ð $ð $ð $ð $ð $ð $r#   r   N)rh   Ú r   r   Úbreezy.lazy_importr   ÚglobalsÚOptionÚcommand_optionÚ
ListOptionÚpo_dirs_optionÚpo_glob_optionÚpot_glob_optionr   r   © r#   r"   ú<module>rt      s@  ðð" 'Ð &ðð ð ð ð ð ð ð ð +Ð *Ð *Ð *Ð *Ð *Ø €ˆGˆG‰IŒIð 
ñ 
ô 
ð 
ð �”ØØJð
ðñ ô €ð$ #�Ô"Ø Ø	FðHñ Hô H€ð
 �”Ø Ø	JðLñ Lô L€ð  �&”-Ø Ø	JðLñ Lô L€ð
c$ð c$ð c$ð c$ð c$ˆuÔ"ñ c$ô c$ð c$ð c$ð c$r#   