-=[ Mr. Bumblebee ]=-
_Indonesia_

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


:Nc@@sdZddlmZddlmZddlmZddlZddlZddl	m
Z
e
edddlm
Z
mZmZdd	lmZmZmZmZmZmZdd
lmZmZmZmZddlmZmZmZm Z m!Z!m"Z"m#Z#dZ$d
Z%dddZ&de'fdYZ(de(fdYZ)de(fdYZ*de(fdYZ+de(fdYZ,de(fdYZ-de(fdYZ.de!fdYZ/d e!fd!YZ0d"Z1d#Z2d$e'fd%YZ3d&e3fd'YZ4d(e3fd)YZ5d*e'fd+YZ6d,e6fd-YZ7d.e6fd/YZ8d0Z9d1Z:d2Z;d3Z<d4e#fd5YZ=d6e'fd7YZ>d8e>fd9YZ?d:e>fd;YZ@d<e'fd=YZAd>e'fd?YZBd@e'fdAYZCdBZDdCe
jEfdDYZFyddElGmHZIWn0eJk
rZKejLeKddFlMmNZInXdS(GskKnit versionedfile implementation.

A knit is a versioned file implementation that supports efficient append only
updates.

Knit file layout:
lifeless: the data file is made up of "delta records".  each delta record has a delta header
that contains; (1) a version id, (2) the size of the delta (in lines), and (3)  the digest of
the -expanded data- (ie, the delta applied to the parent).  the delta also ends with a
end-marker; simply "end VERSION"

delta can be line or full contents.a
... the 8's there are the index number of the annotation.
version robertc@robertcollins.net-20051003014215-ee2990904cc4c7ad 7 c7d23b2a5bd6ca00e8e266cec0ec228158ee9f9e
59,59,3
8
8         if ie.executable:
8             e.set('executable', 'yes')
130,130,2
8         if elt.get('executable') == 'yes':
8             ie.executable = True
end robertc@robertcollins.net-20051003014215-ee2990904cc4c7ad


whats in an index:
09:33 < jrydberg> lifeless: each index is made up of a tuple of; version id, options, position, size, parents
09:33 < jrydberg> lifeless: the parents are currently dictionary compressed
09:33 < jrydberg> lifeless: (meaning it currently does not support ghosts)
09:33 < lifeless> right
09:33 < jrydberg> lifeless: the position and size is the range in the data file


so the index sequence is the dictionary compressed sequence number used
in the deltas to provide line annotation

i(tabsolute_import(tStringIO(tizipN(tlazy_imports
import gzip

from bzrlib import (
    debug,
    diff,
    graph as _mod_graph,
    index as _mod_index,
    pack,
    patiencediff,
    static_tuple,
    trace,
    tsort,
    tuned_gzip,
    ui,
    )

from bzrlib.repofmt import pack_repo
from bzrlib.i18n import gettext
(tannotateterrorstosutils(t
NoSuchFiletInvalidRevisionIdtKnitCorrupttKnitHeaderErrortRevisionNotPresenttSHA1KnitCorrupt(tcontains_whitespacet
sha_stringtsha_stringstsplit_lines(t_KeyRefstAbsentContentFactorytadapter_registrytConstantMappertContentFactorytsort_groupcompresstVersionedFilesWithFallbackss.knits.kndxiitKnitAdaptercB@seZdZdZRS(s$Base class for knit record adaption.cC@s7tdd|_t|_t|_||_dS(sCreate an adapter which accesses full texts from basis_vf.

        :param basis_vf: A versioned file to access basis texts of deltas from.
            May be None for adapters that do not need to access basis texts.
        N(tKnitVersionedFilestNonet_datatKnitAnnotateFactoryt_annotate_factorytKnitPlainFactoryt_plain_factoryt	_basis_vf(tselftbasis_vf((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyt__init__s(t__name__t
__module__t__doc__R#(((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyRstFTAnnotatedToUnannotatedcB@seZdZdZRS(s7An adapter from FT annotated knits to unannotated ones.cC@sm|j}|jj|\}}|jj||d}|jj|df|d|j\}}|S(Nii(t_raw_recordRt_parse_record_uncheckedRtparse_fulltextt_record_to_datattext(R!tfactorytannotated_compressed_bytestrectcontentstcontenttsizetbytes((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyt	get_bytess
	/(R$R%R&R4(((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyR'stDeltaAnnotatedToUnannotatedcB@seZdZdZRS(s4An adapter for deltas from annotated to unannotated.cC@s|j}|jj|\}}|jj||ddt}|jj|}|jj|df|d|\}}|S(Nitplaini(	R(RR)Rtparse_line_deltatTrueRtlower_line_deltaR+(R!R-R.R/R0tdeltaR2R3((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyR4s		)(R$R%R&R4(((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyR5stFTAnnotatedToFullTextcB@seZdZdZRS(s7An adapter from FT annotated knits to unannotated ones.cC@s_|j}|jj|\}}|jj|jd||jd\}}dj|j	S(Nit(
R(RR)Rtparse_recordtkeyt_build_detailsRtjoinR,(R!R-R.R/R0R1R:((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyR4s
	(R$R%R&R4(((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyR;stDeltaAnnotatedToFullTextcB@seZdZdZRS(s4An adapter for deltas from annotated to unannotated.cC@s|j}|jj|\}}|jj||ddt}|jd}|jj|gdtj	}|j
dkrtj||jn|j
d}tj|}	t|	|}
|
j||d|jd|
_dj|
jS(NiR6it	unorderedtabsenttchunkedR<(R(RR)RR7R8tparentsR tget_record_streamtnexttstorage_kindRRtget_bytes_asRtchunks_to_linestPlainKnitContenttapply_deltaR?t_should_strip_eolR@R,(R!R-R.R/R0R:tcompression_parenttbasis_entrytbasis_chunkstbasis_linest
basis_content((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyR4s		
	(R$R%R&R4(((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyRAstFTPlainToFullTextcB@seZdZdZRS(s3An adapter from FT plain knits to unannotated ones.cC@s_|j}|jj|\}}|jj|jd||jd\}}dj|j	S(NiR<(
R(RR)RR=R>R?RR@R,(R!R-tcompressed_bytesR/R0R1R:((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyR4s
	(R$R%R&R4(((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyRSstDeltaPlainToFullTextcB@seZdZdZRS(s4An adapter for deltas from annotated to unannotated.c
C@s|j}|jj|\}}|jj||d}|jd}|jj|gdtj	}|j
dkrtj||jn|j
d}tj|}	t|	|}
|jj|d||j|
\}}dj|jS(NiiRBRCRDR<(R(RR)RR7RER RFR8RGRHRRRIRRJRKR=R?R@R,(
R!R-RTR/R0R:RNRORPRQRRR1t_((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyR4s	
	(R$R%R&R4(((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyRUstKnitContentFactorycB@s/eZdZdddZdZdZRS(sLContent factory for streaming from knits.

    :seealso ContentFactory:
    c	C@stj|||_||_||_|ddkrAd}	nd}	|rVd}
nd}
d|
|	f|_||_||_||_||_	dS(	sCreate a KnitContentFactory for key.

        :param key: The key.
        :param parents: The parents.
        :param build_details: The build details as returned from
            get_build_details.
        :param sha1: The sha1 expected from the full text of this object.
        :param raw_record: The bytes of the knit data from disk.
        :param annotated: True if the raw data is annotated.
        :param network_bytes: None to calculate the network bytes on demand,
            not-none if they are already known.
        is
line-deltaR:tfts
annotated-R<sknit-%s%s-gzN(
RR#tsha1R>RERHR(t_network_bytesR?t_knit(R!R>REt
build_detailsRYt
raw_recordt	annotatedtknitt
network_bytestkindtannotated_kind((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyR#s
								cC@sdj|j}|jd	kr*d}ndjd|jD}|jdr\d}nd}d|j||||jf}||_d	S(
s;Create a fully serialised network version for transmission.tsNone:s	cs@s|]}dj|VqdS(RcN(R@(t.0R>((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pys	<genexpr>!sitNt s
%s
%s
%s
%s%sN(R@R>RERR?RHR(RZ(R!t	key_bytestparent_bytestnoeolR`((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyt_create_network_bytess	
	cC@s||jkr2|jdkr+|jn|jSd|jkr|dkr|jdf}tj|}|d}|j|}|dkr|gS|Sn|jdk	r|dkr|jj|j	dS|dkr|jj
|j	dSntj|j	||jdS(Ns-ft-RDtfulltexti(schunkedRk(
RHRZRRjRtgetR4R[t	get_linesR>tget_textRtUnavailableRepresentation(R!RHtadapter_keytadapter_factorytadapterR3((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyRI*s(
N(R$R%R&RR#RjRI(((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyRWs	tLazyKnitContentFactorycB@s eZdZdZdZRS(sgA ContentFactory which can either generate full text or a wire form.

    :seealso ContentFactory:
    cC@sS||_||_d|_||_d|_|sF|jd|_n||_dS(sCreate a LazyKnitContentFactory.

        :param key: The key of the record.
        :param parents: The parents of the record.
        :param generator: A _ContentMapGenerator containing the record for this
            key.
        :param first: Is this the first content object returned from generator?
            if it is, its storage kind is knit-delta-closure, otherwise it is
            knit-delta-closure-ref
        sknit-delta-closures-refN(R>RERRYt
_generatorRHt_first(R!R>REt	generatortfirst((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyR#Js					cC@s||jkr,|jr%|jjSdSn|dkrs|jj|jj}|dkrc|Sdj|Sntj	|j||jdS(NR<RDRk(schunkedsfulltext(
RHRuRtt_wire_bytest
_get_one_workR>R,R@RRo(R!RHtchunks((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyRI^s	
(R$R%R&R#RI(((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyRsDs	cC@st||}|jS(sConvert a network record to a iterator over stream records.

    :param storage_kind: The storage kind of the record.
        Must be 'knit-delta-closure'.
    :param bytes: The bytes of the record on the network.
    (t_NetworkContentMapGeneratorRF(RHR3tline_endRv((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pytknit_delta_closure_to_recordspsc
	C@s2|}|jd|}t|||!jd}|d}|jd|}|||!}|dkrrd}n=tg|jdD]!}|rt|jd^q}|d}||dk}d|krd}	nd	}	|	|f}
|d}||}d
|k}t|||
d||d|gS(
sConvert a network record to a record object.

    :param storage_kind: The storage kind of the record.
    :param bytes: The bytes of the record on the network.
    s
RcisNone:s	ReRXRks
line-deltaR^R`N(tfindttupletsplitRRW(
RHR3R|tstartR>tparent_lineREtsegmentRitmethodR\R]R^((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pytknit_network_to_record{s,

	$
	

tKnitContentcB@sAeZdZdZdZdZdZedZRS(sContent of a knit version to which deltas can be applied.

    This is always stored in memory as a list of lines with \n at the end,
    plus a flag saying if the final ending is really there or not, because that
    corresponds to the on-disk knit representation.
    cC@s
t|_dS(N(tFalseRM(R!((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyR#scC@st|jdS(s4Apply delta to this object to become new_version_id.N(tNotImplementedErrorRL(R!R:tnew_version_id((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyRLsc
c@s|j}|j}tjd||}xT|jD]F\}}}}}	|dkraq:n|||	||j||	!fVq:WdS(s9Generate line-based delta from this content to new_lines.tequalN(R,tpatiencedifftPatienceSequenceMatcherRtget_opcodest_lines(
R!t	new_linest	new_textst	old_textststtagti1ti2tj1tj2((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pytline_delta_iters"cC@st|j|S(N(tlistR(R!R((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyt
line_deltascc@s7t|}d}d}x|D]\}}}}	||}
|
}|dkr|||d|||dkr~|d8}n|dkr|||fVqn|||
7}|}qW||}|dkr|||d|||dkr|d8}n|dkr|||fVqn||||dfVdS(s?Extract SequenceMatcher.get_matching_blocks() from a knit deltaiiN(tlen(t
knit_deltatsourcettargett
target_lents_postt_posts_begints_endtt_lentnew_textttrue_ntn((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pytget_line_delta_blockss(
$


$
(	R$R%R&R#RLRRtstaticmethodR(((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyRs				tAnnotatedKnitContentcB@s;eZdZdZdZdZdZdZRS(sAnnotated content.cC@stj|||_dS(N(RR#R(R!tlines((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyR#s
cC@sC|j}|jr?|d\}}||jdf|d<n|S(s6Return a list of (origin, text) for each content line.is
(RRMtrstrip(R!Rtorigint	last_line((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyRs

	c	C@sWd}|j}xA|D]9\}}}}||||||+||||}qWdS(s4Apply delta to this object to become new_version_id.iN(R(	R!R:RtoffsetRRtendtcounttdelta_lines((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyRLs
	cC@syy&g|jD]\}}|^q
}Wn)tk
rQ}t|d|fnX|jru|djd|d<n|S(Ns9line in annotated knit missing annotation information: %sis
(Rt
ValueErrorR	RMR(R!RR,Rte((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyR,s&	cC@st|jS(N(RR(R!((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pytcopys(R$R%R&R#RRLR,R(((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyRs				RKcB@s;eZdZdZdZdZdZdZRS(sUnannotated content.

    When annotate[_iter] is called on this content, the same version is reported
    for all lines. Generally, annotate[_iter] is not useful on PlainKnitContent
    objects.
    cC@s#tj|||_||_dS(N(RR#Rt_version_id(R!Rt
version_id((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyR#s
	cC@s#g|jD]}|j|f^q
S(s6Return a list of (origin, text) for each content line.(RR(R!tline((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyR	sc	C@s`d}|j}xA|D]9\}}}}||||||+||||}qW||_dS(s4Apply delta to this object to become new_version_id.iN(RR(	R!R:RRRRRRR((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyRL
s	cC@st|j|jS(N(RKRR(R!((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyRscC@s7|j}|jr3|}|djd|d<n|S(Nis
(RRMR(R!R((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyR,s
		(R$R%R&R#RRLRR,(((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyRKs					t_KnitFactorycB@seZdZedZRS(s(Base class for common Factory functions.c
C@s|\}}|dkrX|r-|j}n|}|j||}	|j|	|n|j||}d}	||_||	fS(sParse a record into a full content object.

        :param version_id: The official version id for this content
        :param record: The data returned by read_records_iter()
        :param record_details: Details about the record returned by
            get_build_details
        :param base_content: If get_build_details returns a compression_parent,
            you must return a base_content here, else use None
        :param copy_base_content: When building from the base_content, decide
            you can either copy it and return a new object, or modify it in
            place.
        :return: (content, delta) A Content object and possibly a line-delta,
            delta may be None
        s
line-deltaN(RR7RLR*RRM(
R!Rtrecordtrecord_detailstbase_contenttcopy_base_contentRRiR1R:((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyR=$s	(R$R%R&R8R=(((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyR!sRcB@sheZdZeZdZdZdZedZ	dZ
dZdZdZ
d	ZRS(
s/Factory for creating annotated Content objects.cC@s&t|}tt|g||S(N(RRtzip(R!RRt	num_lines((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pytmakeHscC@s5g|D]}t|jdd^q}t|S(sConvert fulltext to internal representation

        fulltext content is of the format
        revid(utf8) plaintext

        internal representation is of the format:
        (revid, plaintext)
        Rfi(RRR(R!R1RRR((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyR*Ls+cC@st|j|S(N(titerR7(R!R((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pytparse_line_delta_iter[sc@sYg}t|}|j}ifd}|rx|D]}g|jdD]}t|^qS\}	}
}gt|D]}|jddd^q}
|j|	|
||
fq=Wnx|D]}g|jdD]}t|^q\}	}
}gt|D]!}t|jdd^q}
|j|	|
||
fqW|S(sConvert a line based delta into internal representation.

        line delta is in the form of:
        intstart intend intcount
        1..count lines:
        revid(utf8) newline

        internal representation is
        (start, end, count, [1..count tuples (revid, newline)])

        :param plain: If True, the lines are returned as a plain
            list without annotations, not as a list of (origin, content) tuples, i.e.
            (start, end, count, [1..count newline])
        c@s.|jdd\}}j|||fS(NRfi(Rt
setdefault(RRR,(tcache(s//usr/lib/python2.7/dist-packages/bzrlib/knit.pytcache_and_returnqst,Rfi(RRGRtinttxrangetappendR(R!RRR6tresultRGRtheaderRRRRtiR0((Rs//usr/lib/python2.7/dist-packages/bzrlib/knit.pyR7^s	
12 
14cC@sd|DS(s/Extract just the content lines from a fulltext.cs@s%|]}|jdddVqdS(RfiN(R(RdR((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pys	<genexpr>s((R!R((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pytget_fulltext_contentscc@st|}|j}xd|D]\}|jd}t|d}x4t|D]&}|jdd\}}|VqNWqWdS(sExtract just the content from a line delta.

        This doesn't return all of the extra information stored in a delta.
        Only the actual content lines.
        RiRfiN(RRGRRR(R!RRGRRRRR,((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pytget_linedelta_contents	
cC@s*g|jD]\}}d||f^q
S(stconvert a fulltext content record into a serializable form.

        see parse_fulltext which this inverts.
        s%s %s(R(R!R1tott((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pytlower_fulltextscC@sXg}xK|D]C\}}}}|jd|||f|jd|Dq
W|S(sdconvert a delta into a serializable form.

        See parse_line_delta which this inverts.
        s	%d,%d,%d
cs@s#|]\}}|d|VqdS(RfN((RdRR,((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pys	<genexpr>s(Rtextend(R!R:toutRRtcR((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyR9sc	C@s|j|}t|tkrr|d }|j}g}x.|D]&\}}|j||f|fqDW|S|jSdS(Ni(t_get_contentttypeRRR(	R!R_R>R1tprefixtoriginsRRR((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyRs
(R$R%R&R8R^RR*RRR7RRRR9R(((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyRCs			&				RcB@seeZdZeZdZdZdZdZdZ	dZ
dZdZd	Z
RS(
s+Factory for creating plain Content objects.cC@s
t||S(N(RK(R!RR((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyRscC@s|j||S(sThis parses an unannotated fulltext.

        Note that this is not a noop - the internal representation
        has (versionid, line) - its just a constant versionid.
        (R(R!R1R((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyR*sc
c@sd}t|}x{||kr||}|d7}g|jdD]}t|^qE\}}}	|||	||||	!fV||	7}qWdS(NiiR(RRR(
R!RRtcurRRRRRR((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyRs

1cC@st|j||S(N(RR(R!RR((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyR7scC@s
t|S(s/Extract just the content lines from a fulltext.(R(R!R((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyRscc@sht|}|j}xL|D]D}|jd}t|d}xt|D]}|VqNWqWdS(sExtract just the content from a line delta.

        This doesn't return all of the extra information stored in a delta.
        Only the actual content lines.
        RiN(RRGRRR(R!RRGRRR((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyRs	
cC@s
|jS(N(R,(R!R1((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyRscC@sNg}xA|D]9\}}}}|jd|||f|j|q
W|S(Ns	%d,%d,%d
(RR(R!R:RRRRR((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyR9s
cC@st|}|j|S(N(t_KnitAnnotatort
annotate_flat(R!R_R>t	annotator((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyRs(R$R%R&RR^RR*RR7RRRR9R(((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyRs			
					c@sfd}|S(sCreate a factory for creating a file based KnitVersionedFiles.

    This is only functional enough to run interface tests, it doesn't try to
    provide a full pack environment.

    :param annotated: knit annotations are wanted.
    :param mapper: The mapper from keys to paths.
    c@sCt|ddd}t|}t||dS(NcS@sdS(N(R(((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyt<lambda>scS@stS(N(R8(((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyRsR^(t
_KndxIndext_KnitKeyAccessR(t	transporttindextaccess(R^tmapper(s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyR-s!((R^RR-((R^Rs//usr/lib/python2.7/dist-packages/bzrlib/knit.pytmake_file_factorys	c@sfd}|S(s.Create a factory for creating a pack based VersionedFiles.

    This is only functional enough to run interface tests, it doesn't try to
    provide a full pack environment.

    :param graph: Store a graph.
    :param delta: Delta compress contents.
    :param keylength: How long should keys be.
    c
	@sp	}d}r%|d7}nr>|d7}d}nd}tjd|d}|jd}tj|j}|jt|dd|d	d
|j}t	j
i}|j|||dft||d|}	||	_
||	_|	S(Niiitreference_liststkey_elementstnewpackcS@stS(N(R8(((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyR%sREtdeltastadd_callbacktmax_delta_chain(t
_mod_indextInMemoryGraphIndextopen_write_streamtpacktContainerWritertwritetbegint_KnitGraphIndext	add_nodest	pack_repot_DirectPackAccesst
set_writerRtstreamtwriter(
RREt
ref_lengthRtgraph_indexRRRRR(R:tgrapht	keylength(s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyR-s,

		
			((RR:RR-((R:RRs//usr/lib/python2.7/dist-packages/bzrlib/knit.pytmake_pack_factorys
cC@s|jj|jjdS(N(RtcloseRR(tversioned_files((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pytcleanup_pack_knit1s
c
C@si}|}xu|rt}xY|D]Q}||kr=q%n||\}}}	|||<|	|kr%|j|	q%q%W|}qWtg|jD]}|d^qS(sDetermine the total bytes to build these keys.

    (helper function because _KnitGraphIndex and _KndxIndex work the same, but
    don't inherit from a common base.)

    :param keys: Keys that we want to build
    :param positions: dict of {key, (info, index_memo, comp_parent)} (such
        as returned by _get_components_positions)
    :return: Number of bytes to build those keys
    i(tsettaddtsumt
itervalues(
R!tkeyst	positionstall_build_index_memost
build_keyst	next_keysR>RVt
index_memoRN((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyt_get_total_build_size6s		


RcB@seZdZded,dZdZdZdZd,d,d,ee	dZ
d,edZdZd	Z
d
Zd,d,dZdZd
ZdZdZdZdZedZidZdZdZedZdZedZedZedZ dZ!dZ"dZ#dZ$dZ%d,d Z&d!Z'id,d,d,d"Z(d#Z)d$Z*d%Z+d&Z,d'Z-d(Z.d,d)Z/d*Z0d+Z1RS(-sStorage for many versioned files using knit compression.

    Backend storage is managed by indices and data objects.

    :ivar _index: A _KnitGraphIndex or similar that can describe the
        parents, graph, compression and data location of entries in this
        KnitVersionedFiles.  Note that this is only the index for
        *this* vfs; if there are fallbacks they must be queried separately.
    icC@sR||_||_||_|r0t|_nt|_g|_||_dS(sCreate a KnitVersionedFiles with index and data_access.

        :param index: The index for the knit data.
        :param data_access: The access object to store and retrieve knit
            records.
        :param max_delta_chain: The maximum number of deltas to permit during
            insertion. Set to 0 to prohibit the use of deltas.
        :param annotated: Set to True to cause annotations to be calculated and
            stored during insertion.
        :param reload_func: An function that can be called if we think we need
            to reload the pack listing and try again. See
            'bzrlib.repofmt.pack_repo.AggregateIndex' for the signature.
        N(t_indext_accesst_max_delta_chainRt_factoryRt_immediate_fallback_vfst_reload_func(R!Rtdata_accessRR^treload_func((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyR#^s				cC@sd|jj|j|jfS(Ns
%s(%r, %r)(t	__class__R$RR
(R!((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyt__repr__ws	cC@s(t|j|j|j|jj|jS(s?Return a clone of this object without any fallbacks configured.(RRR
RRR^R(R!((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pytwithout_fallbacks}scC@s|jj|dS(s~Add a source of texts for texts not present in this knit.

        :param a_versioned_files: A VersionedFiles object.
        N(RR(R!ta_versioned_files((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pytadd_fallback_versioned_filessc	

C@sl|jj|j|||||dkr8d}ndj|}	|j|||||||d|	S(sSee VersionedFiles.add_lines().R<t
line_bytesN((Rt_check_write_okt
_check_addRR@t_add(
R!R>RERtparent_textstleft_matching_blockstnostore_shat	random_idt
check_contentR((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyt	add_liness
	c
C@s|jj|j|d|dt|jtk	rGtjdn|dkr\d}n|j	|d|dd||d|S(sSee VersionedFiles._add_text().R!R,RN((
RRRRRRtstrRtBzrBadParameterUnicodeR(R!R>RER,RR ((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyt	_add_texts
	c	C@st|}	||	kr$tjng}
|d
kr?i}n|jj|}x*|D]"}||krX|
j|qXqXWt|
dks|
d|dkrt}
n|j	|
d}
t|}g}t}|r;|ddkr;|jdt
}|d
krtj|}n|}|dd|d<n|d
krYtj|}nx:|d D].}t
|tk	rdtd|fqdqdW|dd
kr|d d|	f}n,t
|dtk	rtd|fn|d}|jj||}|rt
|_n|
s?|jjrft|
dkrf|j||
||
|jj|}n|
r|jd|jj|}|j||	|\}}n|jd|jjtkr|g}|r|jdn|j||	||\}}n-|jj|}|j||	|\}}|jj||fg|d}|jj||||ffd	||	||fS(sAdd a set of lines on top of version specified by parents.

        Any versions not present will be converted into ghosts.

        :param lines: A list of strings where each one is a single line (has a
            single newline at the end of the string) This is now optional
            (callers can pass None). It is left in its location for backwards
            compatibility. It should ''.join(lines) must == line_bytes
        :param line_bytes: A single string containing the content

        We pass both lines and line_bytes because different routes bring the
        values to this function. And for memory efficiency, we don't want to
        have to split/join on-demand.
        iis
sno-eolskey contains non-strings: %rssha1:s
line-deltaRkR N(RRtExistingContentRRtget_parent_mapRRRt_check_should_deltaR8RRRR#t	TypeErrorRRRMR^t_merge_annotationsR9R+RRRR
tadd_raw_recordstadd_records(R!R>RRERRRR Rtdigesttpresent_parentstpresent_parent_maptparentR:ttext_lengthtoptionstno_eoltelementRR1tdelta_hunkststore_linesR2R3tdense_linestaccess_memo((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyRsz	
	

$

	"	cC@s|jj||S(sSee VersionedFiles.annotate.(RR(R!R>((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyRscC@s
t|S(N(R(R!((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyt
get_annotatorscC@s-|dkr|jS|j|dtSdS(sSee VersionedFiles.check().RBN(Rt_logical_checkRFR8(R!tprogress_barR((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pytchecks
cC@s|jj}|j|}xb|D]Z}|jj|dkr%||d}||krtj|d||fqq%q%Wx|jD]}|jqWdS(NRkisMissing basis parent %s for %s(RRR't
get_methodRR	RR<(R!Rt
parent_mapR>RNtfallback_vfs((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyR:'s
	cC@sk|d}|dk	rDt|r4t||n|j|n|rg|j||j|ndS(s0check that version_id and lines are safe to add.iN(RR
Rtcheck_not_reserved_idt_check_lines_not_unicodet_check_lines_are_lines(R!R>RR R!R((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyR8s

cC@s'|j|}|j||d|S(Ni(t
_split_headert_check_header_version(R!R>RR/((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyt
_check_headerGscC@s4|d|kr0t|d||dfndS(sChecks the header version on original format knit records.

        These have the last component of the key embedded in the record.
        is%unexpected version, wanted %r, got %rN(R	(R!R/R((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyRDLscC@sd}d}xt|jD]}y#|jj|g}||}Wnttfk
ra}tSX|\}}	}
}
|\}
}
}|	dkr|}Pn||7}|	}qWtS||kS(sIterate back through the parent listing, looking for a fulltext.

        This is used when we want to decide whether to add a delta or a new
        fulltext. It searches for _max_delta_chain parents. When it finds a
        fulltext parent, it sees if the total size of the deltas leading up to
        it is large enough to indicate that we want a new full text anyway.

        Return True if we should create a new delta, False if we should use a
        full text.
        iN(RRRRtget_build_detailsRtKeyErrorR(R!R0t
delta_sizet
fulltext_sizeRR\tparent_detailsRR
RNRVR2((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyR(Us"

cC@s|d|d|dfS(s2Convert a build_details tuple to a position tuple.iii((R!R\((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyt_build_details_to_components}scC@si}|}x|r|jj|}t|}t}xe|jD]W\}}|\}	}
}}|d}
|
dk	r|j|
n|j|||<qIW|j|}|r|rtj	|j
|qqW|S(sProduce a map of position data for the components of keys.

        This data is intended to be used for retrieving the knit records.

        A dict of key to (record_details, index_memo, next, parents) is
        returned.

        * method is the way referenced data should be applied.
        * index_memo is the handle to pass to the data access to actually get
          the data
        * next is the build-parent of the version, or None for fulltexts.
        * parents is the version_ids of the parents of this version

        :param allow_missing: If True do not raise an error on a missing
            component, just ignore it.
        iN(RRFRt	iteritemsRRRKt
differenceRRtpop(R!Rt
allow_missingtcomponent_datatpending_componentsR\tcurrent_componentsR>tdetailsR
RNRERRtmissing((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyt_get_components_positionss 		

cC@se|j|d}|dk	rF|j|gsBt||n|St||g}|j|S(sEReturns a content object that makes up the specified
        version.N(RlRR'Rt_VFContentMapGeneratorR(R!R>Rtcached_versionRv((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyRscC@s|j|dS(sGet a map of the graph parents of keys.

        :param keys: The keys to look up parents for.
        :return: A mapping from keys to parents. Absent keys are absent from
            the mapping.
        i(t_get_parent_map_with_sources(R!R((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyR'scC@si}|jg|j}g}t|}xT|D]L}|sBPn|j|}|j||j||jt|q2W||fS(sGet a map of the parents of keys.

        :param keys: The keys to look up parents for.
        :return: A tuple. The first element is a mapping from keys to parents.
            Absent keys are absent from the mapping. The second element is a
            list with the locations each key was found in. The first element
            is the in-this-knit parents, the second the first fallback source,
            and so on.
        (RRRR'Rtupdatetdifference_update(R!RRtsourcestsource_resultsRTRt
new_result((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyRXs



cC@s"|j|d|}|j|S(sProduce a dictionary of knit records.

        :return: {key:(record, record_details, digest, next)}

            * record: data returned from read_records (a KnitContentobject)
            * record_details: opaque information to pass to parse_record
            * digest: SHA1 digest of the full text after all steps are done
            * next: build-parent of the version, i.e. the leftmost ancestor.
                Will be None if the record is not a delta.

        :param keys: The keys to build a map for
        :param allow_missing: If some records are missing, rather than
            error, just return the data that could be generated.
        RO(t_get_record_map_unparsedt_raw_map_to_record_map(R!RROtraw_map((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyt_get_record_maps	c	C@s`i}xS|D]K}||\}}}|j|d|\}}||||f||<q
W|S(s_Parse the contents of _get_record_map_unparsed.

        :return: see _get_record_map.
        i(t
_parse_record(	R!R`RR>tdataRRGR1R-((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyR_s
cC@sxtry|j|d|}g|jD]!\}\}}}||f^q.}|jdtjdi}	xC|j|D]2\}}
||\}}}
|
||
f|	|<qW|	SWqtjk
r}|j	j
|qXqWdS(sGet the raw data for reconstructing keys without parsing it.

        :return: A dict suitable for parsing via _raw_map_to_record_map.
            key-> raw_bytes, (method, noeol), compression_parent
        ROR>iN(R8RURLtsorttoperatort
itemgettert_read_records_iter_uncheckedRtRetryWithNewPacksR
treload_or_raise(R!RROtposition_mapR>trti_mRtrecordstraw_record_mapRcRR
RGR((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyR^s
		1cC@si}g}xm|D]e}t|dkr4d}n
|d}||kr^||j|q|g||<|j|qW||fS(sFor the given keys, split them up based on their prefix.

        To keep memory pressure somewhat under control, split the
        requests back into per-file-id requests, otherwise "bzr co"
        extracts the full tree into memory before writing it to disk.
        This should be revisited if _get_content_maps() can ever cross
        file-id boundaries.

        The keys for a given file_id are kept in the same relative order.
        Ordering between file_ids is not, though prefix_order will return the
        order that the key was first seen.

        :param keys: An iterable of key tuples
        :return: (split_map, prefix_order)
            split_map       A dictionary mapping prefix => keys
            prefix_order    The order that we saw the various prefixes
        iR<i(RR(tclsRtsplit_by_prefixtprefix_orderR>R((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyt_split_by_prefixs
	

cC@s.t|}|j|\}}|j|\}}	g}
t}d}g}
g}x|D]}||}|j|g}|jj||}||7}|
j||j|||kr^|
j|
|f|j|g}
t}d}q^q^W|
r*|
j|
|f|j|n|
S(sFor the given keys, group them into 'best-sized' requests.

        The idea is to avoid making 1 request per file, but to never try to
        unpack an entire 1.5GB source tree in a single pass. Also when
        possible, we should try to group requests to the same pack file
        together.

        :return: list of (keys, non_local) tuples that indicate what keys
            should be fetched next.
        i(	RRrRRlRRRRYR(R!Rtnon_local_keysRt_min_buffer_sizet
total_keystprefix_split_keysRqtprefix_split_non_local_keysRVtcur_keyst
cur_non_localtcur_sizeRtsizesRt	non_localt	this_size((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyt_group_keys_for_io2s2	





	
cc@st|}|sdS|jjs+d}n|}x|tryIt|}x2|j|||D]}|j|j|Vq_WdSWq4tjk
r}|j	j
|q4Xq4WdS(sGet a stream of records for keys.

        :param keys: The keys to include.
        :param ordering: Either 'unordered' or 'topological'. A topologically
            sorted stream has compression parents strictly before their
            children.
        :param include_delta_closure: If True then the closure across any
            compression parents will be included (in the opaque data).
        :return: An iterator of ContentFactory objects, each of which is only
            valid until the iterator is advanced.
        NRB(RRt	has_graphR8t_get_remaining_record_streamtdiscardR>RRhR
Ri(R!Rtorderingtinclude_delta_closuretremaining_keystcontent_factoryR((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyRF]s 
			c
#@s|rj|dt}n4jj|}tfd|jD}|jt|}|rt}i}x
|D]}	y|	||	dg}
Wn!tk
r|j	|	qnXt}x|
ddk	rL|
d|kr||
d}Pqy|
j||
ddWqtk
rH|j	|
dt}PqXqWx|
d D]}|||<qXW|s|j	|	qqWnj|\}
}|d
krX|dkrt
j|
}nt|
}g}d}x=|D]j}	x$|D]}|	|kr|}PqqW||k	r<|j|gf|}n|ddj|	qWn|dkrztd	|fng}g}xZt|D]L}|j|gfx0|D](}	|j|	|ddj|	qWqWx:|D]2\}}||d
krjj||qqW|t|
}x|D]}	t|	Vq7W|r||}xGj|||D]C\}}t|||
d|}x|jD]}|VqWqrWnx|D]\}}||d
krcg|D]}	|	||	df^q}xj|D]F\}	}||	\}}}t|	|
|	|d|jjdVqWqj|j|d}x"|j|||D]}|VqWqWdS(s;This function is the 'retry' portion for get_record_stream.ROc3@s*|] \}}|j|fVqdS(N(RK(RdR>RS(R!(s//usr/lib/python2.7/dist-packages/bzrlib/knit.pys	<genexpr>siittopologicalt
groupcompressiRBsTvalid values for ordering are: "unordered", "groupcompress" or "topological" not: %riRN(RR(RUR8RRFtdictRLRMRRGRRRRXttsortt	topo_sortRtAssertionErrortreversedt_sort_keys_by_ioRR~RVRFRgRWRR^RR(R!RRRRR\tabsent_keystneeded_from_fallbacktreconstructable_keysR>tchainRt	chain_keyt
global_maptparent_mapstpresent_keystsource_keystcurrent_sourceR>t
key_sourceRtsub_keysRsRvRRmtraw_dataRR
RVtvf((R!s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyR}s	



	

	



	'
!
c	C@st|}|j|dt}i}x:|jD],\}}||krRq4n|d||<q4W|jt|xJ|jD]?}|sPn|j|}|j||jt|qW|S(sSee VersionedFiles.get_sha1s().ROi(RRaR8RLRZRt	get_sha1sRY(	R!RRTt
record_mapRR>RSRR]((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyRs
c@sfd}t}jjr6d}g}n;d}tdg}jrq|jd|jdnt}jr|jd||jd|n|jd||j|}ii}x|D]}	|	j}
|
jdr9|
jd	r9|	j	}j
|	j|\}}
|jnt
}|	j}|	j|krd|d
}nd}|	jdkrt|	jgnl|	j|kr%|dksjsjj|sj|r%|	j|krGy|	jdf}||}Wn,tk
r4|	jd
f}||}nX|j|	}n	|	j	}|	jd
g}|	jdr}|jdnjj|	jt|fg|d
}|	j|||f}d|krjj|s|j|g}|j|t}qn|sjj|gqn|	jdkr_j|	j|tj |	j!dnjj"y|	j!d}Wn>t#j$k
r|	jdf}||}|j|	}nXt%|}yj|	j||Wnt#j&k
rnX|s|	jg}xp|r~|j'd
}||kr||}jj||j(g|D]}|d
^qZ||=qqWqqW|rg}x%|D]}||}|j(|qWjj|dtndS(sInsert a record stream into this container.

        :param stream: A stream of records to insert.
        :return: None
        :seealso VersionedFiles.get_record_stream:
        c@sJy|SWn7tk
rEtj|}|}||<|SXdS(N(RGRRl(RpRqRr(tadaptersR!(s//usr/lib/python2.7/dist-packages/bzrlib/knit.pytget_adapters

s
annotated-R<sknit-annotated-ft-gzsknit-annotated-delta-gzsknit-%sdelta-gzsknit-%sft-gzsknit-s-gziRCs
knit-delta-gzs
knit-ft-gzisno-eolRkRDtmissing_compression_parentsN()RRR^RRtunionRHt
startswithtendswithR(t_parse_record_headerR>RRRERRRRthas_keyRGR4R?RR
R+RRR8R,R"RRJRItflushRRoRtRevisionAlreadyPresentRNR(R!RRtdelta_typesR^tconvertiblestnative_typest
knit_typestbuffered_index_entriesRRaRtdfR/tbufferedRERNRpRrR3R2R8tindex_entrytpendingRt
added_keysR>t
index_entriestall_entries((RR!s//usr/lib/python2.7/dist-packages/bzrlib/knit.pytinsert_record_streams			
		

		
	


	
		"

	


	cC@s
|jjS(sReturn an iterable of keys of missing compression parents.

        Check this after calling insert_record_stream to find out if there are
        any missing compression parents.  If there are, the records that
        depend on them are not able to be inserted safely. For atomic
        KnitVersionedFiles built on packs, the transaction should be aborted or
        suspended - commit will fail at this point. Nonatomic knits will error
        earlier because they have no staging area to put pending entries into.
        (Rtget_missing_compression_parents(R!((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyt#get_missing_compression_parent_keyss
cc@s@|dkrtjj}nt|}t|}t}xP|syg}|jj|}x@|j	D]2\}}||krm|j
||dfqmqmWt|j|}	x|	D]\}
\}}}|j
td|
|||d}
|
dkr|jj|}n|jj|}|j|x|D]}||fVqBWqWt}Wq?tjk
r}|jj|q?Xq?W|r|jrt|t|nxi|jD]^}|sPnt}x5|j|D]$\}}|j|||fVqW|j|qW|j
td||dS(sIterate over the lines in the versioned files from keys.

        This may return lines from other keys. Each item the returned
        iterator yields is a tuple of a line and a text version that that line
        is present in (not introduced in).

        Ordering of results is in whatever order is most suitable for the
        underlying storage format.

        If a progress bar is supplied, it may be used to indicate progress.
        The caller is responsible for cleaning up progress bars (because this
        is an iterator).

        NOTES:
         * Lines are normalised by the underlying store: they will all have \n
           terminators.
         * Lines are returned in arbitrary order.
         * If a requested key did not change any lines (or didn't have any
           lines), it may not be mentioned at all in the result.

        :param pb: Progress bar supplied by caller.
        :return: An iterator over (line, key).
        isWalking contentiN(Rtuit
ui_factorytnested_progress_barRRRRRFRLRt	enumeratet_read_records_iterRYtgettextRRRtremoveR8RRhR
RiRRtreprt#iter_lines_added_or_present_in_keysRRZ(R!Rtpbttotaltdonetkey_recordsR\R>RStrecords_itertkey_idxRct	sha_valueRNt
line_iteratorRRRR((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyRsH	


	
c	C@svg}xi|jD][}|ddkr/qn|j|d|d|d|d|j|d|d!fqW|S(s5Generate a line delta from delta_seq and new_content.iRiiii(RRR(R!t	delta_seqtnew_contentt
diff_hunkstop((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyt_make_line_deltasCcC@s|dk	rtj|}nd}|rDx|D]}|j||}	||dkrn|dk	rn|}
n!tjd|	j|j}
xQ|
jD]C\}}}
|
dkrqn|	j|||
!|j|||
+qWq1W|jrD|jddddkrD|jddd}|jdd|f|jd<qDn|r|dkr|j|d|}|j}|j}tjd||}n|j	||SdS(sMerge annotations for content and generate deltas.

        This is done by comparing the annotations based on changes to the text
        and generating a delta on the resulting full texts. If annotations are
        not being created then a simple delta is created.
        iiis
N(
Rtdifft_PrematchedMatcherRRRR,tget_matching_blocksRR(R!R1RERR:R^RRt
parent_keyt
merge_contenttseqRtjRRtreference_contentRR((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyR*s2	
	*$$cC@s3|j|\}}|j||||dfS(sParse an original format knit record.

        These have the last element of the key only present in the stored data.
        i(R)RD(R!RRcR/trecord_contents((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyRbBscC@stjdddt|}y|j||j}Wn;tk
rw}t|d||jjt	|fnX||fS(sParse a record header for consistency.

        :return: the header and the decompressor stream.
                 as (stream, header_record)
        tmodetrbtfileobjsWhile reading {%s} got %s(%s)(
tgziptGzipFileRREtreadlinet	ExceptionR	RR$R#(R!R>RRR/R((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyRKs#cC@s0tjdddt|}y|j}Wn;tk
rk}t|d||jjt|fnX|j	d}|j
|}|j	}t|t|dkrt|dt|t|d|d|fn|d	|dkrt|d
||dfn|j
||fS(NRRRs(Corrupt compressed record %r, got %s(%s)iis6incorrect number of lines %s != %s for version {%s} %sisend %s
s)unexpected version end line %r, wanted %r(RRRt	readlinesRR	RR$R#RNRCRRR(R!RcRRRRR/R((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyR)[s(	#
c	c@s|s
dStt|dtjd}|s5dS|jjg|D]\}}|^qE}xStt||D]<\\}}}|j|d|\}}|||fVqvWdS(sRead text records from data file and yield result.

        The result will be returned in whatever is the fastest to read.
        Not by the order requested. Also, multiple requests for the same
        record will only yield 1 response.

        :param records: A list of (key, access_memo) entries
        :return: Yields (key, contents, digest) in the order
                 read, not the order requested
        NR>ii(	tsortedRReRfR
tget_raw_recordsRRRb(	R!Rmtneeded_recordsR>R
RRcR1R-((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyRvs!	"%cc@sXxQ|j|D]@\}}|j||\}}|j|||dfVqWdS(sRead text records from data file and yield raw data.

        This unpacks enough of the text record to validate the id is
        as expected but thats all.

        Each item the iterator yields is (key, bytes,
            expected_sha1_of_full_text).
        iN(RgRR(R!RmR>RcRR/((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyt_read_records_iter_raws	
cc@srt|r@g|D]\}}|^q}|jj|}nx+|D]#\}}|j}||fVqGWdS(sRead text records from data file and yield raw data.

        No validation is done.

        Yields tuples of (key, data).
        N(RR
RRG(R!RmR>R
tneeded_offsetstraw_recordsRc((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyRgs	cC@sd|dt||fg}|j|p/||jd|dx9|D]1}t|tk	rOtdt|qOqOW|r|dddkrtd|ntj|}t||fS(sConvert key, digest, lines into a raw data block.

        :param key: The key of the record. Currently keys are always serialised
            using just the trailing component.
        :param dense_lines: The bytes of lines but in a denser form. For
            instance, if lines is a list of 1000 bytestrings each ending in
            \n, dense_lines may be a list with one line in it, containing all
            the 1000's lines and their \n's. Using dense_lines if it is
            already known is a win because the string join to create bytes in
            this function spends less time resizing the final string.
        :return: (len, a StringIO instance with the raw data ready to read.)
        sversion %s %d %s
isend %s
sdata must be plain bytes was %ss
scorrupt lines value %r(	RRRRR#RRt
tuned_gziptchunks_to_gzip(R!R>R-RR7RztchunkRT((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyR+s
 
cC@s4|j}t|dkr0t|dn|S(Nis.unexpected number of elements in record header(RRR	(R!RR/((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyRCs
cC@sfdtjkr"tjddn|jg|j}t}x!|D]}|j|jqEW|S(sSee VersionedFiles.keys.tevilis keys scales with size of history(	tdebugtdebug_flagsttracetmutter_callsiteRRRRYR(R!R[RR((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyRs	
N(2R$R%R&RRR#RRRR8R"R%RRR9R<R:RRERDR(RKRURR'RXRaR_R^tclassmethodRrt_STREAM_MIN_BUFFER_SIZER~RFRRRRRRR*RbRR)RRRgR+RCR(((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyRSs`						o								(	#				 #*	 	w			O		+								t_ContentMapGeneratorcB@sGeZdZddZdZdZdZdZdZRS(s7Generate texts or expose raw deltas for a set of texts.RBcC@s
||_dS(N(t	_ordering(R!R((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyR#scC@sZ||jkrI|jj}tj|jd}t||jS|j|SdS(sGet the content object for key.RDN(	t
nonlocal_keysRFRGRRJRIRKR>Ry(R!R>RR((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyRs
cc@s x|jD]}|Vq
WdS(s;Get a record stream for the keys requested during __init__.N(t_work(R!R((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyRFscc@s|jdkr*|jj|j|_n|j}t|}xk|jjD]]}|s\PnxJ|j||j	t
D]0}|jdkrqun|j|j
|VquWqLW|jdkrtdnt
}xG|jD]<}||jkrqnt||j|||Vt}qWdS(sProduce maps of text and KnitContents as dicts.

        :return: (text_map, content_map) where text_map contains the texts for
            the requested versions and content_map contains the KnitContents.
        RCs'_raw_record_map should have been filledN(RRRR'RRRRRFRR8RHRR>t_raw_record_mapRRsR(R!Rtmissing_keysRRRwR>((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyRs*		
c	C@s||jkr|j|St|jdk}|jdkrY|jj|j|_n|j}x|jD]}||jkrqlng}|}x|dk	r-y||\}}}	}
Wn t	k
rt
||nX|j||||	f|
}||jkr|j|dddfPqqWd}xt|D]r\}}}}	||jkrr|j|}qA|j
j|d|||d|\}}
|rA||j|<qAqAW|j}t|}||	krlt|||	||qlqlW|r|j|S|SdS(NiiR(t
_contents_mapRRt_record_mapRRR_RRRGRRRRR=R,RR(R!t
requested_keytmultiple_versionsRR>t
componentstcursorRRR-RGR1tcomponent_idR:R,t
actual_sha((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyRysN		
c
C@sg}|jd|jjjr2|jdn
|jd|jdjg|jD]$}||jkrUdj|^qUg}x|jjD]\}\}\}}}dj|}|j	j
|d}	|	dkrd}
ndjd|	D}
|}|rd}nd	}|r9dj|}
nd}
|jd
||
|||
t||fqWdj|}|j|dj|}|S(
sGet the bytes to put on the wire for 'key'.

        The first collection of bytes asked for returns the serialised
        raw_record_map and the additional details (key, parent) for key.
        Subsequent calls return just the additional details (key, parent).
        The wire storage_kind given for the first key is 'knit-delta-closure',
        For subsequent keys it is 'knit-delta-closure-ref'.

        :param key: A key from the content generator.
        :return: Bytes to put on the wire.
        sknit-delta-closureR^R<s	RcsNone:cs@s|]}dj|VqdS(RcN(R@(RdR>((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pys	<genexpr>stTtFs%s
%s
%s
%s
%s
%d
%ss
N(
RRRR^R@RRRRLRRlRR(R!RR>t
map_byte_listtrecord_bytesRRiRGRgRERhtmethod_bytestnoeol_bytest
next_bytest	map_bytesR3((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyRxYs:

(	(			
(	R$R%R&R#RRFRRyRx(((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyRs	
		&	:RVcB@s#eZdZdddddZRS(s;Content map generator reading from a VersionedFiles object.RBcC@stj|d|||_t||_|dkrFt|_nt||_||_	i|_
i|_d|_|dkr|jj
|dt|_n	||_|jj|_dS(syCreate a _ContentMapGenerator.

        :param versioned_files: The versioned files that the texts are being
            extracted from.
        :param keys: The keys to produce content maps for.
        :param nonlocal_keys: An iterable of keys(possibly intersecting keys)
            which are known to not be in this knit, but rather in one of the
            fallback knits.
        :param global_map: The result of get_parent_map(keys) (or a supermap).
            This is required if get_record_stream() is to be used.
        :param raw_record_map: A unparsed raw record map to use for answering
            contents.
        RRON(RR#RRRRRRt	frozensetRt	_text_mapRRR^R8RR(R!RRRRRnR((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyR#s						N(R$R%R&RR#(((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyRVsR{cB@s)eZdZdZdZdZRS(s4Content map generator sourced from a network stream.cC@s||_i|_i|_i|_d|_g|_tdd|_|}|j	d|}|||!}|d}|dkrt
|_nt|_|j	d|}|||!}|d}g|j
dD]!}|rt|j
d^q|_t|}x||kr|j	d|}t|||!j
d}|d}|j	d|}|||!}|dkrd}n=tg|j
dD]!}|rt|j
d^q}||j|<|d}|j	d|}|||!}|}	|d}|j	d|}|||!}|dk}
|d}|j	d|}|||!}|snd}nt|||!j
d}|d}|j	d|}|||!}t|}|d}||||!}
||}|
|	|
f|f|j|<qWdS(	s;Construct a _NetworkContentMapGenerator from a bytes block.s
iR^s	RcsNone:RN(t_bytesRRRRRRRRR~RRRRRRRR(R!R3R|RRRRR>RERRiRGRR((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyR#sl						



$

	$






	



cc@s?t}x2|jD]'}t||j|||Vt}qWdS(s=Get a record stream for for keys requested by the bytestream.N(R8RRsRR(R!RwR>((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyRF	scC@s|jS(N(R(R!((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyRx	s(R$R%R&R#RFRx(((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyR{s	K	RcB@seZdZdZdZeedZdZdZdZ	dZ
dZd	Zd
Z
dZdZd
ZdZdZejZgdZdZdZejZdZdZdZdZeZdZ RS(sFManages knit index files

    The index is kept in memory and read on startup, to enable
    fast lookups of revision information.  The cursor of the index
    file is always pointing to the end, making it easy to append
    entries.

    _cache is a cache for fast mapping from version id to a Index
    object.

    _history is a cache for fast mapping from indexes to version ids.

    The index data format is dictionary compressed when it comes to
    parent references; a index entry may only have parents that with a
    lover index number.  As a result, the index is topological sorted.

    Duplicate entries may be written to the index for a single version id
    if this is done then the latter one completely replaces the former:
    this allows updates to correct version and parent information.
    Note that the two entries may share the delta, and that successive
    annotations and references MUST point to the first entry.

    The index file on disc contains a header, followed by one line per knit
    record. The same revision can be present in an index file more than once.
    The first occurrence gets assigned a sequence number starting from 0.

    The format of a single line is
    REVISION_ID FLAGS BYTE_OFFSET LENGTH( PARENT_ID|PARENT_SEQUENCE_ID)* :

    REVISION_ID is a utf8-encoded revision id
    FLAGS is a comma separated list of flags about the record. Values include
        no-eol, line-delta, fulltext.
    BYTE_OFFSET is the ascii representation of the byte offset in the data file
        that the compressed data starts at.
    LENGTH is the ascii representation of the length of the data file.
    PARENT_ID a utf-8 revision id prefixed by a '.' that is a parent of
        REVISION_ID.
    PARENT_SEQUENCE_ID the ascii representation of the sequence number of a
        revision id already in the knit that is a parent of REVISION_ID.
    The ' :' marker is the end of record marker.

    partial writes:
    when a write is interrupted to the index file, it will result in a line
    that does not end in ' :'. If the ' :' is not present at the end of a line,
    or at the end of the file, then the record that is missing it will be
    ignored by the parser.

    When writing new records to the index file, the data is preceded by '
'
    to ensure that records always start on new lines even if the last write was
    interrupted. As a result its normal for the last line in the index to be
    missing a trailing newline. One can be added with no harmful effects.

    :ivar _kndx_cache: dict from prefix to the old state of KnitIndex objects,
        where prefix is e.g. the (fileid,) for .texts instances or () for
        constant-mapped things like .revisions, and the old state is
        tuple(history_vector, cache_dict).  This is used to prevent having an
        ABI change with the C extension that reads .kndx files.
    s# bzr knit index 8
cC@sD||_||_||_||_||_|jt|_dS(s.Create a _KndxIndex on transport using mapper.N(t
_transportt_mappert
_get_scopet
_allow_writest
_is_lockedt_reset_cacheR8R(R!RRt	get_scopetallow_writest	is_locked((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyR#X	s					
c	C@s|r1td|D}tj||ni}xa|D]Y}|d}|d }|jj|d}	|j|	|gf}
|
dj|q>Wx}t|D]o}	||	\}}
|j|gg}|j|d}|j|dj	}
yx|
D]\}}\}}}}|d
kr7d}nd|ddj||||j|f}t
|tk	rtdt
|n|j||j|||||qWt|r|jj|	d	j|n|j|	|Wq|
|f|j|<qXqWd
S(s?Add multiple records to the index.

        :param records: a list of tuples:
                         (key, options, access_memo, parents).
        :param random_id: If True the ids being added were randomly generated
            and no check for existence will be performed.
        :param missing_compression_parents: If True the records being added are
            only compressed against texts already in the index (or inside
            records). If False the records all refer to unavailable texts (or
            texts inside records) as compression parents.
        cs@s|]}|dVqdS(iN((RdR((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pys	<genexpr>q	siis.kndxis
%s %s %s %s %s :Rsdata must be utf8 was %sR<N((RRRRtmapRRt_load_prefixest_kndx_cacheRRR@t_dictionary_compressRR#Rt
_cache_keyRRtappend_bytest_init_index(R!RmR RRtpathsRR>Rtpatht	path_keysRtorig_historyt
orig_cacheR2RVtposR2RER((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyR,b	sD


"	
cC@st|jdS(s+See _KnitGraphIndex.scan_unvalidated_index.N(Rtscan_unvalidated_index(R!R((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyR	scC@st|jdS(s4See _KnitGraphIndex.get_missing_compression_parents.N(RR(R!((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyR	sc
C@s|d }|d}td|D}x7|D]/}	|	d |kr1td||fq1q1W|j|\}
}||
krt|}|j|n|
|d}||||||f|
|<dS(sCache a version record in the history array and index cache.

        This is inlined into _load_data for performance. KEEP IN SYNC.
        (It saves 60ms, 25% of the __init__ overhead on local 4000 record
         indexes).
        ics@s|]}|dVqdS(iN((RdR0((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pys	<genexpr>	ssmismatched prefixes for %r, %riN(RRRRR(
R!R>R2RR2tparent_keysRRRER0RthistoryR((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyR	s$


cC@sU|j}|dkr*tj|n||jkrQtd|d|ndS(NR<tbadlinetfilename(RRRtHEADERR
(R!tfpR((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pytcheck_header	s
cC@sD|jstj|n|j|jkr@|jndS(N(RRtObjectNotLockedR	t_scopeR(R!((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyt_check_read	scC@se|jstj|n|j|jkr@|jn|jdkratj|ndS(s#Assert if not writes are permitted.twN(RRR%R	R&Rt_modetReadOnlyObjectDirtiedError(R!((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyR	s
c
C@s|j|}i}x|D]}||kr4qn|j|}||}|dkrbd}n
|d}d|j|k}|j|}	|	||||ff||<qW|S(sGet the method, index_memo and compression parent for keys.

        Ghosts are omitted from the result.

        :param keys: An iterable of keys.
        :return: A dict of key:(index_memo, compression_parent, parents,
            record_details).
            index_memo
                opaque structure to pass to read_records to extract the raw
                data
            compression_parent
                Content that this record is built upon, may be None
            parents
                Logical parents of this node
            record_details
                extra information about the content which needs to be passed to
                Factory.parse_record
        Rkisno-eolN(R'R=Rtget_optionstget_position(
R!RR>RR>RRERNRiR
((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyRF	s

	
cC@sE|j|}d|krdSd|kr/dStj||dS(s+Return compression method of specified key.Rks
line-deltaN(R+RtKnitIndexUnknownMethod(R!R>R2((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyR=	scC@sg|j|\}}|j|gy|j|d|dSWn tk
rbt||nXdS(sIReturn a list representing options.

        e.g. ['foo', 'bar']
        iiN(t
_split_keyRRRGR(R!R>Rtsuffix((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyR+
s
c
C@s!td|D}|j|i}i}t}t|}x|r|j}||krkqGn|d }y!|j|d|dd}	Wntk
r|j|qGXtg|	D]}
||
f^q}|||<|jg|D]}||kr|^qqGW||fS(s&See CombinedGraphIndex.find_ancestry()cs@s|]}|d VqdS(iN((RdR>((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pys	<genexpr>
siii(	RRRRNRRGRRR(
R!RtprefixesRR>Rtpending_keysR>Rtsuffix_parentsR/Rtp((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyt
find_ancestry
s*
		
!
 
c@std|D}|j|i}xm|D]e}|d y!|jd|dd}Wntk
rtq0Xtfd|D||<q0W|S(sGet a map of the parents of keys.

        :param keys: The keys to look up parents for.
        :return: A mapping from keys to parents. Absent keys are absent from
            the mapping.
        cs@s|]}|d VqdS(iN((RdR>((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pys	<genexpr>8
siiic3@s|]}|fVqdS(N((RdR/(R(s//usr/lib/python2.7/dist-packages/bzrlib/knit.pys	<genexpr>B
s(RRRRGR(R!RR0RR>R2((Rs//usr/lib/python2.7/dist-packages/bzrlib/knit.pyR'.
s



!
cC@sO|j|\}}|j|g|j|d|}||d|dfS(sReturn details needed to access the version.

        :return: a tuple (key, data position, size) to hand to the access
            logic to get the record.
        iii(R.RR(R!R>RR/tentry((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyR,F
scC@sPt}|j|j|j||jd|jj||dtdS(sInitialize an index.itcreate_parent_dirN(RRR"t
writelinestseekRtput_file_non_atomicR8(R!Rtextra_linestsio((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyRS
s	

c	C@st}t|jtkr*dg}nmt}x<|jjD]+}tjj|\}}|j	|qCWg|D]}|jj
|^qy}|j|x>|D]6}x-|j|dD]}|j	||fqWqW|S(sOGet all the keys in the collection.

        The keys are not ordered.
        i((
RRRRRtiter_files_recursivetosRtsplitextRtunmapRR(	R!RR0trelpathstquoted_relpathRtextRR/((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyR_
s		%

cC@s |jx|D]}||jkri|_g|_||_yv|jj|d}|jj|}zt	||Wd|j
X|j|jf|j|<|`|`|`Wqtk
rigf|j|<t|jt
kr|j|n|`|`|`qXqqWdS(sLoad the indices for prefixes.s.kndxN(R'Rt_cachet_historyt	_filenameRRRRlt
_load_dataRRRRR(R!R0RRR#((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyRu
s.

			

cC@sBi}x5|D]-}|j|d g}|j|dq
W|S(s,Turn keys into a dict of prefix:suffix_list.i(RR(R!RRR>tprefix_keys((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyt_partition_keys
s

cC@s|s
dSg}|dd }|j|d}xx|D]p}|d |kr_td|n|d|kr|jt||ddq6|jd|dq6Wdj|S(sDictionary compress keys.

        :param keys: The keys to generate references to.
        :return: A string representation of keys. keys which are present are
            dictionary compressed, and others are emitted as fulltext with a
            '.' prefix.
        R<iismismatched prefixes for %rit.Rf(RRRR#R@(R!Rtresult_listRRR>((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyR
s
"cC@sCi|_|j|_|j}|r6d|_n	d|_dS(NR(Rk(RR	R&R
R)(R!R((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyR
s	c@sfd}|jd|S(suFigure out an optimal order to read the records for the given keys.

        Sort keys, grouped by index and sorted by position.

        :param keys: A list of keys whose records we want to read. This will be
            sorted 'in-place'.
        :param positions: A dict, such as the one returned by
            _get_components_positions()
        :return: None
        c@s$|d}|dd |dfS(Niii((R>R
(R(s//usr/lib/python2.7/dist-packages/bzrlib/knit.pytget_sort_key
sR>(Rd(R!RRRK((Rs//usr/lib/python2.7/dist-packages/bzrlib/knit.pyR
scC@s|d |dfS(s#Split key into a prefix and suffix.i((R!R>((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyR.
s(!R$R%R&R"R#RR,RRRR$R'RRFR=R+R4R'R,Rt_has_key_from_parent_mapRRRRt_missing_keys_from_parent_mapRRHRRRRR.(((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyR	s69	
5									$	
												RcB@seZdZeededZdZeedZdZ	dZ
dZdZdZ
d	Zd
ZedZdZd
ZdZdZdZdZdZejZdZejZdZdZe Z RS(s1A KnitVersionedFiles index layered on GraphIndex.cC@s||_||_||_||_|rC|rCt|dn||_||_t|_|rvt	|_
n	d|_
dS(snConstruct a KnitGraphIndex on a graph_index.

        :param graph_index: An implementation of bzrlib.index.GraphIndex.
        :param is_locked: A callback to check whether the object should answer
            queries.
        :param deltas: Allow delta-compressed records.
        :param parents: If True, record knits parents, if not do not record
            parents.
        :param add_callback: If not None, allow additions to the index and call
            this callback with a list of added GraphIndex nodes:
            [(node, value, node_refs), ...]
        :param is_locked: A callback, returns True if the index is locked and
            thus usable.
        :param track_external_parent_refs: If True, record all external parent
            references parents from added records.  These can be retrieved
            later by calling get_missing_parents().
        s4Cannot do delta compression without parent tracking.N(t
_add_callbackt_graph_indext_deltast_parentsR	RRRt_missing_compression_parentsRt_key_dependenciesR(R!RRRRERttrack_external_parent_refs((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyR#
s				
		cC@sd|jj|jfS(Ns%s(%r)(RR$RO(R!((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyRscC@s|jstj|ni}t}|j}xP|D]H\}}}	}
|jrt|
}
|dk	r|j||
qn|	\}}}
d|krd}nd}|d||
f7}|j	sd|krt
|dqn|jrT|j	rHd|kr9|
|
dff}|rE|j|
dqEqQ|
df}qr|
f}n|
rlt
|dnd
}||f||<q:W|sF|j|}x|D]\}}}}|d	 }
t
j||}|d	d	 }|d||ddks|
|kr8t
j|}t
|d
||f|fn||=qWng}|jrxo|jD](\}\}}|j|||fqbWn6x3|jD]%\}\}}|j||fqW|j||r|j||jj|n|jj|dS(sYAdd multiple records to the index.

        This function does not insert data into the Immutable GraphIndex
        backing the KnitGraphIndex, instead it prepares data for insertion by
        the caller and checks that it is safe to insert then calls
        self._add_callback with the prepared GraphIndex nodes.

        :param records: a list of tuples:
                         (key, options, access_memo, parents).
        :param random_id: If True the ids being added were randomly generated
            and no check for existence will be performed.
        :param missing_compression_parents: If True the records being added are
            only compressed against texts already in the index (or inside
            records). If False the records all refer to unavailable texts (or
            texts inside records) as compression parents.
        sno-eolReRfs%d %ds
line-deltas+attempt to add line-delta in non-delta knitis5attempt to add node with parents in parentless index.is*inconsistent details in add_records: %s %sN(((RNRt
ReadOnlyErrorRRSRQRRtadd_referencesRPR	Rt_get_entrieststatic_tuplet	as_tuplesRLRRZRRRY(R!RmR RRtcompression_parentstkey_dependenciesR>R2R8RERRR2tvaluet	node_refst
present_nodestpassedtpassed_parentsR((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyR,sj								
		

cC@s|jrD|jdd}|j|j||jj|n|jdk	rx6|jD]%}|jj	|d|ddq`WndS(sInform this _KnitGraphIndex that there is an unvalidated index.

        This allows this _KnitGraphIndex to keep track of any missing
        compression parents we may want to have filled in to make those
        indices valid.

        :param graph_index: A GraphIndex
        tref_list_numiiiN(
RPtexternal_referencesRZR'RRRYRSRtiter_all_entriesRV(R!Rtnew_missingtnode((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyRas		cC@s
t|jS(sReturn the keys of missing compression parents.

        Missing compression parents occur when a record stream was missing
        basis texts, or a index was scanned that had missing basis texts.
        (RRR(R!((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyRtscC@s5|jj|j|jjt|jjS(s#Return the keys of missing parents.(RStsatisfy_refs_for_keysR'tget_unsatisfied_refsR(R!((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pytget_missing_parents|s	cC@s"|jstj|ndS(s!raise if reads are not permitted.N(RRR%(R!((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyR'scC@s"|jstj|ndS(s#Assert if writes are not permitted.N(RRR%(R!((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyRscC@sE|dd}|sdSt|dkr=td|n|dS(Niis Too many compression parents: %ri(RRR(R!tan_entryRZ((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyt_compression_parentsc
C@s|ji}|j|t}x|D]}|d}|jsKd}n|dd}|jskd	}n|j|}|dddk}|rd}	nd}	|j||||	|ff||<q)W|S(
sGet the method, index_memo and compression parent for version_ids.

        Ghosts are omitted from the result.

        :param keys: An iterable of keys.
        :return: A dict of key:
            (index_memo, compression_parent, parents, record_details).
            index_memo
                opaque structure to pass to read_records to extract the raw
                data
            compression_parent
                Content that this record is built upon, may be None
            parents
                Logical parents of this node
            record_details
                extra information about the content which needs to be passed to
                Factory.parse_record
        iiiiRes
line-deltaRk(N(R'RWRRQRPRRjt_node_to_position(
R!RRtentriesR5R>REtcompression_parent_keyRiR((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyRFs&


					cc@st|}t}|jrTx~|jj|D]}|V|j|dq1WnKxH|jj|D]4}|d|d|ddfV|j|dqgW|r|j|}|rt|j|qndS(sYGet the entries for keys.

        :param keys: An iterable of index key tuples.
        iiiN((RRQROtiter_entriesRRMRRN(R!Rt
check_presentt
found_keysReR((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyRWs		cC@s|j|j|S(s+Return compression method of specified key.(t_get_methodt	_get_node(R!R>((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyR=scC@s(|js
dS|j|r dSdSdS(NRks
line-delta(RPRj(R!Re((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyRqs
	cC@sEyt|j|gdSWn tk
r@t||nXdS(Ni(RRWt
IndexErrorR(R!R>((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyRrs
cC@sI|j|}|j|g}|dddkrE|jdn|S(sIReturn a list representing options.

        e.g. ['foo', 'bar']
        iiResno-eol(RrRqR(R!R>ReR2((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyR+s
cC@s|jj|dS(s&See CombinedGraphIndex.find_ancestry()i(ROR4(R!R((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyR4scC@su|j|j|}i}|jrRxF|D]}|dd||d<q/Wnx|D]}d||d<qYW|S(sGet a map of the parents of keys.

        :param keys: The keys to look up parents for.
        :return: A mapping from keys to parents. Absent keys are absent from
            the mapping.
        iiiN(R'RWRQR(R!RtnodesRRe((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyR's
	

cC@s|j|}|j|S(sReturn details needed to access the version.

        :return: a tuple (index, data position, size) to hand to the access
            logic to get the record.
        (RrRk(R!R>Re((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyR,scC@s.|jg|jjD]}|d^qS(sOGet all the keys in the collection.

        The keys are not ordered.
        i(R'RORc(R!Re((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyRs
cC@s<|ddjd}|dt|dt|dfS(s+Convert an index value to position details.iiRfi(RR(R!Retbits((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyRk!sc@sfd}|jd|S(suFigure out an optimal order to read the records for the given keys.

        Sort keys, grouped by index and sorted by position.

        :param keys: A list of keys whose records we want to read. This will be
            sorted 'in-place'.
        :param positions: A dict, such as the one returned by
            _get_components_positions()
        :return: None
        c@s|dS(Ni((R>(R(s//usr/lib/python2.7/dist-packages/bzrlib/knit.pytget_index_memo1sR>(Rd(R!RRRv((Rs//usr/lib/python2.7/dist-packages/bzrlib/knit.pyR&sN(!R$R%R&RR8RR#RR,RRRhR'RRjRFRWR=RqRrR+R4R'R,RRLRRRMRRkRR(((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyR
s6#	Y								*													RcB@s2eZdZdZdZdZdZRS(s!Access to records in .knit files.cC@s||_||_dS(sCreate a _KnitKeyAccess with transport and mapper.

        :param transport: The transport the access object is rooted at.
        :param mapper: The mapper used to map keys to .knit files.
        N(RR(R!RR((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyR#@s	c	C@st|tk	r+tdt|ng}d}x|D]\}}|jj|}y(|jj|d||||!}WnQtjk
r|jj	t
j||jj|d||||!}nX||7}|j|||fq>W|S(s
Add raw knit bytes to a storage area.

        The data is spooled to the container writer in one bytes-record per
        raw data item.

        :param sizes: An iterable of tuples containing the key and size of each
            raw data segment.
        :param raw_data: A bytestring containing the data.
        :return: A list of memos to retrieve the record later. Each memo is an
            opaque index memo. For _KnitKeyAccess the memo is (key, pos,
            length), where the key is the record key.
        sdata must be plain bytes was %sis.knit(
RR#RRRRRRRtmkdirRtdirnameR(	R!t	key_sizesRRRR>R2Rtbase((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyR+Is"

cC@sdS(sfFlush pending writes on this access object.
        
        For .knit files this is a no-op.
        N((R!((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyRmsc
c@sg}d}xx|D]p\}}}||d krH|j||fq|dk	rj|j||fn|d }||fg}qW|dk	r|j||fnxU|D]M\}}	|jj|d}
x(|jj|
|	D]\}}|VqWqWdS(sGet the raw bytes for a records.

        :param memos_for_retrieval: An iterable containing the access memo for
            retrieving the bytes.
        :return: An iterator over the bytes of the records.
        is.knitN(RRRRRtreadv(
R!tmemos_for_retrievalt
request_liststcurrent_prefixR>Rtlengthtcurrent_listRtread_vectorRRRc((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyRts
"(R$R%R&R#R+RR(((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyR=s
			$	cC@st|}t|j|S(sAnnotate a knit with no cached annotations.

    This implementation is for knits with no cached annotations.
    It will work for knits with cached annotations, but this is not
    recommended.
    (RRR(R_trevision_idR((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyt
annotate_knitsRcB@sbeZdZdZdZd
dZdZdZdZ	dZ
dZd	ZRS(s$Build up the annotations for a text.cC@sMtjj||i|_i|_i|_i|_i|_i|_dS(N(	Rt	AnnotatorR#t_matching_blockst_content_objectst_num_compression_childrent_pending_deltast_pending_annotationt_all_build_details(R!R((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyR#s					cC@st|g}g}t}d|j|<x=|rj|}|jjj|}|jj|t}x|jD]\}}|\}}	}
}|
|j|<d|_
|j||f|jg|
D]}||jkr|^q|
r7xC|
D]8}
|
|jkr#|j|
cd7<qd|j|
<qWn|	ru|	|jkrb|j|	cd7<qrd|j|	<ququW|j
|j}|r.x|D]}||jkrK||jkrK|j||j|}
x@|
D]8}
|
|jkr|j|
cd7<qd|j|
<qW|jg|
D]}||jkr&|^q&qtj||jqWq.q.W|j||fS(sGet the graphs for building texts and annotations.

        The data you need for creating a full text may be different than the
        data you need to annotate that text. (At a minimum, you need both
        parents to create an annotation, but only need 1 parent to generate the
        fulltext.)

        :return: A list of (key, index_memo) records, suitable for
            passing to read_records_iter to start reading in the raw data from
            the pack file.
        iN(Rt_num_needed_childrent_vfRRFRRYRLt_parent_mapRt_heads_providerRRRMRt_text_cacheRRRtreverse(R!R>RRmtann_keystthis_iterationR\RSR
RNRRR3Rtmissing_versions((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyt_get_build_graphsP	
		
	




 
cc@sQt|jjdkrGx(tjj||d|D]}|Vq4WdSxtrLy|j|\}}xht|j	|D]Q\}\}}}	|dk	r|jtd|t|n|||	fVq~Wx5|D]-}|j
|}t|}	|||	fVqWdSWqJtjk
rH}
|jjj|
|jjqJXqJWdS(NiRt
annotating(RRRRRt_get_needed_textsR8RRt_extract_textsRRYRRRRhR
RiRtclear(R!R>RtvRmRtidxtsub_keyR,RR((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyRs("		%"

cC@s?|j|}ttj|||}||j||f<dS(N(RRRRR(R!R>RNR:Rtparent_linestblocks((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyt_cache_delta_blocks
s
cC@sgd}|r||jkrG|jj|gj||||fdS|j|}|d8}|dkr|jj|}|jj|n||j|<|j|}|jjj	||||dt
\}	}n$|jjj	|||d\}	}
|jj|ddkr%|	|j|<n|	j}||j
|<|dk	rc|j||||n|S(NiiR(RRRRRRRNRRR=R8RlR,RR(R!R>RRNRRR:tnumRR1RVR((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyt_expand_record
s2




cC@s]||f}||jkrD|jj|}|j|}||fStjj||||S(sGet the list of annotations for the parent, and the matching lines.

        :param text: The opaque value given by _get_needed_texts
        :param parent_key: The key for the parent text
        :return: (parent_annotations, matching_blocks)
            parent_annotations is a list as long as the number of lines in
                parent
            matching_blocks is a list of (parent_idx, text_idx, len) tuples
                indicating which lines match between the two texts
        (RRNt_annotations_cacheRRt#_get_parent_annotations_and_matches(R!R>R,Rt	block_keyRtparent_annotations((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyR:
s

cC@sg}||jkr|}|jj|}xZ|D]O\}}}}|j|||||}	|j||r4|j|q4q4Wn||jkr|jj|}|jg|D]$\}
}|j|
|r|
^qn|S(sxThe content for 'key' was just processed.

        Determine if there is any more pending work to be processed.
        (RRNRt_check_ready_for_annotationsRRR(R!R>t	to_returnRNtchildrent	child_keyRRRRRtp_keys((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyt_process_pendingM
s"cC@sJxC|D];}||jkr|jj|gj||ftSqWtS(sreturn true if this text is ready to be yielded.

        Otherwise, this will return False, and queue the text into
        self._pending_annotation
        (RRRRRR8(R!R>RR((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyRd
s
cc@si}x|jj|D]\}}}|j|}|\}}}	}
|j||	|||
}|dkrtqn|j||	}|r||t|fVn|j|}
x^|
r|
}g}
xE|D]=}|j|}||t|fV|
j	|j|qWqWqWdS(s1Extract the various texts needed based on recordsN(
RRRRRRRRRR(R!Rmtpending_deltasR>RR-RSRVRNRRRtyield_this_textt
to_processtthis_process((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyRt
s("
			

N(
R$R%R&R#RRRRRRRRR(((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyRs		B		'			(t_load_data_c(t
_load_data_py(OR&t
__future__Rt	cStringIORt	itertoolsRReR=tbzrlib.lazy_importRtglobalstbzrlibRRRt
bzrlib.errorsRRR	R
RRtbzrlib.osutilsR
RRRtbzrlib.versionedfileRRRRRRRtDATA_SUFFIXtINDEX_SUFFIXRtobjectRR'R5R;RARSRURWRsR}RRRRKRRRRRRRRRRVR{RRRRRRtbzrlib._knit_load_data_pyxRRFtImportErrorRtfailed_to_load_extensiontbzrlib._knit_load_data_pyR(((s//usr/lib/python2.7/dist-packages/bzrlib/knit.pyt<module>4sr	."4P,		 8)%"z?		%		.YaR	


Copyright © 2017 || Recoded By Mr.Bumblebee