Ć
"Nö9c       sb     d  Z  	  d k Z  d k T d k Z  h  Z  d d  Z 2 d   Z 6 d   Z d S(   s­  Efficiently compare files, boolean outcome only (equal / not equal).

Tricks (used in this order):
    - Use the statcache module to avoid statting files more than once
    - 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
N(   s   *c 	   sI     t  t i |    t  t i |   f \ } }  t | d  p t | d  o  d Sn  | o
 | | j o   d Sn ! | d  | d  j o # d Sn % |  d | } & t
 i |  oB ' t
 | \ } } } ) | | j o
 | | j o + | Sn n . t |  |  } / | | | f t
 | <0 | Sd S(   sß   Compare two files, use the cache if possible.
    May raise os.error if a stat or open of either fails.
    Return 1 for identical files, 0 for different.
    Raise exceptions if either file could not be statted, read, etc.i    i   i   s    N(   s   sigs	   statcaches   stats   f1s   f2s   s1s   s2s   S_ISREGs   shallows   keys   caches   has_keys   cs1s   cs2s   outcomes   do_cmp(	   s   f1s   f2s   shallows   s1s   s2s   keys   cs1s   cs2s   outcomes-   /mit/python/lib/python2.0/lib-old/cmpcache.pys   cmp s    3'i   c    s,   2 3 4 t  |  t  |  t |  t f Sd S(   s>   Return signature (i.e., type, size, mtime) from raw stat data.N(   s   S_IFMTs   sts   ST_MODEs   ST_SIZEs   ST_MTIME(   s   sts-   /mit/python/lib/python2.0/lib-old/cmpcache.pys   sig2 s   c    sĽ   6 7 9 d d } : 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/cmpcache.pys   do_cmp6 s    
  (   s   __doc__s   oss   stats	   statcaches   caches   cmps   sigs   do_cmp(    s-   /mit/python/lib/python2.0/lib-old/cmpcache.pys   ?	 s   
	