Ć
 Nö9c       s7   d  Z  d k Z h  Z d d  Z d   Z 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 	   s  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 } y9 t	 | \ } } } | | j o
 | | j o | Sn Wn t j
 o n Xt |  |  } | | | 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$     0"i   c    s3   |  d d } |  d } |  d } | | | 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~   d d } t |  d  } t | d  } xO d oG | 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
   			