Your IP : 216.73.216.213


Current Path : /opt/alt/python35/lib64/python3.5/Tools/scripts/__pycache__/
Upload File :
Current File : //opt/alt/python35/lib64/python3.5/Tools/scripts/__pycache__/treesync.cpython-35.pyc



��Yf5�@s�dZddlZddlZddlZddlZdZdZdadada	dd�Z
dd	�Zd
d�ZdZ
dd�Zdd�Zdd�Zddddd�Zdd�Zddd�Zedkr�e
�dS)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�nocCs:tjtjdd�d�\}}x�|D]�\}}|dkrJd}|dkr\d}|dkrn|a|dkr�|a|d	kr�|a|d
kr�|}|dkr,|}aaaq,Wy|\}}WnPtk
r(tdtjd
p�ddd�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/python35/lib64/python3.5/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}~XnXtd|�d}g}tj	|�}x�|D]}}tjj||�}tjj||�}|dkr�|}q<tjj|�r<tjj
|�r<|j||f�q<W|retjj|d�}	x�t|	�j
�D]v}
|
jd�}|ddkr�|dd�r�|d}tjj||�}tjj||�}
t||
�q�Wx!|D]\}}
t||
�qlWdS)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	slavename�entries�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�dSt|�}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-�icCs@x9|jt�}|jt�}||kr1dS|sPqWdS)Nrr)�read�BUFSIZE)r>r?ZsdZmdrrrr9�sr9cCs tj|j��}|tjS)N)r �fstat�fileno�stat�ST_MTIME)�f�strrrr:�sr:cCs=x6|jt�}|sPd|ks1d|krdSqWdS)N�
�rr)rArB)rG�bufrrrr=�sr=r6�wbcCs�td|�td|�td|�s-dSt||�}t||�}x'|jt�}|sdP|j|�qNW|j�|j�dS)NZcopyingz     tozokay to copy? )rr$r*rArB�writer;)�srcZdstZrmodeZwmoderrG�grKrrrr8�s


r8cCs*tjj|�tjj�tjj�S)N)r�stdoutrM�flush�stdin�readline)�promptrrr�	raw_input�s
rUcCs�|j�j�}|s)|ddkrSt|�}|j�j�}|sSt}|dd�dkrmdS|dd�dkr�dStd�t|�S)NrZnyr�y�nzYes or No please -- try again:)�strip�lower�inputrrr$)rTrrrrr$�s
r$�__main__i@)�__doc__r rrErrrrr
rrrr-rBr9r:r=r8rUr$�__name__rrrr�<module>s$0..