-=[ Mr. Bumblebee ]=-
_Indonesia_

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

ó
î:ïNc@@s&dZddlmZddlmZmZmZddlmZm	Z	m
Z
defd„ƒYZdefd„ƒYZ
d	efd
„ƒYZdefd„ƒYZd
efd„ƒYZdefd„ƒYZde
fd„ƒYZde
fd„ƒYZd„Zd„Zd„Zd„ZdS(s)Searching in versioned file repositories.i(tabsolute_import(tdebugtrevisionttrace(tDictParentsProvidertGraphtinvert_parent_maptAbstractSearchResultcB@s;eZdZd„Zd„Zd„Zd„Zd„ZRS(sºThe result of a search, describing a set of keys.
    
    Search results are typically used as the 'fetch_spec' parameter when
    fetching revisions.

    :seealso: AbstractSearch
    cC@st|jƒ‚dS(sReturn a recipe that can be used to replay this search.

        The recipe allows reconstruction of the same results at a later date.

        :return: A tuple of `(search_kind_str, *details)`.  The details vary by
            kind of search result.
        N(tNotImplementedErrort
get_recipe(tself((s4/usr/lib/python2.7/dist-packages/bzrlib/vf_search.pyR	+scC@st|jƒ‚dS(s=Return a tuple that can be transmitted via the HPSS protocol.N(Rtget_network_struct(R
((s4/usr/lib/python2.7/dist-packages/bzrlib/vf_search.pyR5scC@st|jƒ‚dS(sOReturn the keys found in this search.

        :return: A set of keys.
        N(Rtget_keys(R
((s4/usr/lib/python2.7/dist-packages/bzrlib/vf_search.pyR9scC@st|jƒ‚dS(s5Return false if the search lists 1 or more revisions.N(Rtis_empty(R
((s4/usr/lib/python2.7/dist-packages/bzrlib/vf_search.pyR
@scC@st|jƒ‚dS(sûCreate a new search by refining this search.

        :param seen: Revisions that have been satisfied.
        :param referenced: Revision references observed while satisfying some
            of this search.
        :return: A search result.
        N(Rtrefine(R
tseent
referenced((s4/usr/lib/python2.7/dist-packages/bzrlib/vf_search.pyRDs(t__name__t
__module__t__doc__R	RRR
R(((s4/usr/lib/python2.7/dist-packages/bzrlib/vf_search.pyR"s	
			tAbstractSearchcB@seZdZd„ZRS(sbA search that can be executed, producing a search result.

    :seealso: AbstractSearchResult
    cC@st|jƒ‚dS(sòConstruct a network-ready search result from this search description.

        This may take some time to search repositories, etc.

        :return: A search result (an object that implements
            AbstractSearchResult's API).
        N(Rtexecute(R
((s4/usr/lib/python2.7/dist-packages/bzrlib/vf_search.pyRUs(RRRR(((s4/usr/lib/python2.7/dist-packages/bzrlib/vf_search.pyROstSearchResultcB@sMeZdZd„Zd„Zd„Zd„Zd„Zd„Zd„Z	RS(sŸThe result of a breadth first search.

    A SearchResult provides the ability to reconstruct the search or access a
    set of the keys the search found.
    cC@s(d|||f|_t|ƒ|_dS(sÑCreate a SearchResult.

        :param start_keys: The keys the search started at.
        :param exclude_keys: The keys the search excludes.
        :param key_count: The total number of keys (from start to but not
            including exclude).
        :param keys: The keys the search found. Note that in future we may get
            a SearchResult from a smart server, in which case the keys list is
            not necessarily immediately available.
        tsearchN(t_recipet	frozensett_keys(R
t
start_keystexclude_keyst	key_counttkeys((s4/usr/lib/python2.7/dist-packages/bzrlib/vf_search.pyt__init__gscC@s°|j\}}}}t|ƒdkrHtt|ƒd ƒd d}nt|ƒ}t|ƒdkr‡tt|ƒd ƒd d}nt|ƒ}d|jj||||fS(Niiÿÿÿÿs, ...]s<%s %s:(%s, %s, %d)>(Rtlentreprtlistt	__class__R(R
tkindRRRtstart_keys_reprtexclude_keys_repr((s4/usr/lib/python2.7/dist-packages/bzrlib/vf_search.pyt__repr__us!!cC@s|jS(s—Return a recipe that can be used to replay this search.

        The recipe allows reconstruction of the same results at a later date
        without knowing all the found keys. The essential elements are a list
        of keys to start and to stop at. In order to give reproducible
        results when ghosts are encountered by a search they are automatically
        added to the exclude list (or else ghost filling may alter the
        results).

        :return: A tuple ('search', start_keys_set, exclude_keys_set,
            revision_count). To recreate the results of this search, create a
            breadth first searcher on the same graph starting at start_keys.
            Then call next() (or next_with_ghosts()) repeatedly, and on every
            result, call stop_searching_any on any keys from the exclude_keys
            set. The revision_count value acts as a trivial cross-check - the
            found revisions of the new search should have as many elements as
            revision_count. If it does not, then additional revisions have been
            ghosted since the search was executed the first time and the second
            time.
        (R(R
((s4/usr/lib/python2.7/dist-packages/bzrlib/vf_search.pyR	‚scC@sbdj|jdƒ}dj|jdƒ}t|jdƒ}|jddj|||fƒfS(Nt iiiis
(tjoinRtstr(R
Rt	stop_keystcount((s4/usr/lib/python2.7/dist-packages/bzrlib/vf_search.pyR™scC@s|jS(sOReturn the keys found in this search.

        :return: A set of keys.
        (R(R
((s4/usr/lib/python2.7/dist-packages/bzrlib/vf_search.pyRŸscC@s|jddkS(s5Return false if the search lists 1 or more revisions.ii(R(R
((s4/usr/lib/python2.7/dist-packages/bzrlib/vf_search.pyR
¦sc	C@s¯|jd}|jd}|jd}|jƒ}t|ƒ}|j|ƒ|j|ƒ|j|ƒ|j|ƒ}|j|ƒ||}|t|ƒ8}t||||ƒS(sÙCreate a new search by refining this search.

        :param seen: Revisions that have been satisfied.
        :param referenced: Revision references observed while satisfying some
            of this search.
        iii(RRtsettupdatetdifference_updatetintersectionR R(	R
RRtstarttexcludeR,Rtpending_refst
seen_heads((s4/usr/lib/python2.7/dist-packages/bzrlib/vf_search.pyRªs







(
RRRRR'R	RRR
R(((s4/usr/lib/python2.7/dist-packages/bzrlib/vf_search.pyR`s		
				tPendingAncestryResultcB@sVeZdZd„Zd„Zd„Zd„Zd„Zd„Zd„Z	d„Z
RS(	sÖA search result that will reconstruct the ancestry for some graph heads.

    Unlike SearchResult, this doesn't hold the complete search result in
    memory, it just holds a description of how to generate it.
    cC@st|ƒ|_||_dS(s«Constructor.

        :param heads: an iterable of graph heads.
        :param repo: a repository to use to generate the ancestry for the given
            heads.
        N(Rtheadstrepo(R
R6R7((s4/usr/lib/python2.7/dist-packages/bzrlib/vf_search.pyRËscC@s|t|jƒdkrStt|jƒd ƒd }|dt|jƒdf7}nt|jƒ}d|jj||jfS(Niiÿÿÿÿs, <%d more>...]s<%s heads:%s repo:%r>(R R6R!R"R#RR7(R
t
heads_repr((s4/usr/lib/python2.7/dist-packages/bzrlib/vf_search.pyR'Õs!cC@sd|jtƒdfS(siReturn a recipe that can be used to replay this search.

        The recipe allows reconstruction of the same results at a later date.

        :seealso SearchResult.get_recipe:

        :return: A tuple ('proxy-search', start_keys_set, set(), -1)
            To recreate this result, create a PendingAncestryResult with the
            start_keys_set.
        sproxy-searchiÿÿÿÿ(R6R-(R
((s4/usr/lib/python2.7/dist-packages/bzrlib/vf_search.pyR	ÞscC@sdg}|j|jƒ|S(Nsancestry-of(textendR6(R
tparts((s4/usr/lib/python2.7/dist-packages/bzrlib/vf_search.pyRës	cC@s|j|jjƒƒS(sSee SearchResult.get_keys.

        Returns all the keys for the ancestry of the heads, excluding
        NULL_REVISION.
        (t	_get_keysR7t	get_graph(R
((s4/usr/lib/python2.7/dist-packages/bzrlib/vf_search.pyRðscC@sPtj}g|j|jƒD]*\}}||kr|dk	r|^q}|S(N(Rt
NULL_REVISIONt
iter_ancestryR6tNone(R
tgraphR=tkeytparentsR((s4/usr/lib/python2.7/dist-packages/bzrlib/vf_search.pyR;øs	$cC@s<tj|jkr%t|jƒdkSt|jƒdkSdS(s5Return false if the search lists 1 or more revisions.iiN(RR=R6R (R
((s4/usr/lib/python2.7/dist-packages/bzrlib/vf_search.pyR
þscC@s&|jj|ƒ}t|||jƒS(sÙCreate a new search by refining this search.

        :param seen: Revisions that have been satisfied.
        :param referenced: Revision references observed while satisfying some
            of this search.
        (R6tunionR5R7(R
RR((s4/usr/lib/python2.7/dist-packages/bzrlib/vf_search.pyRs(RRRRR'R	RRR;R
R(((s4/usr/lib/python2.7/dist-packages/bzrlib/vf_search.pyR5Äs	
			
				tEmptySearchResultcB@seZdZd„ZRS(sAn empty search result.cC@stS(N(tTrue(R
((s4/usr/lib/python2.7/dist-packages/bzrlib/vf_search.pyR
s(RRRR
(((s4/usr/lib/python2.7/dist-packages/bzrlib/vf_search.pyRDstEverythingResultcB@sMeZdZd„Zd„Zd„Zd„Zd„Zd„Zd„Z	RS(sBA search result that simply requests everything in the repository.cC@s
||_dS(N(t_repo(R
R7((s4/usr/lib/python2.7/dist-packages/bzrlib/vf_search.pyRscC@sd|jj|jfS(Ns%s(%r)(R#RRG(R
((s4/usr/lib/python2.7/dist-packages/bzrlib/vf_search.pyR'scC@st|jƒ‚dS(N(RR	(R
((s4/usr/lib/python2.7/dist-packages/bzrlib/vf_search.pyR	 scC@sdS(Nt
everything(RH((R
((s4/usr/lib/python2.7/dist-packages/bzrlib/vf_search.pyR#scC@sWdtjkrJddlm}t|j|jƒrJtjddƒqJn|jj	ƒS(Ntevili(tremoteis6EverythingResult(RemoteRepository).get_keys() is slow.(
Rtdebug_flagstbzrlibRJt
isinstanceRGtRemoteRepositoryRtmutter_callsitetall_revision_ids(R
RJ((s4/usr/lib/python2.7/dist-packages/bzrlib/vf_search.pyR&scC@stS(N(tFalse(R
((s4/usr/lib/python2.7/dist-packages/bzrlib/vf_search.pyR
/scC@s?t|jjƒƒ}|j|ƒ|j|ƒt||jƒS(N(R-RGRPR/R.R5(R
RRR6((s4/usr/lib/python2.7/dist-packages/bzrlib/vf_search.pyR5s

(
RRRRR'R	RRR
R(((s4/usr/lib/python2.7/dist-packages/bzrlib/vf_search.pyRFs							tEverythingNotInOthercB@s#eZdZed„Zd„ZRS(s=Find all revisions in that are in one repo but not the other.cC@s||_||_||_dS(N(tto_repot	from_repotfind_ghosts(R
RSRTRU((s4/usr/lib/python2.7/dist-packages/bzrlib/vf_search.pyR?s		cC@s|jj|jd|jƒS(NRU(RStsearch_missing_revision_idsRTRU(R
((s4/usr/lib/python2.7/dist-packages/bzrlib/vf_search.pyRDs	(RRRRQRR(((s4/usr/lib/python2.7/dist-packages/bzrlib/vf_search.pyRR<stNotInOtherForRevscB@s2eZdZdedd„Zd„Zd„ZRS(sAFind all revisions missing in one repo for a some specific heads.cC@s:||_||_||_||_||_||_dS(s7Constructor.

        :param required_ids: revision IDs of heads that must be found, or else
            the search will fail with NoSuchRevision.  All revisions in their
            ancestry not already in the other repository will be included in
            the search result.
        :param if_present_ids: revision IDs of heads that may be absent in the
            source repository.  If present, then their ancestry not already
            found in other will be included in the search result.
        :param limit: maximum number of revisions to fetch
        N(RSRTRUtrequired_idstif_present_idstlimit(R
RSRTRXRYRURZ((s4/usr/lib/python2.7/dist-packages/bzrlib/vf_search.pyRLs
					cC@sÈt|jƒdkr9tt|jƒd ƒd d}nt|jƒ}|jrŠt|jƒdkrŠtt|jƒd ƒd d}nt|jƒ}d|jj|j|j|j	|||j
fS(Niiÿÿÿÿs, ...]s@<%s from:%r to:%r find_ghosts:%r req'd:%r if-present:%rlimit:%r>(R RXR!R"RYR#RRTRSRURZ(R
treqd_revs_reprt
ifp_revs_repr((s4/usr/lib/python2.7/dist-packages/bzrlib/vf_search.pyR'`s$$c
C@s7|jj|jd|jd|jd|jd|jƒS(Ntrevision_idsRYRURZ(RSRVRTRXRYRURZ(R
((s4/usr/lib/python2.7/dist-packages/bzrlib/vf_search.pyRps	N(RRRR?RQRR'R(((s4/usr/lib/python2.7/dist-packages/bzrlib/vf_search.pyRWIs
	cC@sÈ|sggdfSt|ƒ}tƒ}x!|jƒD]}|j|ƒq5W|j|ƒ}|j|ƒt|ƒ}tj|krŸtj|krŸ|d7}n|j|ƒ}|j|ƒ|||fS(s5Transform a parent_map into SearchResult information.ii(	R-t
itervaluesR.t
differenceR/R RR=R0(t
parent_maptmissing_keyst	start_settresult_parentsRBR+Rt
included_keys((s4/usr/lib/python2.7/dist-packages/bzrlib/vf_search.pytsearch_result_from_parent_mapws
	


c
C@s	tt|ƒƒ}|j|ƒ}tƒ}x“tr¿y|jƒ}Wntk
rWPnXx<|jjƒD]+}|j	|ƒ}|rh|j
|ƒqhqhW|j	|ƒ}	|	r-|j|	ƒq-q-Wx<|jjƒD]+}|j	|ƒ}|rÐ|j
|ƒqÐqÐW||fS(s¨Given a parent map, run a _BreadthFirstSearcher on it.

    Start at heads, walk until you hit exclude_keys. As a further improvement,
    watch for any heads that you encounter while walking, which means they were
    not heads of the search.

    This is mostly used to generate a succinct recipe for how to walk through
    most of parent_map.

    :return: (_BreadthFirstSearcher, set(heads_encountered_by_walking))
    (RRt_make_breadth_first_searcherR-REtnextt
StopIterationt_current_parentsR^R0R.tstop_searching_any(
R`R6Rtgtstfound_headst	next_revsRBtf_headsR+((s4/usr/lib/python2.7/dist-packages/bzrlib/vf_search.pyt_run_search“s(		
c
C@sÜt|ƒ}tƒ}|}t|ƒ}x˜|rÁ|dkrÁ|d8}tƒ}|j}xA|D]9}	y|||	ƒWq_tk
r—|j|	ƒq_Xq_W|j|ƒ}|j|ƒ|}q*W|rØ|j|ƒn|S(s”Walk backwards (towards children) through the parent_map.

    This finds 'heads' that will hopefully succinctly describe our search
    graph.
    ii(RR-R.tKeyErrortaddR_(
R`ttip_keystdeptht	child_mapR6t
current_rootstwalkedtchildrentchildren_updatetp((s4/usr/lib/python2.7/dist-packages/bzrlib/vf_search.pyt_find_possible_headsµs&	
		



c
C@s‰|sggdfSt|||ƒ}t||t|ƒƒ\}}|jƒ\}}}	|rvt|ƒj|ƒ}n||t|	ƒfS(snTransform a parent_map that is searching 'tip_keys' into an
    approximate SearchResult.

    We should be able to generate a SearchResult from a given set of starting
    keys, that covers a subset of parent_map that has the last step pointing at
    tip_keys. This is to handle the case that really-long-searches shouldn't be
    started from scratch on each get_parent_map request, but we *do* want to
    filter out some of the keys that we've already seen, so we don't get
    information that we already know about on every request.

    The server will validate the search (that starting at start_keys and
    stopping at stop_keys yields the exact key_count), so we have to be careful
    to give an exact recipe.

    Basic algorithm is:
        1) Invert parent_map to get child_map (todo: have it cached and pass it
           in)
        2) Starting at tip_keys, walk towards children for 'depth' steps.
        3) At that point, we have the 'start' keys.
        4) Start walking parent_map from 'start' keys, counting how many keys
           are seen, and generating stop_keys for anything that would walk
           outside of the parent_map.

    :param parent_map: A map from {child_id: (parent_ids,)}
    :param missing_keys: parent_ids that we know are unavailable
    :param tip_keys: the revision_ids that we are searching
    :param depth: How far back to walk.
    i(R{RpR-t	get_stateR_R (
R`RaRsRtR6RlRmRRR((s4/usr/lib/python2.7/dist-packages/bzrlib/vf_search.pyt%limited_search_result_from_parent_map×s
N(Rt
__future__RRLRRRtbzrlib.graphRRRtobjectRRRR5RDRFRRRWReRpR{R}(((s4/usr/lib/python2.7/dist-packages/bzrlib/vf_search.pyt<module>s-dL%
.		"	"

Copyright © 2017 || Recoded By Mr.Bumblebee