;ò Q Bc@sGdZdkZdkTdkZhZdd„Zd„Zd„ZdS(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*ic Cstti|ƒƒtti|ƒƒf\}}t|dƒ pt|dƒ odSn|o ||jodSn|d |d jodSn|d|}t i |ƒo9t |\}}}||jo ||jo|Sqìnt||ƒ}|||ft |<|SdS(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.iiis N(ssigs statcachesstatsf1sf2ss1ss2sS_ISREGsshallowskeyscacheshas_keyscs1scs2soutcomesdo_cmp( sf1sf2sshallowss2ss1skeysoutcomescs1scs2((s&/usr/lib/python2.3/lib-old/cmpcache.pyscmps 0$ cCs#t|tƒ|t|tfSdS(s>Return signature (i.e., type, size, mtime) from raw stat data.N(sS_IFMTsstsST_MODEsST_SIZEsST_MTIME(sst((s&/usr/lib/python2.3/lib-old/cmpcache.pyssig2scCs~dd}t|dƒ}t|dƒ}xOnoG|i|ƒ}|i|ƒ}||jodSn| odSq+q2WdS(sCompare two files, really.iisrbiiN( sbufsizesopensf1sfp1sf2sfp2sreadsb1sb2(sf1sf2sfp1sb1sb2sfp2sbufsize((s&/usr/lib/python2.3/lib-old/cmpcache.pysdo_cmp6s  (s__doc__sossstats statcachescachescmpssigsdo_cmp(s statcachescachesdo_cmpssigsosscmp((s&/usr/lib/python2.3/lib-old/cmpcache.pys? s