1000
  $   ˆÇÆÌ516Åa–ßi~” T¾R( 	ÅÝÀ3pS�ÿË     ‹      ½”Oo›0‡ïýž»ÁHÚu©aêB¤EK“(Í4MÓŽm‚U°‘í6ë>}M j6%ûsèN¼˜û÷¼“WÙ|´ú²£«›)Z|z?�Œ >÷G Ù*kÂ^0ža„çê!Àv»·ýP›¬–P¸ª€uF2rÇqzFš±ô‘BPî¯ˆ8éJ‘Nß‘Îè{g%ñ¾ ®+V(žËR„\T:,lÈ´®ý\3X[îéÔF3�—9­Ç .j¸c`¥$Ð®ç@�¬5l’Eÿ1…_l'O×»0MiRâ
ô@K¹Q	vºÆ)‘ÕYÃ’iea]RundŽ-]‚¿NFóožW4o§„¢Âˆ<ÁïFÉìjžd8�ÑJ Ç™Ï\ãtJ­C•æ2—‚Ÿ„o[øVþ8=aÖ2™°ÌÈÚI­žQðŠ‡ªL—¶¦ÞõÜæ�jþ§nPöS3×Ëñl•M–mKx3Åsº—ü¦8]P#”C™4‚9m;í6Ãkµ¶õÕþuRFn
‡S„t”ü‡NäºäÂöâT<ž‡ÜîŠÃœ¿‹{ñEEAüõ.†Ñ9B/hp¯î”ÞªC¿UŽ*ø¦‡RIœvÅïA¯±@QØ�N+¼‰?žVøËMÝïL`w¤h»'¶Tº.O       ˆÈÇÍ‚l@Æ¾Ë     ‹      ½”]o›0†ïû+<_ìHÒVMS*-ZšDi¦išvá`VÁF¶»¬ûõ3�¨Ù”ìã¢»ò|Þ÷õ}•.&ëOË[ôn}7CËogÓ	ÂÀÇá ]§Ý‡	#€Û9F¸t®l·[²m
X¯ tu5ëŒÌáŽãäŒ¶ï’3DKÁ¸uÒU"™*.¾!�#Ð�ÎJ.û¸®-X¡x.+A¸¨5)-É´n|®3X[íé4Fg¯r0Z;.ƒ¦là’ŒÚ‘o

]K/zt£ùS+.ú¿B|¿]l³ÓÓ–&¡®D_Y%c§œPYÈš,Æ 3­,l*¦H!sŒXåbüy:Y|ñ¸²ý;¡•Fä1~3‰ç×‹8ÅÉœÕ‚;ÎÜyæ'3fª5—¹ü$|ßÁ÷òûé	ÓŽI…ÍŒlœÔêoñÐj¦+Û0ïõÜ;(Í!Õ!üOi°ì§0–7«Ûù:�®ºHx;Å³º—\Vœ,™Ê¡T‘9mžzÛ�†×jc›ëý#êMY”'è(ùIäºâÂfq*�ç„{Á}q¨óaƒppDQ0¸BáÅ8:Gè<ª¥·êÐ‚ß*G-øÐ‰T'}ñ{Ã ¼
ÂŠÂq48má2zÚÂ_nZè�3…Ý­B¡»ò~ Š'Ù7U    6   ˆl–ßi~” T¾R( 	ÅÕÆÜ¸)‹Fÿ�þB gìÆûîF¿üÿÏƒh¹Î¿Ì      input:b0019v0000p0001e0000-e0,1,k74,ramlsfw
  7   ˆl–ßi~” T¾R( 	ÅÝÀ3pS�ÿ‘äÇò 8à_fA ²ÿŸÐƒh¹ÏÀÍ      input:b0010v001Fp0001e0100-e0,12,kramls1,2,fw
  B   ˆl–Ü4ý( ©”u( 	•íÀà™S�ÿ�þduÙVnQðÈ0„¤óÑ„m°¸ïÐ_ŠI|¥�+Wé3ž¯ÂÏ ?÷     # Copyright (C) 2006-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

"""Wire-level encoding and decoding of requests and responses for the smart
client and server.
"""


from collections import deque

from io import BytesIO
import struct
import sys
import _thread
import time

from fastbencode import bdecode_as_tuple, bencode

import breezy
from ... import (
    debug,
    errors,
    osutils,
    )
from . import message, request
from ...trace import log_exception_quietly, mutter


# Protocol version strings.  These are sent as prefixes of bzr requests and
# responses to identify the protocol version being used. (There are no version
# one strings because that version doesn't send any).
REQUEST_VERSION_TWO = b'bzr request 2\n'
RESPONSE_VERSION_TWO = b'bzr response 2\n'

MESSAGE_VERSION_THREE = b'bzr message 3 (bzr 1.6)\n'
RESPONSE_VERSION_THREE = REQUEST_VERSION_THREE = MESSAGE_VERSION_THREE


class SmartMessageHandlerError(errors.InternalBzrError):

    _fmt = ("The message handler raised an exception:\n"
            "%(traceback_text)s")

    def __init__(self, exc_info):
        import traceback
        # GZ 2010-08-10: Cycle with exc_tb/exc_info affects at least one test
        self.exc_type, self.exc_value, self.exc_tb = exc_info
        self.exc_info = exc_info
        traceback_strings = traceback.format_exception(
            self.exc_type, self.exc_value, self.exc_tb)
        self.traceback_text = ''.join(traceback_strings)


def _recv_tuple(from_file):
    req_line = from_file.readline()
    return _decode_tuple(req_line)


def _decode_tuple(req_line):
    if req_line is None or req_line == b'':
        return None
    if not req_line.endswith(b'\n'):
        raise errors.SmartProtocolError("request %r not terminated" % req_line)
    return tuple(req_line[:-1].split(b'\x01'))


def _encode_tuple(args):
    """Encode the tuple args to a bytestream."""
    for arg in args:
        if isinstance(arg, str):
            raise TypeError(