       0        0        0        0        0        0        0        0        0        0        0        0        0        0        0        0        0
  $   	H403239_•I|¥‰ÓMjqØ‚¦ ë<óo¬ÈÇ  ï    	<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html><head>
<title>403 Forbidden</title>
</head><body>
<h1>Forbidden</h1>
<p>You don't have permission to access this resource.</p>
</body></html>
      ˆÀ‘äÇò 8à_Ú‚t2?Ëƒh¹ÊÈÇ      0
  B   ˆl–Ü4ý( ©”u( 	•íÀà™S�ÿ�þD2‘fåƒJ@?Ì„yïË_ŠI|¥�+Wé3ž¯ÊÉ *ì    # Copyright (C) 2005-2010 Canonical Ltd
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA

# TODO: Up-front, stat all files in order and remove those which are deleted or
# out-of-date.  Don't actually re-read them until they're needed.  That ought
# to bring all the inodes into core so that future stats to them are fast, and
# it preserves the nice property that any caller will always get up-to-date
# data except in unavoidable cases.

# TODO: Perhaps return more details on the file to avoid statting it
# again: nonexistent, file type, size, etc

# TODO: Perhaps use a Python pickle instead of a text file; might be faster.


CACHE_HEADER = b"### bzr hashcache v5\n"

import os
import stat
import time

from .. import (
    atomicfile,
    errors,
    filters as _mod_filters,
    osutils,
    trace,
    )


FP_MTIME_COLUMN = 1
FP_CTIME_COLUMN = 2
FP_MODE_COLUMN = 5


class HashCache:
    """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)
    """
    needs_write = False

    def __init__(self, root, cache_file_name, mode=None,
                 content_filter_stack_provider=None):
        """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.
        """
        if not isinstance(root, str):
            raise ValueError("Base dir for hashcache must be text")
        self.root = root
        self.hit_count = 0
        self.miss_count = 0
        self.stat_count = 0
        self.danger_count = 0
        self.removed_count = 0
        self.update_count = 0
        self._cache = 