???<!-- GIF89;a -->
123123123123
.....................................................................................................................................???<!-- GIF89;a -->
123123123123
.....................................................................................................................................ó
fc           @   sÈ   d  Z  d d l Z d d l Z d d l Z d d l Z d Z d Z d a d a d a	 d „  Z
 d „  Z d „  Z d Z d „  Z d „  Z d „  Z d d d d „ Z d d „ Z e d k rÄ e
 ƒ  n  d S(   s†  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

iÿÿÿÿNt   askt   yest   noc          C   s)  t  j  t j d d ƒ \ }  } x³ |  D]« \ } } | d k rG d } n  | d k r\ d } n  | d k rq | a n  | d k r† | a n  | d	 k r› | a n  | d
 k r° | } n  | d k r& | } a a a q& q& Wy | \ } } Wn0 t k
 rd Gt j d p	d Gd Gd GHd  SXt | | ƒ d  S(   Ni   s   nym:s:d:f:a:s   -yR   s   -nR   s   -ss   -ms   -ds   -fs   -as   usage: pythoni    s   treesync.pys5   [-n] [-y] [-m y|n|a] [-s y|n|a] [-d y|n|a] [-f n|y|a]s   slavedir masterdir(   t   getoptt   syst   argvt   write_slavet   write_mastert   create_directoriest
   ValueErrort   process(   t   optst   argst   ot   at   default_answert   create_filest   slavet   master(    (    s.   /usr/lib64/python2.7/Tools/scripts/treesync.pyt   main#   s0    						c         C   sY  t  j j | d ƒ } t  j j | ƒ s9 d G| GHd GHd  Sd d GHd G|  GHd G| GHt  j j |  ƒ sã t d |  d	 t ƒs’ d G| GHd
 G|  GHd  Sd G|  GHy t  j |  ƒ Wn( t  j k
 rÖ } d G|  Gd G| GHd  SXd G|  GHn  d  } g  } t  j	 | ƒ } xˆ | D]€ } t  j j | | ƒ } t  j j |  | ƒ } | d k rJ| } qt  j j | ƒ rt  j j
 | ƒ r| j | | f ƒ qqW| r1t  j j | d ƒ }	 xŠ t |	 ƒ j ƒ  D]s }
 |
 j d ƒ } | d d k r·| d r·| d } t  j j |  | ƒ } t  j j | | ƒ } t | | ƒ q·q·Wn  x! | D] \ } } t | | ƒ q8Wd  S(   Nt   CVSs   skipping master subdirectorys   -- not under CVSt   -i(   s   slave R   s   create slave directory %s?t   answers   -- no corresponding slaves   creating slave directorys   can't make slave directoryt   :s   made slave directoryt   Entriest   /i    t    i   (   t   ost   patht   joint   isdirt   okayR   t   mkdirt   errort   Nonet   listdirt   islinkt   appendt   opent	   readlinest   splitt   compareR
   (   R   R   t   cvsdirt   msgt   subdirst   namest   namet
   masternamet	   slavenamet   entriest   et   wordst   st   m(    (    s.   /usr/lib64/python2.7/Tools/scripts/treesync.pyR
   ?   sT    									%
c         C   sª  y t  |  d ƒ } Wn t k
 r, d  } n Xy t  | d ƒ } Wn t k
 rY d  } n X| s“ | ss d G| GHd  Sd G|  GHt | |  d t ƒd  S| s¦ d G| GHd  S| rÈ | rÈ t | | ƒ rÈ d  Sn  t | ƒ } t | ƒ } | | k r)| j ƒ  | j ƒ  d G| GHd G|  GHt | |  d t ƒd  Sd	 G| | Gd
 GH| j	 d ƒ t
 | ƒ } | j ƒ  | j ƒ  | r‹d GHt |  | d d t ƒn d GHt |  | d d t ƒd  S(   Nt   rt   rbs   Neither master nor slave existss   Creating missing slaveR   s   Not updating missing masters   Master             s   is newer than slaves   Slave iss   seconds newer than masteri    s#   ***UPDATING MASTER (BINARY COPY)***s   ***UPDATING MASTER***(   R&   t   IOErrorR"   t   copyR   t	   identicalt   mtimet   closeR   t   seekt
   funnycharsR   (   R   R   t   sft   mft   sftt   mftt   fun(    (    s.   /usr/lib64/python2.7/Tools/scripts/treesync.pyR)   m   sP    

			

		

i   i   c         C   sC   x< |  j  t ƒ } | j  t ƒ } | | k r1 d S| s Pq q Wd S(   Ni    i   (   t   readt   BUFSIZE(   R?   R@   t   sdt   md(    (    s.   /usr/lib64/python2.7/Tools/scripts/treesync.pyR:      s      c         C   s    t  j |  j ƒ  ƒ } | t j S(   N(   R   t   fstatt   filenot   statt   ST_MTIME(   t   ft   st(    (    s.   /usr/lib64/python2.7/Tools/scripts/treesync.pyR;   ¥   s    c         C   s@   x9 |  j  t ƒ } | s Pn  d | k s4 d | k r d Sq Wd S(   Ns   s    i   i    (   RD   RE   (   RL   t   buf(    (    s.   /usr/lib64/python2.7/Tools/scripts/treesync.pyR>   ©   s      R7   t   wbc         C   sˆ   d G|  GHd G| GHt  d | ƒ s% d  St |  | ƒ } t | | ƒ } x* | j t ƒ } | s_ Pn  | j | ƒ qF W| j ƒ  | j ƒ  d  S(   Nt   copyings        tos   okay to copy? (   R   R&   RD   RE   t   writeR<   (   t   srct   dstt   rmodet   wmodeR   RL   t   gRN   (    (    s.   /usr/lib64/python2.7/Tools/scripts/treesync.pyR9   °   s    		 
c         C   s   | j  ƒ  j ƒ  } | s) | d d k rY t |  ƒ } | j  ƒ  j ƒ  } | sY t } qY n  | d  d k rm d S| d  d k r d Sd GHt |  ƒ S(   Ni    t   nyi   t   yt   ns   Yes or No please -- try again:(   t   stript   lowert	   raw_inputR   R   (   t   promptR   (    (    s.   /usr/lib64/python2.7/Tools/scripts/treesync.pyR   ¾   s    t   __main__i @  (   t   __doc__R   R   RJ   R   R   R   R   R   R   R   R
   R)   RE   R:   R;   R>   R9   R   t   __name__(    (    (    s.   /usr/lib64/python2.7/Tools/scripts/treesync.pyt   <module>   s"   0		.	.			