-=[ Mr. Bumblebee ]=-
_Indonesia_

Path : /usr/lib/python2.7/dist-packages/bzrlib/smart/
File Upload :
Current File : //usr/lib/python2.7/dist-packages/bzrlib/smart/request.pyc


5Qc@@s
dZddlmZddlZddlmZmZmZmZm	Z	m
Z
mZddlm
Z
e
edejZde_dZdZed	efd
YZdefdYZd
efdYZdefdYZdefdYZdZdefdYZdefdYZdefdYZejZ e j!ddddde j!dd d!dd"e j!d#d d$dd%e j!d&d d'dd%e j!d(d d)dd"e j!d*d d+dd%e j!d,d d-dd"e j!d.d d/dd%e j!d0d d1dd%e j!d2d d3dd%e j!d4d d5dd%e j!d6d d7dd8e j!d9d d:dd%e j!d;d d<dd"e j!d=d d>dd"e j!d?d d@dd"e j!dAd dBdd"e j!dCd dDdd"e j!dEd dFdd"e j!dGd dHdd8e j!dId dJdd%e j!dKdLdMdd%e j!dNdLdOdd%e j!dPdLdQdd8e j!dRdLdSdd8e j!dTdLdUdd%e j!dVdLdWdd%e j!dXdLdYdd%e j!dZdLd[dd%e j!d\dLd]dd%e j!d^dLd_dd8e j!d`dLdadd8e j!dbdLdcdd%e j!dddLdedd8e j!dfdLdgdd8e j!dhdLdidd%e j!djdLdkdd%e j!dldLdmdd%e j!dndLdodd%e j!dpdLdqdd%e j!drddsddte j!duddvdd%e j!dwdxddd%e j!dyddzdd%e j!d{dxddd%e j!d|dd}dd%e j!d~dddd%e j!dddddte j!dddddte j!ddddd"e j!ddddd"e j!ddddd%e j!dddddte j!ddddd"e j!ddddd%e j!ddddd"e j!ddddd"e j!ddddd%e j!ddddd%e j!ddddd%e j!ddddd%e j!ddddd%e j!ddddd%e j!ddddde j!ddddde j!ddddde j!ddddd%e j!ddddd%e j!ddddd8e j!ddddd%e j!ddddd"e j!ddddd8e j!ddddd%e j!ddddd%e j!ddddd%e j!ddddd%e j!ddddd%e j!ddddd"e j!ddddd8e j!ddddd8e j!ddddd8e j!ddddd%e j!ddddd"e j!ddddd%e j!ddddd%e j!ddddd%e j!dddddte j!ddddd%e j!ddxddd%dS(sInfrastructure for server-side request handlers.

Interesting module attributes:
    * The request_handlers registry maps verb names to SmartServerRequest
      classes.
    * The jail_info threading.local() object is used to prevent accidental
      opening of BzrDirs outside of the backing transport, or any other
      transports placed in jail_info.transports.  The jail_info is reset on
      every call into a request handler (which can happen an arbitrary number
      of times during a request).
i(tabsolute_importN(tdebugterrorstosutilstregistrytrevisionttraceturlutils(tlazy_imports_
from bzrlib import bzrdir
from bzrlib.bundle import serializer

import tempfile
import thread
cC@stjjjdtddS(Ntpre_openschecking server jail(tbzrdirtBzrDirthookstinstall_named_hookt_pre_open_hook(((s8/usr/lib/python2.7/dist-packages/bzrlib/smart/request.pyt
_install_hook=scC@s~ttdd}|dkr"dS|j}x=|D]5}y|j|Wntjk
rbq2q2XdSq2Wtj|dS(Nt
transports(tgetattrt	jail_infotNonetbasetrelpathRtPathNotChildt	JailBreak(t	transporttallowed_transportstabspathtallowed_transport((s8/usr/lib/python2.7/dist-packages/bzrlib/smart/request.pyRBs	
tSmartServerRequestcB@sweZdZdd
dZdZdZdZdZdZ	dZ
d	Zd
ZdZ
dZRS(sRBase class for request handlers.

    To define a new request, subclass this class and override the `do` method
    (and if appropriate, `do_body` as well).  Request implementors should take
    care to call `translate_client_path` and `transport_from_client_path` as
    appropriate when dealing with paths received from the client.
    t/cC@s||_|dkr|}n||_|dk	rn|jdsOd|}n|jdsn|d7}qnn||_g|_dS(shConstructor.

        :param backing_transport: the base transport to be used when performing
            this request.
        :param root_client_path: the client path that maps to the root of
            backing_transport.  This is used to interpret relpaths received
            from the client.  Clients will not be able to refer to paths above
            this root.  If root_client_path is None, then no translation will
            be performed on client paths.  Default is '/'.
        :param jail_root: if specified, the root of the BzrDir.open jail to use
            instead of backing_transport.
        RN(t_backing_transportRt
_jail_roott
startswithtendswitht_root_client_patht_body_chunks(tselftbacking_transporttroot_client_patht	jail_root((s8/usr/lib/python2.7/dist-packages/bzrlib/smart/request.pyt__init___s
			
	cC@sdS(s1Raises DisabledMethod if this method is disabled.N((R$((s8/usr/lib/python2.7/dist-packages/bzrlib/smart/request.pyt_check_enabledxscG@st|jdS(sMandatory extension point for SmartServerRequest subclasses.

        Subclasses must implement this.

        This should return a SmartServerResponse if this command expects to
        receive no body.
        N(tNotImplementedErrortdo(R$targs((s8/usr/lib/python2.7/dist-packages/bzrlib/smart/request.pyR+|scG@s|j|j|S(sPublic entry point to execute this request.

        It will return a SmartServerResponse if the command does not expect a
        body.

        :param args: the arguments of the request.
        (R)R+(R$R,((s8/usr/lib/python2.7/dist-packages/bzrlib/smart/request.pytexecutes
cC@s"|dkrtjdndS(sCalled if the client sends a body with the request.

        The do() method is still called, and must have returned None.

        Must return a SmartServerResponse.
        tsRequest does not expect a bodyN(RtSmartProtocolError(R$t
body_bytes((s8/usr/lib/python2.7/dist-packages/bzrlib/smart/request.pytdo_bodyscC@s|jj|dS(sCalled with each body chunk if the request has a streamed body.

        The do() method is still called, and must have returned None.
        N(R#tappend(R$tchunk_bytes((s8/usr/lib/python2.7/dist-packages/bzrlib/smart/request.pytdo_chunkscC@s(dj|j}d|_|j|S(s5Called when the end of the request has been received.R.N(tjoinR#RR1(R$R0((s8/usr/lib/python2.7/dist-packages/bzrlib/smart/request.pytdo_ends	cC@s|jgt_dS(N(RRR(R$((s8/usr/lib/python2.7/dist-packages/bzrlib/smart/request.pyt
setup_jailscC@s
dt_dS(N(RRR(R$((s8/usr/lib/python2.7/dist-packages/bzrlib/smart/request.pyt
teardown_jailscC@s|jdkr|S|jds/d|}n|d|jkrFdS|j|jr|t|j}tjd|}|jdst|ntjd|Stj	||jdS(sTranslate a path received from a network client into a local
        relpath.

        All paths received from the client *must* be translated.

        :param client_path: the path from the client.
        :returns: a relpath that may be used with self._backing_transport
            (unlike the untranslated client_path, which must not be used with
            the backing transport).
        Rt.N(
R"RR tlenRtjoinpatht
ValueErrortescapeRR(R$tclient_pathtpathR((s8/usr/lib/python2.7/dist-packages/bzrlib/smart/request.pyttranslate_client_paths
cC@s|j|}|jj|S(sGet a backing transport corresponding to the location referred to by
        a network client.

        :seealso: translate_client_path
        :returns: a transport cloned from self._backing_transport
        (R@Rtclone(R$R>R((s8/usr/lib/python2.7/dist-packages/bzrlib/smart/request.pyttransport_from_client_pathsN(t__name__t
__module__t__doc__RR(R)R+R-R1R4R6R7R8R@RB(((s8/usr/lib/python2.7/dist-packages/bzrlib/smart/request.pyRTs		
		
					tSmartServerResponsecB@s/eZdZdddZdZdZRS(sA response to a client request.

    This base class should not be used. Instead use
    SuccessfulSmartServerResponse and FailedSmartServerResponse as appropriate.
    cC@sI||_|dk	r3|dk	r3tjdn||_||_dS(sConstructor.

        :param args: tuple of response arguments.
        :param body: string of a response body.
        :param body_stream: iterable of bytestrings to be streamed to the
            client.
        s0'body' and 'body_stream' are mutually exclusive.N(R,RRtBzrErrortbodytbody_stream(R$R,RHRI((s8/usr/lib/python2.7/dist-packages/bzrlib/smart/request.pyR(s		cC@sD|dkrtS|j|jkoC|j|jkoC|j|jkS(N(RtFalseR,RHRI(R$tother((s8/usr/lib/python2.7/dist-packages/bzrlib/smart/request.pyt__eq__s
cC@sd|jj|j|jfS(Ns<%s args=%r body=%r>(t	__class__RCR,RH(R$((s8/usr/lib/python2.7/dist-packages/bzrlib/smart/request.pyt__repr__sN(RCRDRERR(RLRN(((s8/usr/lib/python2.7/dist-packages/bzrlib/smart/request.pyRFs	tFailedSmartServerResponsecB@seZdZdZRS(s1A SmartServerResponse for a request which failed.cC@stS(s-FailedSmartServerResponse are not successful.(RJ(R$((s8/usr/lib/python2.7/dist-packages/bzrlib/smart/request.pyt
is_successfuls(RCRDRERP(((s8/usr/lib/python2.7/dist-packages/bzrlib/smart/request.pyROstSuccessfulSmartServerResponsecB@seZdZdZRS(s;A SmartServerResponse for a successfully completed request.cC@stS(s-SuccessfulSmartServerResponse are successful.(tTrue(R$((s8/usr/lib/python2.7/dist-packages/bzrlib/smart/request.pyRPs(RCRDRERP(((s8/usr/lib/python2.7/dist-packages/bzrlib/smart/request.pyRQstSmartServerRequestHandlercB@sqeZdZddZdedZdZdZdZ	dZ
dZdZd	Z
d
ZRS(sProtocol logic for smart server.

    This doesn't handle serialization at all, it just processes requests and
    creates responses.
    cC@s||_||_||_|dkr0|}n||_d|_t|_d|_dt	j
krtj|_
tj|_ndS(sConstructor.

        :param backing_transport: a Transport to handle requests for.
        :param commands: a registry mapping command names to SmartServerRequest
            subclasses. e.g. bzrlib.transport.smart.vfs.vfs_commands.
        thpssN(RR"t	_commandsRRtresponseRJtfinished_readingt_commandRtdebug_flagsRt
timer_funct_request_start_timetthreadt	get_identt
_thread_id(R$R%tcommandsR&R'((s8/usr/lib/python2.7/dist-packages/bzrlib/smart/request.pyR(s								cC@s|r dtj|j}nd}|dkr;d}n?dt|d }t|dkrz|d |dd}ntjd	||j|||fdS(
Ns%5.3fs R.t i(i!iis...s%12s: [%s] %s%s%s(	RRZR[RtreprR:RtmutterR^(R$tactiontmessagetextra_bytestinclude_timetttextra((s8/usr/lib/python2.7/dist-packages/bzrlib/smart/request.pyt_trace,s		cC@se|jdkrdS|j|jj|fidtjkra|jddt|f|ndS(sAccept body data.NRTsaccept bodys%d bytes(RXRt_run_handler_codeR4RRYRiR:(R$tbytes((s8/usr/lib/python2.7/dist-packages/bzrlib/smart/request.pytaccept_body>s	cC@sN|j|jjdit|_dtjkrJ|jdddtndS(s#No more body data will be received.RTsend of bodyR.RfN((RjRXR6RRRWRRYRi(R$((s8/usr/lib/python2.7/dist-packages/bzrlib/smart/request.pytend_of_bodyHs	cC@s:|j|||}|dk	r6||_t|_ndS(s/Run some handler specific code 'callable'.

        If a result is returned, it is considered to be the commands response,
        and finished_reading is set true, and its assigned to self.response.

        Any exceptions caught are translated and a response object created
        from them.
        N(t_call_converting_errorsRRVRRRW(R$tcallableR,tkwargstresult((s8/usr/lib/python2.7/dist-packages/bzrlib/smart/request.pyRjPs		cC@syy3|jjz|||SWd|jjXWn?ttfk
rOn&tk
rt}t|}t|SXdS(s4Call callable converting errors to Response objects.N(RXR7R8tKeyboardInterruptt
SystemExitt	Exceptiont_translate_errorRO(R$RoR,Rpterrt
err_struct((s8/usr/lib/python2.7/dist-packages/bzrlib/smart/request.pyRn_s
cC@s,dtjkr(|jdt|ndS(NRTtheaders(RRYRiRa(R$Rx((s8/usr/lib/python2.7/dist-packages/bzrlib/smart/request.pytheaders_receivedoscC@s$|d}|d}y|jj|}WnRtk
r~dtjkrl|jd|t|dd!ntj|nXdtjkrddl	m
}t||jrd}nd}|j|d	|t|dd!fn||j
|j|j|_|j|jj|idS(
NiiRTshpss unknown requesti(tvfsshpss vfs reqshpss requests%s %s(RUtgettLookupErrorRRYRiRaRtUnknownSmartMethodtbzrlib.smartRzt
issubclasst
VfsRequestRR"RRXRjR-(R$R,tcmdtcommandRzRc((s8/usr/lib/python2.7/dist-packages/bzrlib/smart/request.pyt
args_receivedts&


			!cC@sX|jdkrdS|j|jjdidtjkrT|jdddtndS(NRTtendR.Rf((RXRRjR6RRYRiRR(R$((s8/usr/lib/python2.7/dist-packages/bzrlib/smart/request.pytend_receiveds
cC@sdS(N((R$t
error_args((s8/usr/lib/python2.7/dist-packages/bzrlib/smart/request.pytpost_body_error_receivedsN(RCRDRERR(RJRiRlRmRjRnRyRRR(((s8/usr/lib/python2.7/dist-packages/bzrlib/smart/request.pyRSs
	
						cC@st|tjrd|jfSt|tjr>d|jfSt|tjr]d|jfSt|tjrdt|jt|j	t|j
fSt|tjrd|jt|jt|j
t|jfSt|tjrd|j|jfSt|tjr-dt|j|jfSt|tjrXdt|j|jfSt|tjrndSt|tjrd
|jfSt|tr|j}t|trd|jd}nd
|jd}|jj|j|t|j t|j!|j"fSt|tj#r9|jdkrdSnt|tj$rXd|jfSt|tj%r}d|j|j&fSt|tj'rd|j(|j)fSt|tj*rdSt|t+rdSt,j-dt,j.|jt/t|fS(Nt
NoSuchFilet
FileExiststDirectoryNotEmptytIncompatibleRepositoriestShortReadvErrortRevisionNotPresenttUnstackableRepositoryFormattUnstackableBranchFormatt
NotStackedt
BzrCheckErrorsu:sutf-8ss:tbase64sreadonly transportt
ReadOnlyErrort	ReadErrortPermissionDeniedt
TokenMismatchtLockContentiontMemoryErrorterror(s
NotStacked(R(sLockContention(sMemoryError(0t
isinstanceRRR?RRRtstrtsourcettargettdetailsRtoffsettlengthtactualRtrevision_idtfile_idRtformatturlRRRtmsgtUnicodeErrortobjecttunicodetencodeRMRCtencodingtstartRtreasontTransportNotPossibleRRRhRtgiven_tokent
lock_tokenRRRtlog_exception_quietlyt_qualified_exception_nameRR(Rvtstr_or_unicodetval((s8/usr/lib/python2.7/dist-packages/bzrlib/smart/request.pyRusZ


!
	

tHelloRequestcB@seZdZdZRS(sYAnswer a version request with the highest protocol version this server
    supports.
    cC@s
tdS(Ntokt2(sokR(RQ(R$((s8/usr/lib/python2.7/dist-packages/bzrlib/smart/request.pyR+s(RCRDRER+(((s8/usr/lib/python2.7/dist-packages/bzrlib/smart/request.pyRstGetBundleRequestcB@seZdZdZRS(sAGet a bundle of from the null revision to the specified revision.c	C@s~|j|}tjj|\}}|j}tj}tj}t	j
|||||jdtd|j
S(Ni((RBR
Rtopen_containing_from_transporttopen_repositoryttempfilet
TemporaryFileRt
NULL_REVISIONt
serializertwrite_bundletseekRQtread(	R$R?RRgtcontrolt
extra_pathtrepottmpft
base_revision((s8/usr/lib/python2.7/dist-packages/bzrlib/smart/request.pyR+s	
(RCRDRER+(((s8/usr/lib/python2.7/dist-packages/bzrlib/smart/request.pyRstSmartServerIsReadonlycB@seZdZRS(cC@s+|jjrd}nd}t|fS(Ntyestno(Rtis_readonlyRQ(R$tanswer((s8/usr/lib/python2.7/dist-packages/bzrlib/smart/request.pyR+s	(RCRDR+(((s8/usr/lib/python2.7/dist-packages/bzrlib/smart/request.pyRsR2sbzrlib.smart.vfst
AppendRequesttinfotmutatesBranch.break_locksbzrlib.smart.branchtSmartServerBranchBreakLocktidemsBranch.get_config_filetSmartServerBranchGetConfigFileRsBranch.get_parenttSmartServerBranchGetParentsBranch.put_config_filetSmartServerBranchPutConfigFilesBranch.get_tags_bytestSmartServerBranchGetTagsBytessBranch.set_tags_bytestSmartServerBranchSetTagsBytessBranch.heads_to_fetchtSmartServerBranchHeadsToFetchsBranch.get_stacked_on_urlt'SmartServerBranchRequestGetStackedOnURLsBranch.get_physical_lock_statust-SmartServerBranchRequestGetPhysicalLockStatussBranch.last_revision_infot(SmartServerBranchRequestLastRevisionInfosBranch.lock_writet!SmartServerBranchRequestLockWritetsemisBranch.revision_historyt!SmartServerRequestRevisionHistorysBranch.set_config_optiont'SmartServerBranchRequestSetConfigOptionsBranch.set_config_option_dictt+SmartServerBranchRequestSetConfigOptionDictsBranch.set_last_revisiont'SmartServerBranchRequestSetLastRevisionsBranch.set_last_revision_infot+SmartServerBranchRequestSetLastRevisionInfosBranch.set_last_revision_ext)SmartServerBranchRequestSetLastRevisionExsBranch.set_parent_locationt)SmartServerBranchRequestSetParentLocations
Branch.unlocktSmartServerBranchRequestUnlocksBranch.revision_id_to_revnot)SmartServerBranchRequestRevisionIdToRevnosBzrDir.checkout_metadirsbzrlib.smart.bzrdirt'SmartServerBzrDirRequestCheckoutMetaDirsBzrDir.cloning_metadirt&SmartServerBzrDirRequestCloningMetaDirsBzrDir.create_branchtSmartServerRequestCreateBranchsBzrDir.create_repositoryt"SmartServerRequestCreateRepositorysBzrDir.find_repositoryt"SmartServerRequestFindRepositoryV1sBzrDir.find_repositoryV2t"SmartServerRequestFindRepositoryV2sBzrDir.find_repositoryV3t"SmartServerRequestFindRepositoryV3sBzrDir.get_branchest#SmartServerBzrDirRequestGetBranchessBzrDir.get_config_filet"SmartServerBzrDirRequestConfigFilesBzrDir.destroy_brancht%SmartServerBzrDirRequestDestroyBranchsBzrDir.destroy_repositoryt)SmartServerBzrDirRequestDestroyRepositorysBzrDir.has_workingtreet&SmartServerBzrDirRequestHasWorkingTreesBzrDirFormat.initializet"SmartServerRequestInitializeBzrDirsBzrDirFormat.initialize_ex_1.16t$SmartServerRequestBzrDirInitializeExsBzrDir.opentSmartServerRequestOpenBzrDirsBzrDir.open_2.1t SmartServerRequestOpenBzrDir_2_1sBzrDir.open_branchtSmartServerRequestOpenBranchsBzrDir.open_branchV2tSmartServerRequestOpenBranchV2sBzrDir.open_branchV3tSmartServerRequestOpenBranchV3tdeletet
DeleteRequesttsemivfsR{t
GetRequestt
get_bundlesbzrlib.smart.requestthast
HasRequestthellotiter_files_recursivetIterFilesRecursiveRequesttlist_dirtListDirRequesttmkdirtMkdirRequesttmovetMoveRequesttputt
PutRequesttput_non_atomictPutNonAtomicRequesttreadvtReadvRequesttrenamet
RenameRequestsRepository.add_signature_textsbzrlib.smart.repositoryt%SmartServerRepositoryAddSignatureTextsRepository.all_revision_idst#SmartServerRepositoryAllRevisionIdssPackRepository.autopacksbzrlib.smart.packrepositoryt!SmartServerPackRepositoryAutopacksRepository.break_locktSmartServerRepositoryBreakLocksRepository.gather_statst SmartServerRepositoryGatherStatssRepository.get_parent_mapt!SmartServerRepositoryGetParentMapsRepository.get_revision_grapht%SmartServerRepositoryGetRevisionGraphs&Repository.get_revision_signature_textt-SmartServerRepositoryGetRevisionSignatureTextsRepository.has_revisiontSmartServerRequestHasRevisions(Repository.has_signature_for_revision_idt+SmartServerRequestHasSignatureForRevisionIdsRepository.insert_streamt!SmartServerRepositoryInsertStreamtstreamsRepository.insert_stream_1.19t&SmartServerRepositoryInsertStream_1_19sRepository.insert_stream_lockedt'SmartServerRepositoryInsertStreamLockedsRepository.is_sharedtSmartServerRepositoryIsSharedsRepository.iter_files_bytest#SmartServerRepositoryIterFilesBytessRepository.lock_writetSmartServerRepositoryLockWritesRepository.make_working_treest%SmartServerRepositoryMakeWorkingTreess!Repository.set_make_working_treest(SmartServerRepositorySetMakeWorkingTreessRepository.unlocktSmartServerRepositoryUnlocks#Repository.get_physical_lock_statust*SmartServerRepositoryGetPhysicalLockStatussRepository.get_rev_id_for_revnot%SmartServerRepositoryGetRevIdForRevnosRepository.get_streamtSmartServerRepositoryGetStreamsRepository.get_stream_1.19t#SmartServerRepositoryGetStream_1_19sRepository.iter_revisionst"SmartServerRepositoryIterRevisionssRepository.packtSmartServerRepositoryPacksRepository.start_write_groupt$SmartServerRepositoryStartWriteGroupsRepository.commit_write_groupt%SmartServerRepositoryCommitWriteGroupsRepository.abort_write_groupt$SmartServerRepositoryAbortWriteGroupsRepository.check_write_groupt$SmartServerRepositoryCheckWriteGroupsRepository.reconciletSmartServerRepositoryReconcilesRepository.tarballtSmartServerRepositoryTarballs-VersionedFileRepository.get_serializer_formatt(SmartServerRepositoryGetSerializerFormats'VersionedFileRepository.get_inventoriest#SmartServerRepositoryGetInventoriestrmdirtRmdirRequesttstattStatRequestsTransport.is_readonly("REt
__future__Rt	threadingtbzrlibRRRRRRRtbzrlib.lazy_importRtglobalstlocalRRRRRRRRFRORQRSRuRRRtRegistrytrequest_handlerst
register_lazy(((s8/usr/lib/python2.7/dist-packages/bzrlib/smart/request.pyt<module>s"4					"	:	#







































































Copyright © 2017 || Recoded By Mr.Bumblebee