-=[ Mr. Bumblebee ]=-
_Indonesia_

Path : /usr/lib/python2.7/dist-packages/bzrlib/
File Upload :
Current File : //usr/lib/python2.7/dist-packages/bzrlib/hashcache.pyc

σ
¦ξNc@@sŽddlmZdZddlZddlZddlZddlmZmZm	Z
mZmZdZ
dZdZdefd	„ƒYZdS(
i(tabsolute_imports### bzr hashcache v5
N(t
atomicfileterrorstfilterstosutilsttraceiiit	HashCachecB@szeZdZeZddd„Zd„Zd„Zd„Z	dd„Z
d„Zd„Zd„Z
d	„Zdd
„ZRS(s{Cache for looking up file SHA-1.

    Files are considered to match the cached value if the fingerprint
    of the file has not changed.  This includes its mtime, ctime,
    device number, inode number, and size.  This should catch
    modifications or replacement of the file by a new one.

    This may not catch modifications that do not change the file's
    size and that occur within the resolution window of the
    timestamps.  To handle this we specifically do not cache files
    which have changed since the start of the present second, since
    they could undetectably change again.

    This scheme may fail if the machine's clock steps backwards.
    Don't do that.

    This does not canonicalize the paths passed in; that should be
    done by the caller.

    _cache
        Indexed by path, points to a two-tuple of the SHA-1 of the file.
        and its fingerprint.

    stat_count
        number of times files have been statted

    hit_count
        number of times files have been retrieved from the cache, avoiding a
        re-read

    miss_count
        number of misses (times files have been completely re-read)
    cC@sŽtj|ƒ|_|jjdƒ|_d|_d|_d|_d|_d|_	d|_
i|_||_tj|ƒ|_
||_dS(sICreate a hash cache in base dir, and set the file mode to mode.

        :param content_filter_stack_provider: a function that takes a
            path (relative to the top of the tree) and a file-id as
            parameters and returns a stack of ContentFilters.
            If None, no content filtering is performed.
        tutf8iN(Rtsafe_unicodetroottencodet	root_utf8t	hit_countt
miss_countt
stat_counttdanger_countt
removed_counttupdate_countt_cachet_modet_cache_file_namet_filter_provider(tselfR	tcache_file_nametmodetcontent_filter_stack_provider((s4/usr/lib/python2.7/dist-packages/bzrlib/hashcache.pyt__init__Ys									cC@s|jS(N(R(R((s4/usr/lib/python2.7/dist-packages/bzrlib/hashcache.pyRoscC@s"|jrt|_i|_ndS(sJDiscard all cached information.

        This does not reset the counters.N(RtTruetneeds_write(R((s4/usr/lib/python2.7/dist-packages/bzrlib/hashcache.pytclearrs		c	C@sΦg|jjƒD]#\}}|dd||f^q}|jƒxŒ|D]„\}}}tj|j|ƒ}|j|ƒ}|jd7_|d}|s©||krJ|jd7_t	|_
|j|=qJqJWdS(sΓScan all files and remove entries where the cache entry is obsolete.

        Obsolete entries are those where the file has been modified or deleted
        since the entry was inserted.
        iiN(Rt	iteritemstsortRtpathjoinR	t_fingerprintRRRR(	Rtpathtcetpreptinumtcache_entrytabspathtfptcache_fp((s4/usr/lib/python2.7/dist-packages/bzrlib/hashcache.pytscanzs9

	cC@sK|jtkr'tj|j|ƒ}ntj|j|ƒ}|jd7_|j||ƒ}|s›||jkr—|j	d7_	t
|_|j|=ndS||jkrΐ|j|\}}nd\}}||krλ|j
d7_
|S|jd7_|t}tj|ƒrX|jdkr+g}n|jd|ddƒ}|j||ƒ}	n[tj|ƒrštjtj|ƒƒ}
tj|
jdƒƒ}	ntjd||fƒ‚|jƒ}|t|ksί|t|kr|jd7_|rG|j	d7_	t
|_|j|=qGn+|jd7_t
|_|	|f|j|<|	S(s#Return the sha1 of a file.
        iR"tfile_idsUTF-8s#file %r: unknown file stat mode: %oN(NN( t	__class__tstrRR RR	RR!RRRRtNoneRR
tFP_MODE_COLUMNtstattS_ISREGRt_really_sha1_filetS_ISLNKtreadlinkRt
sha_stringR
RtBzrErrort_cutoff_timetFP_MTIME_COLUMNtFP_CTIME_COLUMNRR(RR"t
stat_valueR'tfile_fpt
cache_sha1R)RRtdigestttargettcutoff((s4/usr/lib/python2.7/dist-packages/bzrlib/hashcache.pytget_sha1’sR	

		
		cC@stj||ƒdS(s5Calculate the SHA1 of a file by reading the full texti(t_mod_filterstinternal_size_sha_file_byname(RR'R((s4/usr/lib/python2.7/dist-packages/bzrlib/hashcache.pyR2ήscC@sμtj|jƒdd|jƒ}zΉ|jtƒx’|jjƒD]\}}|jdƒd|ddg}|j	dj
g|dD]}t|ƒ^qƒƒƒ|j	dƒ|jd	j
|ƒƒqAW|jƒt
|_Wd
|jƒXd
S(s Write contents of cache to file.twbtnew_modesutf-8s// it is
tN(Rt
AtomicFileRRtwritetCACHE_HEADERRRR
tappendtjoinR-tcommittFalseRtclose(RtoutfR"tct	line_infotfld((s4/usr/lib/python2.7/dist-packages/bzrlib/hashcache.pyRHβs
3


cC@s«i|_|jƒ}yt|dddƒ}Wn0tk
r`}tjd||ƒt|_dSX|jƒ}|t	kr–tjd|ƒt|_dSxϋ|D]σ}|j
dƒ}|| jdƒ}||jkrλtjd	|ƒqn|d
7}||j
dƒ}t|ƒdkr1tjd
|ƒqn|d}	t|	ƒdkrdtjd|	ƒqnttt|dƒƒ}
|	|
f|j|<qW|jƒt|_dS(s›Reinstate cache from file.

        Overwrites existing cache.

        If the cache file has the wrong version marker, this just clears
        the cache.trbt	bufferingiθύsfailed to open %s: %sNs<cache header marker not found at top of %s; discarding caches// sutf-8sduplicated path %r in cacheiREisbad line in hashcache: %rii(sbad sha1 in hashcache: %ri(RRtfiletIOErrorRtmutterRRtreadlineRItindextdecodetwarningtsplittlenttupletmaptlongRNRM(RtfntinftethdrtltposR"tfieldstsha1R(((s4/usr/lib/python2.7/dist-packages/bzrlib/hashcache.pytreadχsB				



cC@sttjƒƒdS(sœReturn cutoff time.

        Files modified more recently than this time are at risk of being
        undetectably modified and so can't be cached.
        i(tintttime(R((s4/usr/lib/python2.7/dist-packages/bzrlib/hashcache.pyR7+scC@s|dkr7ytj|ƒ}Wq7tk
r3dSXntj|jƒrMdS|jt|j	ƒt|j
ƒ|j|j|jfS(N(
R.tostlstattOSErrorR0tS_ISDIRtst_modetst_sizeR`tst_mtimetst_ctimetst_inotst_dev(RR'R:((s4/usr/lib/python2.7/dist-packages/bzrlib/hashcache.pyR!3s
N(t__name__t
__module__t__doc__RMRR.RRRR*R@R2RHRiR7R!(((s4/usr/lib/python2.7/dist-packages/bzrlib/hashcache.pyR5s!			L			4	(t
__future__RRIRlR0RktbzrlibRRRRARRR8R9R/tobjectR(((s4/usr/lib/python2.7/dist-packages/bzrlib/hashcache.pyt<module>s(	

Copyright © 2017 || Recoded By Mr.Bumblebee