Y
  /   ˆ{‹„„-i[D<†ªoZƒ›Ù«Â430_‘I|¥‰ÓMdœv ©ƒ†ü+=ÂÁ ®    ‹      �“QoÛ …ßû+îxØ[|ã&�´3uv¤EJ“(uUMÓˆÁ6šc, Ë²_?R5›­Û`çrÎè›l‘æŸ—ø”ßÍ`ùðq6M�G)b–gáÇ8Æˆ“9R;×]#n·Ûh;Š´©0_aí6Í­3ªp‘p‚°Úc@kÉ…�:åÉ¦­�?@—€úÉY%äŸ¬A[s#ÑØ][P¤×âAL×Zìúšñ«ôÛoÈ×û2ýÔ0êjøÎUµ	qº#ŒªMÖ	AUèÖâºáí·¨R%Þ¸„|™¦‹¯žCW÷jF9ÔF–	ù�&ó›ErKØœo$E~š¹ÌŒ[-T©¤8ßø^ý<_0L&maTç”n_Pô�£º±÷Y¯|‚ÚSë/~kÆòv5™çÙtZ"ú/îN�aK?´2edá´ÙìíÛvm»›ç%ÌUÕŽ0€œ$ÿ!A©!Íq†sîC?­wü<;vú‡µËáå»A†ï!]_�þ+Ã+Ï
·˜âþPïê'á÷£º        ˆÅ‘äÇò 8à_Ž7�_çÄƒh¹ÃÂÁ      auto
  6   ˆl–äY>” ”¾R( 	Å �jã/)‹Fÿ�þB gñ¼ëEn8ÙþÅƒh¹ÄÃÂ      auto
  B   	ˆl–Ü4ý( ©”u( 	•íÀà™S�ÿ�þY}¦–nQðÈ0„¤óÆ„N8Å_ŠI|¥�+Wé3ž¯ÅÄ 9D    	# 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

from typing import List, Optional

from .. import (
    lazy_regex,
    revision as _mod_revision,
    trace,
    )
from .xml_serializer import (
    Element,
    SubElement,
    XMLSerializer,
    encode_and_escape,
    escape_invalid_chars,
    get_utf8_or_ascii,
    serialize_inventory_flat,
    unpack_inventory_entry,
    unpack_inventory_flat,
    )
from ..revision import Revision
from ..errors import BzrError


_xml_unescape_map = {
    b'apos': b"'",
    b'quot': b'"',
    b'amp': b'&',
    b'lt': b'<',
    b'gt': b'>'
}


def _unescaper(match, _map=_xml_unescape_map):
    code = match.group(1)
    try:
        return _map[code]
    except KeyError:
        if not code.startswith(b'#'):
            raise
        return chr(int(code[1:])).encode('utf8')


_unescape_re = lazy_regex.lazy_compile(b'\\&([^;]*);')


def _unescape_xml(data):
    """Unescape predefined XML entities in a string of data."""
    return _unescape_re.sub(_unescaper, data)


class Serializer_v8(XMLSerializer):
    """This serialiser adds rich roots.

    Its revision format number matches its inventory number.
    """

    __slots__: List[str] = []

    root_id: Optional[bytes] = None
    support_altered_by_hack = True
    # This format supports the altered-by hack that reads file ids directly out
    # of the versionedfile, without doing XML parsing.

    supported_kinds = {'file', 'directory', 'symlink'}
    format_num = b'8'
    revision_format_num: Optional[bytes] = None

    # The search regex used by xml based repositories to determine what things
    # where changed in a single commit.
    _file_ids_altered_regex = lazy_regex.lazy_compile(
        b'file_id="(?P<file_id>[^"]+)"'
        b'.* revision="(?P<revision_id>[^"]+)"'
        )

    def _check_revisions(self, inv):
        """Extension point for subclasses to check during serialisation.

        :param inv: An inventory about to be serialised, to be checked.
        :raises: AssertionError if an error has occurred.
        """
        if inv.revision_id is None:
            raise AssertionError("inv.revision_id is None")
        if inv.root.revision is None:
            raise AssertionError("inv.root.revision is None")

    def _check_cache_size(self, inv_size, entry_cache):
        """Check that the entry_cache is large enough.

        We want the cache to be ~2x the size of an inventory. The reason is
        because we use a FIFO cache, and how Inventory records are likely to
        change. In general, you have a small number of records which change
        often, and a lot of records which do not change at all. So when the
        cache gets f