File: //kunden/lib/python3/dist-packages/breezy/__pycache__/hashcache.cpython-39.pyc
a
�*�^a+ � @ st d dl mZ dZd dlZd dlZd dlZddlmZmZm Z
mZmZ ddl
mZmZ dZdZdZG d d
� d
e�ZdS )� )�absolute_imports ### bzr hashcache v5
N� )�
atomicfile�errors�filters�osutils�trace)� text_type� viewitems� � c @ sj e Zd ZdZdZddd�Zdd� Zdd � Zd
d� Zddd
�Z dd� Z
dd� Zdd� Zdd� Z
ddd�ZdS )� HashCachea{ 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)
FNc C sX t |t�std��|| _d| _d| _d| _d| _d| _d| _ i | _
|| _|| _|| _
dS )aI Create 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.
z#Base dir for hashcache must be textr N)�
isinstancer �
ValueError�root� hit_count�
miss_count�
stat_count�danger_count�
removed_count�update_count�_cache�_mode�_cache_file_name�_filter_provider)�selfr �cache_file_name�modeZcontent_filter_stack_provider� r �2/usr/lib/python3/dist-packages/breezy/hashcache.py�__init__[ s
zHashCache.__init__c C s | j S �N)r �r r r r r r s zHashCache.cache_file_namec C s | j rd| _i | _ dS )zJDiscard all cached information.
This does not reset the counters.TN)r �needs_writer"