-=[ Mr. Bumblebee ]=-
_Indonesia_

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


džHPc@@s?dZddlmZddlZddlZddlZddlZddlZddlZddl	Z	ddl
mZmZm
Z
mZmZmZmZmZmZmZddlmZddlmZmZmZddlmZmZddl
mZ dd	l!m"Z"m#Z#m$Z$d
efdYZ%de%fd
YZ&de%fdYZ'dZ(de%fdYZ)de&fdYZ*de&fdYZ+de%fdYZ,de%fdYZ-de%fdYZ.de%fdYZ/de%fdYZ0d e%fd!YZ1d"e%fd#YZ2d$e%fd%YZ3d&e%fd'YZ4d(e4fd)YZ5d*Z6d+e7fd,YZ8dd-Z:d.e%fd/YZ;d0e%fd1YZ<d2e%fd3YZ=d4e%fd5YZ>d6e%fd7YZ?d8e?fd9YZ@d:e?fd;YZAd<e%fd=YZBd>e%fd?YZCd@e%fdAYZDdBe%fdCYZEdDe%fdEYZFdFe%fdGYZGdHe%fdIYZHdJe%fdKYZIdLe%fdMYZJdNe%fdOYZKdPe%fdQYZLdS(Rs7Server-side repository related request implementations.i(tabsolute_importN(
tbencodeterrorstestimate_compressed_sizet	inventorytinventory_deltatosutilstpackttracetuit	vf_search(tBzrDir(tFailedSmartServerResponsetSmartServerRequesttSuccessfulSmartServerResponse(t_strip_NULL_ghoststnetwork_format_registry(trevision(tChunkedContentFactorytNetworkRecordStreamtrecord_to_fulltext_bytestSmartServerRepositoryRequestcB@s8eZdZdZdZedZedZRS(s*Common base class for Repository requests.cG@s@|j|}tj|}|j|_|j|j|S(sExecute a repository request.

        All Repository requests take a path to the repository as their first
        argument.  The repository must be at the exact path given by the
        client - no searching is done.

        The actual logic is delegated to self.do_repository_request.

        :param client_path: The path for the repository as received from the
            client.
        :return: A SmartServerResponse from self.do_repository_request().
        (ttransport_from_client_pathRtopen_from_transporttopen_repositoryt_repositorytdo_repository_request(tselftpathtargst	transporttbzrdir((s;/usr/lib/python2.7/dist-packages/bzrlib/smart/repository.pytdo;s
cG@sdS(s1Override to provide an implementation for a verb.N(tNone(Rt
repositoryR((s;/usr/lib/python2.7/dist-packages/bzrlib/smart/repository.pyRNscC@s|dkrtj|d	fS|jd}|ddkrd|d}tj||}|d	fS|ddkr|j||dd|Sd	td
fSd	S(sJRecreate a search from its serialised form.

        :param discard_excess: If True, and the search refers to data we don't
            have, just silently accept that fact - the verb calling
            recreate_search trusts that clients will look for missing things
            they expected and get it from elsewhere.
        t
everythings
isancestry-ofitsearchtdiscard_excesst	BadSearchN(R&(R
tEverythingResultR!tsplittPendingAncestryResulttrecreate_search_from_recipeR(RR"tsearch_bytesR%tlinestheadst
search_result((s;/usr/lib/python2.7/dist-packages/bzrlib/smart/repository.pytrecreate_searchTs

c
C@s%t|djd}t|djd}t|d}|jz|jj|}xEtry|j}Wntk
rPnX|j	|j
|qgW|j\}	}
}|rt||krdtdfStj|	|
t||}|dfSWd|jXdS(sZRecreate a specific revision search (vs a from-tip search).

        :param discard_excess: If True, and the search refers to data we don't
            have, just silently accept that fact - the verb calling
            recreate_search trusts that clients will look for missing things
            they expected and get it from elsewhere.
        it iitNoSuchRevisionN(sNoSuchRevision(tsetR(tintt	lock_readt	get_grapht_make_breadth_first_searchertTruetnextt
StopIterationtstop_searching_anytintersectiont	get_statetlenR!RR
tSearchResulttunlock(
RR"R,R%t
start_keystexclude_keystrevision_countR$t	next_revststarted_keystexcludest
included_keysR.((s;/usr/lib/python2.7/dist-packages/bzrlib/smart/repository.pyR*is(	
		
(t__name__t
__module__t__doc__R RtFalseR/R*(((s;/usr/lib/python2.7/dist-packages/bzrlib/smart/repository.pyR8s
		tSmartServerRepositoryReadLockedcB@seZdZdZRS(s,Calls self.do_readlocked_repository_request.cG@s0|jz|j||SWd|jXdS(s<Read lock a repository for do_readlocked_repository_request.N(R4t do_readlocked_repository_requestR?(RR"R((s;/usr/lib/python2.7/dist-packages/bzrlib/smart/repository.pyRs
(RGRHRIR(((s;/usr/lib/python2.7/dist-packages/bzrlib/smart/repository.pyRKstSmartServerRepositoryBreakLockcB@seZdZdZRS(sBreak a repository lock.cC@s|jtdS(Ntok(sok(t
break_lockR(RR"((s;/usr/lib/python2.7/dist-packages/bzrlib/smart/repository.pyRs
(RGRHRIR(((s;/usr/lib/python2.7/dist-packages/bzrlib/smart/repository.pyRMst!SmartServerRepositoryGetParentMapcB@s;eZdZeZdZdZddZdZRS(s?Bzr 1.2+ - get parent data for revisions during a graph search.cG@s
||_dS(sGet parent details for some revisions.

        All the parents for revision_ids are returned. Additionally up to 64KB
        of additional parent data found by performing a breadth first search
        from revision_ids is returned. The verb takes a body containing the
        current search state, see do_body for details.

        If 'include-missing:' is in revision_ids, ghosts encountered in the
        graph traversal for getting parent data are included in the result with
        a prefix of 'missing:'.

        :param repository: The repository to query in.
        :param revision_ids: The utf8 encoded revision_id to answer for.
        N(t
_revision_idsR!(RR"trevision_ids((s;/usr/lib/python2.7/dist-packages/bzrlib/smart/repository.pyRs	cC@s6|j}|jz|j|SWd|jXdS(s?Process the current search state and perform the parent lookup.

        :return: A smart server response where the body contains an utf8
            encoded flattened list of the parents of the revisions (the same
            format as Repository.get_revision_graph) which has been bz2
            compressed.
        N(RR4t_do_repository_requestR?(Rt
body_bytesR"((s;/usr/lib/python2.7/dist-packages/bzrlib/smart/repository.pytdo_bodys
	
icC@si}t}tj|}|}	t}
xT|	r|j|	|j|	}|	}t}	x|D]}
t}|j|
}|dk	r|tj	fkrd}n|	j||
}nt
}d|
}g}|
|kre|s|re|||<d|dj|f}|j|qeqeW|j
s>|
rh|jrhtjd|j|jft}	Pn|	j|}	t
}
q-W|S(Nsmissing:s%s %s
R0ssize: %d, z_size: %d((R2Rt
ZLibEstimatorRJtupdatetget_parent_maptgetR!t
_mod_revisiont
NULL_REVISIONR7tjointadd_contenttno_extra_resultstfullRtmuttert_uncompressed_size_addedt_compressed_size_addedt
difference(Rt
repo_graphRRtclient_seen_revstinclude_missingtmax_sizetresulttqueried_revst	estimatorRCtfirst_loop_donet
parent_maptcurrent_revstrevision_idtmissing_revtparentst
encoded_idtline((s;/usr/lib/python2.7/dist-packages/bzrlib/smart/repository.pyt_expand_requested_revssF		
	
	
	


		
cC@s|j}t|j}d|k}|r:|jdn|jd}|j||\}}|dk	rq|St|j}|j||j	}	|j
|	|||}
g}xCt|
jD]/\}}
|j
dj|ft|
qWtdtjdj|S(Nsinclude-missing:s
R0RN(sok(RR2RQtremoveR(R*R!tget_keystdifference_updateR5RstsortedtitemstappendR\ttupleRtbz2tcompress(RRTR"RRRft
body_linesR.terrorReRdRhR,RRp((s;/usr/lib/python2.7/dist-packages/bzrlib/smart/repository.pyRSs(	
'(	RGRHRIRJR^RRURsRS(((s;/usr/lib/python2.7/dist-packages/bzrlib/smart/repository.pyRPs		0t%SmartServerRepositoryGetRevisionGraphcB@seZdZRS(cC@s|sd}ng}|j}|r3|g}n|j}|j|}t}t|jt||j|}t	|}	|r||	krt
d|fdSx=|	jD]/\}
}|jdj
|
ft|qWtddj
|S(sReturn the result of repository.get_revision_graph(revision_id).

        Deprecated as of bzr 1.4, but supported for older clients.

        :param repository: The repository to query in.
        :param revision_id: The utf8 encoded revision_id to get a graph from.
        :return: A smart server response where the body contains an utf8
            encoded flattened list of the revision graph.
        tnosuchrevisiontR0RNs
N(sok(R!R5tall_revision_idsR6R2tmapRWtlistRXRRRxRyR\RzR(RR"RnR,tgrapht
search_idsR$ttransitive_idsRltrevision_graphRRp((s;/usr/lib/python2.7/dist-packages/bzrlib/smart/repository.pyRLs"
		'(RGRHRL(((s;/usr/lib/python2.7/dist-packages/bzrlib/smart/repository.pyRst%SmartServerRepositoryGetRevIdForRevnocB@seZdZRS(c	C@sy|j||\}}WnOtjk
rm}|j|dkrZtd|jntd|jfSX|rtd|fS|\}}td||fSdS(shFind the revid for a given revno, given a known revno/revid pair.
        
        New in 1.17.
        isIget_rev_id_for_revno raised RevisionNotPresent for non-initial revision: RRNshistory-incompleteN(tget_rev_id_for_revnoRtRevisionNotPresentRntAssertionErrorRR(	RR"trevnot
known_pairt
found_flagRhterrtearliest_revnotearliest_revid((s;/usr/lib/python2.7/dist-packages/bzrlib/smart/repository.pyRLBs(RGRHRL(((s;/usr/lib/python2.7/dist-packages/bzrlib/smart/repository.pyR@st(SmartServerRepositoryGetSerializerFormatcB@seZdZRS(cC@s|j}td|fS(sReturn the serializer format for this repository.

        New in 2.5.0.

        :param repository: The repository to query
        :return: A smart server response ('ok', FORMAT)
        RN(tget_serializer_formatR(RR"t
serializer((s;/usr/lib/python2.7/dist-packages/bzrlib/smart/repository.pyR[s(RGRHR(((s;/usr/lib/python2.7/dist-packages/bzrlib/smart/repository.pyRYstSmartServerRequestHasRevisioncB@seZdZRS(cC@s'|j|rtdStdSdS(s<Return ok if a specific revision is in the repository at path.

        :param repository: The repository to query in.
        :param revision_id: The utf8 encoded revision_id to lookup.
        :return: A smart server response of ('yes', ) if the revision is
            present. ('no', ) if it is missing.
        tyestnoN(syes(sno(thas_revisionR(RR"Rn((s;/usr/lib/python2.7/dist-packages/bzrlib/smart/repository.pyRis
(RGRHR(((s;/usr/lib/python2.7/dist-packages/bzrlib/smart/repository.pyRgst+SmartServerRequestHasSignatureForRevisionIdcB@seZdZRS(cC@sOy'|j|rtdStdSWn!tjk
rJtd|fSXdS(soReturn ok if a signature is present for a revision.

        Introduced in bzr 2.5.0.

        :param repository: The repository to query in.
        :param revision_id: The utf8 encoded revision_id to lookup.
        :return: A smart server response of ('yes', ) if a
            signature for the revision is present,
            ('no', ) if it is missing.
        RRRN(syes(sno(thas_signature_for_revision_idRRR1R(RR"Rn((s;/usr/lib/python2.7/dist-packages/bzrlib/smart/repository.pyRzs
(RGRHR(((s;/usr/lib/python2.7/dist-packages/bzrlib/smart/repository.pyRwst SmartServerRepositoryGatherStatscB@seZdZRS(cC@s7|dkrd}n|}|dkr0t}nd}y|j||}Wn!tjk
rotd|fSXd}|jdr|d|d7}n|jdr|d|d7}n|jdr|d	|d7}n|jd
r|d|d
7}n|jdr*|d
|d7}ntd|S(sReturn the result of repository.gather_stats().

        :param repository: The repository to query in.
        :param revid: utf8 encoded rev id or an empty string to indicate None
        :param committers: 'yes' or 'no'.

        :return: A SmartServerResponse ('ok',), a encoded body looking like
              committers: 1
              firstrev: 1234.230 0
              latestrev: 345.700 3600
              revisions: 2

              But containing only fields returned by the gather_stats() call
        RRRt
committersscommitters: %d
tfirstrevsfirstrev: %.3f %d
t	latestrevslatestrev: %.3f %d
t	revisionssrevisions: %d
tsizes	size: %d
RNN(sok(R!R7tgather_statsRR1Rthas_keyR(RR"trevidRtdecoded_revision_idtdecoded_committerststatstbody((s;/usr/lib/python2.7/dist-packages/bzrlib/smart/repository.pyRs.			
(RGRHR(((s;/usr/lib/python2.7/dist-packages/bzrlib/smart/repository.pyRst-SmartServerRepositoryGetRevisionSignatureTextcB@seZdZdZRS(s>Return the signature text of a revision.

    New in 2.5.
    cC@sIy|j|}Wn&tjk
r;}td|jfSXtd|S(sReturn the result of repository.get_signature_text().

        :param repository: The repository to query in.
        :return: A smart server response of with the signature text as
            body.
        RRN(sok(tget_signature_textRR1RRR(RR"RnttextR((s;/usr/lib/python2.7/dist-packages/bzrlib/smart/repository.pyRs(RGRHRIR(((s;/usr/lib/python2.7/dist-packages/bzrlib/smart/repository.pyRstSmartServerRepositoryIsSharedcB@seZdZRS(cC@s$|jrtdStdSdS(sReturn the result of repository.is_shared().

        :param repository: The repository to query in.
        :return: A smart server response of ('yes', ) if the repository is
            shared, and ('no', ) if it is not.
        RRN(syes(sno(t	is_sharedR(RR"((s;/usr/lib/python2.7/dist-packages/bzrlib/smart/repository.pyRs
(RGRHR(((s;/usr/lib/python2.7/dist-packages/bzrlib/smart/repository.pyRst%SmartServerRepositoryMakeWorkingTreescB@seZdZRS(cC@s$|jrtdStdSdS(sReturn the result of repository.make_working_trees().

        Introduced in bzr 2.5.0.

        :param repository: The repository to query in.
        :return: A smart server response of ('yes', ) if the repository uses
            working trees, and ('no', ) if it is not.
        RRN(syes(sno(tmake_working_treesR(RR"((s;/usr/lib/python2.7/dist-packages/bzrlib/smart/repository.pyRs	
(RGRHR(((s;/usr/lib/python2.7/dist-packages/bzrlib/smart/repository.pyRstSmartServerRepositoryLockWritecB@seZddZRS(RcC@s|dkrd}ny|jd|j}Wnntjk
rM}tdStjk
rgtdStjk
r}tdt|j	t|j
fSX|dk	r|jn|j|dkrd}nt
d|fS(	NRttokentLockContentiontUnlockableTransportt
LockFailedRN(sLockContention(sUnlockableTransport(R!t
lock_writetrepository_tokenRRRRRtstrtlocktwhytleave_lock_in_placeR?R(RR"Rte((s;/usr/lib/python2.7/dist-packages/bzrlib/smart/repository.pyRs"	

 

	(RGRHR(((s;/usr/lib/python2.7/dist-packages/bzrlib/smart/repository.pyRstSmartServerRepositoryGetStreamcB@s,eZdZdZdZdZRS(cC@s,tj||_|jr(tdSdS(sGet a stream for inserting into a to_format repository.

        The request body is 'search_bytes', a description of the revisions
        being requested.

        In 2.3 this verb added support for search_bytes == 'everything'.  Older
        implementations will respond with a BadSearch error, and clients should
        catch this and fallback appropriately.

        :param repository: The repository to stream from.
        :param to_network_name: The network name of the format of the target
            repository.
        t
UnknownMethodsRepository.get_stream(RsRepository.get_streamN(RRYt
_to_formatt_should_fake_unknownRR!(RR"tto_network_name((s;/usr/lib/python2.7/dist-packages/bzrlib/smart/repository.pyRs
cC@sW|jj}|j}|js"tS|jrS|j|jkrS|j|jkrStStS(sReturn True if we should return UnknownMethod to the client.
        
        This is a workaround for bugs in pre-1.19 clients that claim to
        support receiving streams of CHK repositories.  The pre-1.19 client
        expects inventory records to be serialized in the format defined by
        to_network_name, but in pre-1.19 (at least) that format definition
        tries to use the xml5 serializer, which does not correctly handle
        rich-roots.  After 1.19 the client can also accept inventory-deltas
        (which avoids this issue), and those clients will use the
        Repository.get_stream_1.19 verb instead of this one.
        So: if this repository is CHK, and the to_format doesn't match,
        we should just fake an UnknownSmartMethod error so that the client
        will fallback to VFS, rather than sending it a stream we know it
        cannot handle.
        (Rt_formatRt
supports_chksRJtrepository_classt_serializerR7(Rtfrom_formatt	to_format((s;/usr/lib/python2.7/dist-packages/bzrlib/smart/repository.pyR s			cC@s|j}|jy]|j||dt\}}|dk	rN|j|S|j|j}|j|}WnGt	k
rt
j}z|jWd|d|d|dXnXtdd|j
||S(NR%iiiRNtbody_stream(sok(RR4R/R7R!R?t_get_sourceRt
get_streamt	Exceptiontsystexc_infoRR(RRTR"R.R~tsourcetstreamR((s;/usr/lib/python2.7/dist-packages/bzrlib/smart/repository.pyRU?s"	


	cc@sqt||j}yx|D]}|VqWWn4tjk
rb}|jtd|jfVnX|jdS(NR1(t_stream_to_byte_streamRRRR?RRn(RRR"tbyte_streamtbytesR((s;/usr/lib/python2.7/dist-packages/bzrlib/smart/repository.pyRTs


(RGRHRRRUR(((s;/usr/lib/python2.7/dist-packages/bzrlib/smart/repository.pyR
s			t#SmartServerRepositoryGetStream_1_19cB@seZdZdZRS(sThe same as Repository.get_stream, but will return stream CHK formats to
    clients.

    See SmartServerRepositoryGetStream._should_fake_unknown.
    
    New in 1.19.
    cC@stS(sAReturns False; we don't need to workaround bugs in 1.19+ clients.(RJ(R((s;/usr/lib/python2.7/dist-packages/bzrlib/smart/repository.pyRks(RGRHRIR(((s;/usr/lib/python2.7/dist-packages/bzrlib/smart/repository.pyRbscc@stj}|jV|j|jdVx|D]\}}x|D]~}|jdkrlt|}n:|jdkrtd|jfn|j	|j}|rH|j||fgVqHqHWq5W|j
VdS(s8Convert a record stream to a self delimited byte stream.RtchunkedtfulltexttabsentsAbsent factory for %sN(RR(RtContainerSerialisertbegintbytes_recordtnetwork_nametstorage_kindRt
ValueErrortkeytget_bytes_astend(Rt
src_formattpack_writertsubstream_typet	substreamtrecordt
serialised((s;/usr/lib/python2.7/dist-packages/bzrlib/smart/repository.pyRps
"t_ByteStreamDecodercB@s;eZdZdZdZdZdZdZRS(s*Helper for _byte_stream_to_stream.

    The expected usage of this class is via the function _byte_stream_to_stream
    which creates a _ByteStreamDecoder, pops off the stream format and then
    yields the output of record_stream(), the main entry point to
    _ByteStreamDecoder.

    Broadly this class has to unwrap two layers of iterators:
    (type, substream)
    (substream details)

    This is complicated by wishing to return type, iterator_for_type, but
    getting the data for iterator_for_type when we find out type: we can't
    simply pass a generator down to the NetworkRecordStream parser, instead
    we have a little local state to seed each NetworkRecordStream instance,
    and gather the type that we'll be yielding.

    :ivar byte_stream: The byte stream being decoded.
    :ivar stream_decoder: A pack parser used to decode the bytestream
    :ivar current_type: The current type, used to join adjacent records of the
        same type into a single stream.
    :ivar first_bytes: The first bytes to give the next NetworkRecordStream.
    cC@s@tj|_d|_d|_||_||_d|_dS(sCreate a _ByteStreamDecoder.iN(	RtContainerPushParsertstream_decoderR!tcurrent_typetfirst_bytesRt_record_countert	key_count(RRtrecord_counter((s;/usr/lib/python2.7/dist-packages/bzrlib/smart/repository.pyt__init__s				cc@sfx|jjD]}|VqWx@|jD]5}|jj|x|jjD]}|VqOWq)WdS(s5Iterate the contents of the pack from stream_decoder.N(Rtread_pending_recordsRtaccept_bytes(RRR((s;/usr/lib/python2.7/dist-packages/bzrlib/smart/repository.pytiter_stream_decoders	cc@s|jdk	r#|jVd|_nxZ|jD]O}|\}}|\}|d}||jkrw||_||_dS|Vq-WdS(Ni(RR!titer_pack_recordsR(RRtrecord_namestrecord_bytestrecord_nameR((s;/usr/lib/python2.7/dist-packages/bzrlib/smart/repository.pytiter_substream_bytess	
		c#@sfd}jtjj}j}zFx?jdk	rutj}j	||||fVq7WWd|r|j
d|j|jn|jXdS(s5Yield substream_type, substream from the byte stream.c3@sd}|rUjdkrUjdkrU|jsR|jjjqRqUnx|jD]}|r|jr||jkr|j||jd|j|j	d}njdkrjd7_||jkr|jdjd}qqn|d7}|VqbWdS(s1Yield records from stream while showing progress.iRtEstimateisEstimating..N(
RRtis_initializedtsetuptreadtSTEPt	incrementRWtcurrenttmax(tpbtrcRtcounterR(R(s;/usr/lib/python2.7/dist-packages/bzrlib/smart/repository.pytwrap_and_counts$
	
NtDone(
t
seed_stateR	t
ui_factorytnested_progress_barRRR!RRRRWRtfinished(RRRRR((Rs;/usr/lib/python2.7/dist-packages/bzrlib/smart/repository.pyt
record_streams
	"cC@s#|j|_t|jdS(s>Prepare the _ByteStreamDecoder to decode from the pack stream.N(RRRR(R((s;/usr/lib/python2.7/dist-packages/bzrlib/smart/repository.pyRs(RGRHRIRRRRR(((s;/usr/lib/python2.7/dist-packages/bzrlib/smart/repository.pyRs					.cC@s|t||}xf|D]^}|jj|xE|jjddD].}|\}}tj|}||jfSWqWdS(sConvert a byte stream into a format and a stream.

    :param byte_stream: A bytes iterator, as output by _stream_to_byte_stream.
    :return: (RepositoryFormat, stream_generator)
    RiN(RRRRRRYR(RRtdecoderRRRtsrc_format_nameR((s;/usr/lib/python2.7/dist-packages/bzrlib/smart/repository.pyt_byte_stream_to_streams
tSmartServerRepositoryUnlockcB@seZdZRS(cC@sRy|jd|Wntjk
r3}tdSX|j|jtdS(NRt
TokenMismatchRN(s
TokenMismatch(sok(RRRRtdont_leave_lock_in_placeR?R(RR"RR((s;/usr/lib/python2.7/dist-packages/bzrlib/smart/repository.pyR
s

(RGRHR(((s;/usr/lib/python2.7/dist-packages/bzrlib/smart/repository.pyRst*SmartServerRepositoryGetPhysicalLockStatuscB@seZdZdZRS(sDGet the physical lock status for a repository.

    New in 2.5.
    cC@s$|jrtdStdSdS(NRR(syes(sno(tget_physical_lock_statusR(RR"((s;/usr/lib/python2.7/dist-packages/bzrlib/smart/repository.pyRs
(RGRHRIR(((s;/usr/lib/python2.7/dist-packages/bzrlib/smart/repository.pyRst(SmartServerRepositorySetMakeWorkingTreescB@seZdZRS(cC@s2|dkrt}nt}|j|tdS(NR7RN(sok(R7RJtset_make_working_treesR(RR"tstr_bool_new_valuet	new_value((s;/usr/lib/python2.7/dist-packages/bzrlib/smart/repository.pyR#s
	
(RGRHR(((s;/usr/lib/python2.7/dist-packages/bzrlib/smart/repository.pyR!stSmartServerRepositoryTarballcB@s2eZdZdZdZdZdZRS(s;Get the raw repository files as a tarball.

    The returned tarball contains a .bzr control directory which in turn
    contains a repository.

    This takes one parameter, compression, which currently must be
    "", "gz", or "bz2".

    This is used to implement the Repository.copy_content_into operation.
    cC@sH|j|\}}z|d}|j||SWdtj|XdS(Ns/.bzr(t_copy_to_tempdirt_tarfile_responseRtrmtree(RR"tcompressionttmp_dirnamettmp_repotcontroldir_name((s;/usr/lib/python2.7/dist-packages/bzrlib/smart/repository.pyR8s

cC@sPtjdd}|jjj|}|jj|}|j|||fS(Ntprefixttmpbzrclone(RtmkdtempRRt
initializetcopy_content_into(Rt	from_repoRt
tmp_bzrdirR((s;/usr/lib/python2.7/dist-packages/bzrlib/smart/repository.pyR@s

cC@sXtj}z:|j|||j|jdtd|jSWd|jXdS(NiRN(sok(ttempfiletNamedTemporaryFilet_tarball_of_dirtfiletseekRRtclose(RRRttemp((s;/usr/lib/python2.7/dist-packages/bzrlib/smart/repository.pyRGs
cC@sddl}tjj|j}|jd|d|dd|}zG|jtj}|j	dsyt
|n|j|dWd|jXdS(Nitfileobjtnametmodesw|s.bzr(
ttarfiletosRtbasenameR+topentencodeRtgetfilesystemencodingtendswithRtaddR((RtdirnameRtofileR-tfilenamettarball((s;/usr/lib/python2.7/dist-packages/bzrlib/smart/repository.pyR%Ss
(RGRHRIRRRR%(((s;/usr/lib/python2.7/dist-packages/bzrlib/smart/repository.pyR,s

			t'SmartServerRepositoryInsertStreamLockedcB@sDeZdZdZdZdZdZdZdZRS(sInsert a record stream from a RemoteSink into a repository.

    This gets bytes pushed to it by the network infrastructure and turns that
    into a bytes iterator using a thread. That is then processed by
    _byte_stream_to_stream.

    New in 1.14.
    cC@s$|jd||j||dS(s1StreamSink.insert_stream for a remote repository.RN(Rtdo_insert_stream_request(RR"t
resume_tokenst
lock_token((s;/usr/lib/python2.7/dist-packages/bzrlib/smart/repository.pyRqscC@srg|jdD]}|r|^q}||_||_tj|_tjd|j|_|jj	dS(NR0ttarget(
R(ttokensR"tQueuetqueuet	threadingtThreadt_inserter_threadt
insert_threadtstart(RR"R;RR>((s;/usr/lib/python2.7/dist-packages/bzrlib/smart/repository.pyR:vs(		cC@s|jj|dS(N(R@tput(Rtbody_stream_chunk((s;/usr/lib/python2.7/dist-packages/bzrlib/smart/repository.pytdo_chunk~scC@soyIt|j\}}|jjj|||j|_t|_Wnt	j
|_t|_nXdS(N(
R
tblocking_byte_streamR"t	_get_sinkt
insert_streamR>t
insert_resultR7t	insert_okRRtinsert_exceptionRJ(RRR((s;/usr/lib/python2.7/dist-packages/bzrlib/smart/repository.pyRCs
cc@s5x.tr0|jj}|tkr(dS|VqWdS(N(R7R@RYR9(RR((s;/usr/lib/python2.7/dist-packages/bzrlib/smart/repository.pyRIs
	cC@s|jjt|jdk	r/|jjn|js\|j}|d|d|dn|j\}}|sw|rt	|}t
j
||f}|jjt
d|fS|jjt
dSdS(Niiis
missing-basisRN(sok(R@RFR9RDR!R\RMRNRLRwRR"R?R(RRtwrite_group_tokenstmissing_keysR((s;/usr/lib/python2.7/dist-packages/bzrlib/smart/repository.pytdo_ends		

(	RGRHRIRR:RHRCRIRQ(((s;/usr/lib/python2.7/dist-packages/bzrlib/smart/repository.pyR9gs					t&SmartServerRepositoryInsertStream_1_19cB@seZdZddZRS(sInsert a record stream from a RemoteSink into a repository.

    Same as SmartServerRepositoryInsertStreamLocked, except:
     - the lock token argument is optional
     - servers that implement this verb accept 'inventory-delta' records in the
       stream.

    New in 1.19.
    cC@stj||||dS(s1StreamSink.insert_stream for a remote repository.N(R9R(RR"R;R<((s;/usr/lib/python2.7/dist-packages/bzrlib/smart/repository.pyRsN(RGRHRIR!R(((s;/usr/lib/python2.7/dist-packages/bzrlib/smart/repository.pyRRs	t!SmartServerRepositoryInsertStreamcB@seZdZdZRS(sInsert a record stream from a RemoteSink into an unlocked repository.

    This is the same as SmartServerRepositoryInsertStreamLocked, except it
    takes no lock_tokens; i.e. it works with an unlocked (or lock-free, e.g.
    like pack format) repository.

    New in 1.13.
    cC@s|j|j||dS(s1StreamSink.insert_stream for a remote repository.N(RR:(RR"R;((s;/usr/lib/python2.7/dist-packages/bzrlib/smart/repository.pyRs
(RGRHRIR(((s;/usr/lib/python2.7/dist-packages/bzrlib/smart/repository.pyRSst%SmartServerRepositoryAddSignatureTextcB@s eZdZdZdZRS(s4Add a revision signature text.

    New in 2.5.
    cG@s||_||_||_dS(sAdd a revision signature text.

        :param repository: Repository to operate on
        :param lock_token: Lock token
        :param revision_id: Revision for which to add signature
        :param write_group_tokens: Write group tokens
        N(t_lock_tokent_revision_idt_write_group_tokensR!(RR"R<RnRO((s;/usr/lib/python2.7/dist-packages/bzrlib/smart/repository.pyRs				cC@s|jjd|jzD|jj|jz|jj|j|Wd|jj}XWd|jjXt	dt
|S(sAdd a signature text.

        :param body_bytes: GPG signature text
        :return: SuccessfulSmartServerResponse with arguments 'ok' and
            the list of new write group tokens.
        RNRN(sok(RRRUtresume_write_groupRWtadd_signature_textRVtsuspend_write_groupR?RRz(RRTtnew_write_group_tokens((s;/usr/lib/python2.7/dist-packages/bzrlib/smart/repository.pyRUs(RGRHRIRRU(((s;/usr/lib/python2.7/dist-packages/bzrlib/smart/repository.pyRTs	t$SmartServerRepositoryStartWriteGroupcB@seZdZdZRS(s*Start a write group.

    New in 2.5.
    cC@sj|jd|z<|jy|j}Wntjk
rJtdSXWd|jXtd|fS(sStart a write group.RtUnsuspendableWriteGroupNRN(sUnsuspendableWriteGroup(Rtstart_write_groupRZRR]RR?R(RR"R<R>((s;/usr/lib/python2.7/dist-packages/bzrlib/smart/repository.pyRs
(RGRHRIR(((s;/usr/lib/python2.7/dist-packages/bzrlib/smart/repository.pyR\st%SmartServerRepositoryCommitWriteGroupcB@seZdZdZRS(s+Commit a write group.

    New in 2.5.
    cC@s|jd|zky|j|Wn,tjk
rR}td|j|jfSXy|jWn|j}nXWd|j	Xt
dS(sCommit a write group.RtUnresumableWriteGroupNRN(sok(RRXRR`Rtwrite_groupstreasontcommit_write_groupRZR?R(RR"R<ROR((s;/usr/lib/python2.7/dist-packages/bzrlib/smart/repository.pyRs(RGRHRIR(((s;/usr/lib/python2.7/dist-packages/bzrlib/smart/repository.pyR_st$SmartServerRepositoryAbortWriteGroupcB@seZdZdZRS(s*Abort a write group.

    New in 2.5.
    cC@sy|jd|zQy|j|Wn9tjk
r_}td|j|jfS|jnXWd|jXt	dS(sAbort a write group.RR`NRN(sok(
RRXRR`RRaRbtabort_write_groupR?R(RR"R<ROR((s;/usr/lib/python2.7/dist-packages/bzrlib/smart/repository.pyR(s(RGRHRIR(((s;/usr/lib/python2.7/dist-packages/bzrlib/smart/repository.pyRd"st$SmartServerRepositoryCheckWriteGroupcB@seZdZdZRS(s>Check that a write group is still valid.

    New in 2.5.
    cC@sv|jd|zNy|j|Wn,tjk
rR}td|j|jfSX|jWd|jXt	dS(sAbort a write group.RR`NRN(sok(
RRXRR`RRaRbRZR?R(RR"R<ROR((s;/usr/lib/python2.7/dist-packages/bzrlib/smart/repository.pyR=s(RGRHRIR(((s;/usr/lib/python2.7/dist-packages/bzrlib/smart/repository.pyRf7st#SmartServerRepositoryAllRevisionIdscB@seZdZdZRS(sGRetrieve all of the revision ids in a repository.

    New in 2.5.
    cC@s"|j}tddj|S(NRNs
(sok(RRR\(RR"trevids((s;/usr/lib/python2.7/dist-packages/bzrlib/smart/repository.pyRSs(RGRHRIR(((s;/usr/lib/python2.7/dist-packages/bzrlib/smart/repository.pyRgMstSmartServerRepositoryReconcilecB@seZdZdZRS(s-Reconcile a repository.

    New in 2.5.
    cC@sy|jd|Wntjk
r3}tdSXz|j}Wd|jXd|jd|jg}tddj	|S(	NRtTokenLockingNotSupportedsgarbage_inventories: %d
sinconsistent_parents: %d
RNR(sTokenLockingNotSupported(sok(
RRRjRt	reconcileR?tgarbage_inventoriestinconsistent_parentsRR\(RR"R<Rt
reconcilerR((s;/usr/lib/python2.7/dist-packages/bzrlib/smart/repository.pyR^s
(RGRHRIR(((s;/usr/lib/python2.7/dist-packages/bzrlib/smart/repository.pyRiXstSmartServerRepositoryPackcB@s eZdZdZdZRS(s(Pack a repository.

    New in 2.5.
    cC@s7||_||_|dkr*t|_n	t|_dS(NR7(RRUR7t_clean_obsolete_packsRJR!(RR"R<tclean_obsolete_packs((s;/usr/lib/python2.7/dist-packages/bzrlib/smart/repository.pyRus			cC@sl|dkrd}n|j}|jjd|jz|jj||jWd|jjXtdS(NRRRN(sok(	R!t
splitlinesRRRURRpR?R(RRTthint((s;/usr/lib/python2.7/dist-packages/bzrlib/smart/repository.pyRU~s	(RGRHRIRRU(((s;/usr/lib/python2.7/dist-packages/bzrlib/smart/repository.pyRoos		t#SmartServerRepositoryIterFilesBytescB@s)eZdZdZdZdZRS(sIterate over the contents of files.

    The client sends a list of desired files to stream, one
    per line, and as tuples of file id and revision, separated by
    .

    The server replies with a stream. Each entry is preceded by a header,
    which can either be:

    * "okIDX
" where IDX is the index of the entry in the desired files
        list sent by the client. This header is followed by the contents of
        the file, bzip2-compressed.
    * "absentFILEIDREVISIONIDX" to indicate a text is missing.
        The client can then raise an appropriate RevisionNotPresent error
        or check its fallback repositories.

    New in 2.5.
    cc@s|jjzi}x$t|D]\}}|||<q#Wx|jj|dtD]}||j}|jdkrd|jd|jd|fVqVnd|Vtj	}x4|j
dD]#}	|j|	}
|
r|
VqqW|j}
|
rV|
VqVqVWWd|jj
XdS(Nt	unorderedRtabsent%s%s%d
iitok%d
R(RR4t	enumeratettextstget_record_streamR7RRtzlibtcompressobjRR|tflushR?(RR"t
desired_filest	text_keystiRRt
identifiert
compressorRtdata((s;/usr/lib/python2.7/dist-packages/bzrlib/smart/repository.pyRs,


	cC@sMg|jD]}t|jd^q
}tdd|j|j|S(NtRNR(sok(RrRzR(RRR(RRTtlR~((s;/usr/lib/python2.7/dist-packages/bzrlib/smart/repository.pyRUs.	cC@sdS(N(R!(RR"((s;/usr/lib/python2.7/dist-packages/bzrlib/smart/repository.pyRs(RGRHRIRRUR(((s;/usr/lib/python2.7/dist-packages/bzrlib/smart/repository.pyRts		t"SmartServerRepositoryIterRevisionscB@s)eZdZdZdZdZRS(slStream a list of revisions.

    The client sends a list of newline-separated revision ids in the
    body of the request and the server replies with the serializer format,
    and a stream of bzip2-compressed revision texts (using the specified
    serializer format).

    Any revisions the server does not have are omitted from the stream.

    New in 2.5.
    cC@s
||_dS(N(RR!(RR"((s;/usr/lib/python2.7/dist-packages/bzrlib/smart/repository.pyRs	cC@s=|jd}td|jjfd|j|j|S(Ns
RNR(R(RRRR(RRTRR((s;/usr/lib/python2.7/dist-packages/bzrlib/smart/repository.pyRUscc@s|jjzixb|jjg|D]}|f^q#dtD]2}|jdkrZq?ntj|jdVq?WWd|jj	XdS(NRuRR(
RR4RRzR7RR{R|RR?(RR"RRRR((s;/usr/lib/python2.7/dist-packages/bzrlib/smart/repository.pyRs
)(RGRHRIRRUR(((s;/usr/lib/python2.7/dist-packages/bzrlib/smart/repository.pyRs		t#SmartServerRepositoryGetInventoriescB@s2eZdZdZdZdZdZRS(sGet the inventory deltas for a set of revision ids.

    This accepts a list of revision ids, and then sends a chain
    of deltas for the inventories of those revisions. The first
    revision will be empty.

    The server writes back zlibbed serialized inventory deltas,
    in the ordering specified. The base for each delta is the
    inventory generated by the previous delta.

    New in 2.5.
    c
c@stjdddtj}tj|j|jj	}|j
zxy|j||D]e\}}|dkrwqYn|j|}|j
|j|j|}	t|jdd|	V|}qYWWd|jXdS(Ntroot_idRn(t_mod_inventoryt	InventoryR!RZR[RtInventoryDeltaSerializertsupports_rich_rootRtsupports_tree_referenceR4t_iter_inventoriest_make_deltatdelta_to_linesRnRR?(
RR"torderingRhtprev_invRtinvRt	inv_deltaR,((s;/usr/lib/python2.7/dist-packages/bzrlib/smart/repository.pyt_inventory_delta_streams 	
cC@s.|j|||}td|fg|jS(Nsinventory-deltas(RRR(RR"RRhR((s;/usr/lib/python2.7/dist-packages/bzrlib/smart/repository.pyR	s	cC@s+tdd|j|j|j|jS(NRNR(sok(RRRt	_orderingRr(RRT((s;/usr/lib/python2.7/dist-packages/bzrlib/smart/repository.pyRUs	cC@s"|dkrd}n||_dS(NRuttopological(RR!(RR"R((s;/usr/lib/python2.7/dist-packages/bzrlib/smart/repository.pyRs		(RGRHRIRRRUR(((s;/usr/lib/python2.7/dist-packages/bzrlib/smart/repository.pyRs
			(MRIt
__future__RR{R.R?RR#RAR{tbzrlibRRRRRRRRRR	R
t
bzrlib.bzrdirRtbzrlib.smart.requestRR
Rtbzrlib.repositoryRRRRZtbzrlib.versionedfileRRRRRKRMt
_lsprof_countRPRRRRRRRRRRRRRtobjectRR!R
RRRRR9RRRSRTR\R_RdRfRgRiRoRtRR(((s;/usr/lib/python2.7/dist-packages/bzrlib/smart/repository.pyt<module>slFVv&.X	t
;A)9$

Copyright © 2017 || Recoded By Mr.Bumblebee