Your IP : 216.73.216.213


Current Path : /opt/alt/python34/lib64/python3.4/Tools/scripts/__pycache__/
Upload File :
Current File : //opt/alt/python34/lib64/python3.4/Tools/scripts/__pycache__/treesync.cpython-34.pyo

�
e f5�@s�dZddlZddlZddlZddlZdZdZdadada	dd�Z
dd	�Zd
d�ZdZ
dd�Zdd�Zdd�Zddddd�Zdd�Zddd�Zedkr�e
�ndS)a�Script to synchronize two source trees.

Invoke with two arguments:

python treesync.py slave master

The assumption is that "master" contains CVS administration while
slave doesn't.  All files in the slave tree that have a CVS/Entries
entry in the master tree are synchronized.  This means:

    If the files differ:
        if the slave file is newer:
            normalize the slave file
            if the files still differ:
                copy the slave to the master
        else (the master is newer):
            copy the master to the slave

    normalizing the slave means replacing CRLF with LF when the master
    doesn't use CRLF

�NZask�yes�nocCsOtjtjdd�d�\}}x�|D]�\}}|dkrMd}n|dkrbd}n|dkrw|an|dkr�|an|d	kr�|an|d
kr�|}n|dkr,|}aaaq,q,Wy|\}}WnPtk
r=tdtjd
pddd�tddd�td�dSYnXt||�dS)N�znym:s:d:f:a:z-yrz-nrz-sz-mz-dz-fz-az
usage: pythonrztreesync.py�end� z5[-n] [-y] [-m y|n|a] [-s y|n|a] [-d y|n|a] [-f n|y|a]zslavedir masterdir)	�getopt�sys�argv�write_slave�write_master�create_directories�
ValueError�print�process)Zopts�args�o�a�default_answer�create_files�slave�master�r�;/opt/alt/python34/lib64/python3.4/Tools/scripts/treesync.py�main#s0%						
 
	rcCs�tjj|d�}tjj|�sBtd|�td�dStdd�td|�td|�tjj|�std|d	t�s�td|�td
|�dStd|�ytj|�Wn<tk
r}ztd|d
|�dSWYdd}~XqXtd|�nd}g}tj	|�}x�|D]�}tjj||�}tjj||�}|dkr�|}q?tjj|�r?tjj
|�r?|j||f�q?q?W|rqtjj|d�}	x�t|	�j
�D]y}
|
jd�}|ddkr�|dd�r�|d}tjj||�}tjj||�}
t||
�q�q�Wnx!|D]\}}
t||
�qxWdS)NZCVSzskipping master subdirectoryz-- not under CVS�-�(zslave rzcreate slave directory %s?�answerz-- no corresponding slavezcreating slave directoryzcan't make slave directory�:zmade slave directoryZEntries�/r�r)�os�path�join�isdirr�okayr�mkdir�OSError�listdir�islink�append�open�	readlines�split�comparer)rrZcvsdir�msgZsubdirs�names�nameZ
masternameZ	slavenameZentries�eZwords�s�mrrrr?sT




	



	% 
rcCs�yt|d�}Wntk
r-d}YnXyt|d�}Wntk
r[d}YnX|s�|sytd|�dStd|�t||dt�dS|s�td|�dS|r�|r�t||�r�dSnt|�}t|�}||kr?|j�|j�td|�td|�t||dt�dStd	||d
�|j	d�t
|�}|j�|j�|r�td�t||ddt�n td
�t||ddt�dS)N�r�rbzNeither master nor slave existszCreating missing slaverzNot updating missing masterzMaster             zis newer than slavezSlave iszseconds newer than masterrz#***UPDATING MASTER (BINARY COPY)***z***UPDATING MASTER***)r*�IOErrorr�copyr�	identical�mtime�closer
�seek�
funnycharsr)rr�sf�mfZsftZmftZfunrrrr-msP













r-�icCsCx<|jt�}|jt�}||kr1dS|sPqqWdS)Nrr)�read�BUFSIZE)r=r>ZsdZmdrrrr8�sr8cCs tj|j��}|tjS)N)r �fstat�fileno�stat�ST_MTIME)�f�strrrr9�sr9cCs@x9|jt�}|sPnd|ks4d|krdSqWdS)N�
�rr)r@rA)rF�bufrrrr<�sr<r5�wbcCs�td|�td|�td|�s-dSt||�}t||�}x*|jt�}|sgPn|j|�qNW|j�|j�dS)NZcopyingz     tozokay to copy? )rr$r*r@rA�writer:)�srcZdstZrmodeZwmoderrF�grJrrrr7�s


r7cCs*tjj|�tjj�tjj�S)N)r�stdoutrL�flush�stdin�readline)�promptrrr�	raw_input�s
rTcCs�|j�j�}|s)|ddkrYt|�}|j�j�}|sYt}qYn|dd�dkrsdS|dd�dkr�dStd�t|�S)NrZnyr�y�nzYes or No please -- try again:)�strip�lower�inputrrr$)rSrrrrr$�s
r$�__main__i@)�__doc__r rrDrrrrr
rrrr-rAr8r9r<r7rTr$�__name__rrrr�<module>s$0..