Ć
 Nö9c       sL     d  Z   
 d k Z  h  Z  d d  Z - d   Z 6 d   Z d S(   sg  Efficiently compare files, boolean outcome only (equal / not equal).

Tricks (used in this order):
    - Files with identical type, size & mtime are assumed to be clones
    - Files with different type or size cannot be identical
    - We keep a cache of outcomes of earlier comparisons
    - We don't fork a process to run 'cmp' but read the files ourselves
Nc 	   sQ     t  t i |    t  t i |   f \ } }  | d d j p | d d j o  d Sn  | o
 | | j o  d Sn  | d  | d  j o  d Sn  |  | f }  yB  t	 | \ } } } ! | | j o
 | | j o # | Sn Wn % t j
 o
 ' n X) t |  |  } * | | | f t	 | <+ | Sd S(   sĽ   Compare two files, use the cache if possible.
    Return 1 for identical files, 0 for different.
    Raise exceptions if either file could not be statted, read, etc.i    i   i   i   N(   s   sigs   oss   stats   f1s   f2s   s1s   s2s   shallows   keys   caches   cs1s   cs2s   outcomes   KeyErrors   do_cmp(	   s   f1s   f2s   shallows   s1s   s2s   keys   cs1s   cs2s   outcomes(   /mit/python/lib/python2.0/lib-old/cmp.pys   cmp s$   3%i   c    sE   - 0 1 |  d d } 2 |  d } 3 |  d } 4 | | | f Sd S(   s§   Return signature (i.e., type, size, mtime) from raw stat data
    0-5: st_mode, st_ino, st_dev, st_nlink, st_uid, st_gid
    6-9: st_size, st_atime, st_mtime, st_ctimei    i   i   i   N(   s   sts   types   sizes   mtime(   s   sts   types   sizes   mtimes(   /mit/python/lib/python2.0/lib-old/cmp.pys   sig- s
   c    sĽ   6 7 8 d d } 9 t |  d  } : t | d  } ; xd ; d oY < | i |  } = | i |  } > | | j o > d Sn ? | o ? d Sn q= Wd S(   s   Compare two files, really.i   i   s   rbi   i    N(	   s   bufsizes   opens   f1s   fp1s   f2s   fp2s   reads   b1s   b2(   s   f1s   f2s   bufsizes   fp1s   fp2s   b1s   b2s(   /mit/python/lib/python2.0/lib-old/cmp.pys   do_cmp6 s    
  (   s   __doc__s   oss   caches   cmps   sigs   do_cmp(    s(   /mit/python/lib/python2.0/lib-old/cmp.pys   ? s
   		