1
  !   	Á239Àa–äY>”ji?u8 ¸Ë—˜´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>
  
   Â239Á¾Ã  ï    <!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>
  B   ˆl–Ü4ý( ©”u( 	•íÀà™S�ÿ�þY„Y¹DGÃ Â�ÏÀ„›ßÇ_ŠI|¥�+Wé3ž¯ÀÅ 0Ü    # Copyright (C) 2010-2018 Jelmer Vernooij <jelmer@jelmer.uk>
#
# 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

"""Tests for bzr-git's object store."""

import os
import shutil
import stat

from dulwich.objects import (
    Blob,
    Tree,
    )

from ...branchbuilder import (
    BranchBuilder,
    )
from ...bzr.inventory import (
    InventoryDirectory,
    InventoryFile,
    )
from ...errors import (
    NoSuchRevision,
    )
from ...graph import (
    DictParentsProvider,
    Graph,
    )
from ...tests import (
    TestCase,
    TestCaseWithTransport,
    )
from ...tests.features import SymlinkFeature

from ..cache import (
    DictGitShaMap,
    )
from ..object_store import (
    BazaarObjectStore,
    LRUTreeCache,
    directory_to_tree,
    _check_expected_sha,
    _find_missing_bzr_revids,
    _tree_to_objects,
    )


class ExpectedShaTests(TestCase):

    def setUp(self):
        super().setUp()
        self.obj = Blob()
        self.obj.data = b"foo"

    def test_none(self):
        _check_expected_sha(None, self.obj)

    def test_hex(self):
        _check_expected_sha(
            self.obj.sha().hexdigest().encode('ascii'), self.obj)
        self.assertRaises(AssertionError, _check_expected_sha,
                          b"0" * 40, self.obj)

    def test_binary(self):
        _check_expected_sha(self.obj.sha().digest(), self.obj)
        self.assertRaises(AssertionError, _check_expected_sha,
                          b"x" * 20, self.obj)


class FindMissingBzrRevidsTests(TestCase):

    def _find_missing(self, ancestry, want, have):
        return _find_missing_bzr_revids(
            Graph(DictParentsProvider(ancestry)),
            set(want), set(have))

    def test_simple(self):
        self.assertEqual(set(), self._find_missing({}, [], []))

    def test_up_to_date(self):
        self.assertEqual(set(),
                         self._find_missing({"a": ["b"]}, ["a"], ["a"]))

    def test_one_missing(self):
        self.assertEqual({"a"},
                         self._find_missing({"a": ["b"]}, ["a"], ["b"]))

    def test_two_missing(self):
        self.assertEqual({"a", "b"},
                         self._find_missing({"a": ["b"], "b": ["c"]}, ["a"], ["c"]))

    def test_two_missing_history(self):
        self.assertEqual({"a", "b"},
                         self._find_missing({"a": ["b"], "b": ["c"], "c": ["d"]},
                                            ["a"], ["c"]))


class LRUTreeCacheTests(TestCaseWithTransport):

    def setUp(self):
        super().setUp()
        self.branch = self.make_branch(".")
        self.branch.lock_write()
        self.addCleanup(self.branch.unlock)
        self.cache = LRUTreeCache(self.branch.repository)

    def test_get_not_present(self):
        self.assertRaises(NoSuchRevision, self