-=[ Mr. Bumblebee ]=-
_Indonesia_

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


Oc@@sdZddlmZddlmZeedddlmZmZdZ	de
jfdYZd	ee
j
fd
YZdejfdYZee_d
efdYZdefdYZdS(s7MutableTree object.

See MutableTree for more details.
i(tabsolute_import(tlazy_imports
import operator
import os
import re

from bzrlib import (
    add,
    controldir,
    errors,
    hooks,
    inventory as _mod_inventory,
    osutils,
    revisiontree,
    trace,
    transport as _mod_transport,
    tree,
    )
(tneeds_read_locktneeds_write_lockc@s+fd}j|_j|_|S(s;Decorate unbound to take out and release a tree_write lock.c@s0|jz|||SWd|jXdS(N(tlock_tree_writetunlock(tselftargstkwargs(tunbound(s6/usr/lib/python2.7/dist-packages/bzrlib/mutabletree.pyttree_write_locked1s
(t__doc__t__name__(R	R
((R	s6/usr/lib/python2.7/dist-packages/bzrlib/mutabletree.pytneeds_tree_write_lock/stMutableTreecB@s
eZdZdZdZedddZdZdZ	dZ
dZedddZ
d	Zedd
ZedZedZd
ZdZeddZdZedZedZedZededZRS(s3A MutableTree is a specialisation of Tree which is able to be mutated.

    Generally speaking these mutations are only possible within a lock_write
    context, and will revert if the lock is broken abnormally - but this cannot
    be guaranteed - depending on the exact implementation of the mutable state.

    The most common form of Mutable Tree is WorkingTree, see bzrlib.workingtree.
    For tests we also have MemoryTree which is a MutableTree whose contents are
    entirely in memory.

    For now, we are not treating MutableTree as an interface to provide
    conformance tests for - rather we are testing MemoryTree specifically, and
    interface testing implementations of WorkingTree.

    A mutable tree always has an associated Branch and ControlDir object - the
    branch and bzrdir attributes.
    cO@s&tt|j||t|_dS(N(tsuperRt__init__tTruetcase_sensitive(RRtkw((s6/usr/lib/python2.7/dist-packages/bzrlib/mutabletree.pyRNscC@st|jdS(sTrue if filename is the name of a control file in this tree.

        :param filename: A filename within the tree. This is a relative path
            from the root of this tree.

        This is true IF and ONLY IF the filename is part of the meta data
        that bzr controls in this tree. I.E. a random .bzr directory placed
        on disk will not be a control file for this tree.
        N(tNotImplementedErrortis_control_filename(Rtfilename((s6/usr/lib/python2.7/dist-packages/bzrlib/mutabletree.pyRUs
cC@st|tr|dkp't|ts6tn|dkpNt|ts]tn|g}|dk	r~|g}n|dk	r|g}qng|D]}|jd^q}|dkrdgt|}n$t|t|kstn|dkr#dgt|}n$t|t|ksGtnxA|D]9}|j|rxtjd|nt	j
|}qNW|j|||j|||dS(sAdd paths to the set of versioned paths.

        Note that the command line normally calls smart_add instead,
        which can automatically recurse.

        This adds the files to the inventory, so that they will be
        recorded by the next commit.

        :param files: List of paths to add, relative to the base of the tree.
        :param ids: If set, use these instead of automatically generated ids.
            Must be the same length as the list of files, but may
            contain None for ids that are to be autogenerated.
        :param kinds: Optional parameter to specify the kinds to be used for
            each file.

        TODO: Perhaps callback with the ids and paths as they're added.
        t/RN(
t
isinstancet
basestringtNonetAssertionErrortstriptlenRterrorstForbiddenControlFileErrortosutilst	splitpatht
_gather_kindst_add(Rtfilestidstkindstpathtftfp((s6/usr/lib/python2.7/dist-packages/bzrlib/mutabletree.pytaddas2	"
cC@stj|j|dS(s5Add a TreeReference to the tree, pointing at sub_treeN(RtUnsupportedOperationt
add_reference(Rtsub_tree((s6/usr/lib/python2.7/dist-packages/bzrlib/mutabletree.pyR,scC@sy|j|j}Wn)tjk
rAtj||dnX|j}||jkrxtj||dn|j|rtj||dn|j|g|gdgdS(s<Standard add_reference implementation, for use by subclassessTarget not inside tree.sTrees have the same root id.sRoot id already present in treestree-referenceN(trelpathtbasedirRtPathNotChildtBadReferenceTargettget_root_idthas_idR#(RR-t
sub_tree_pathtsub_tree_id((s6/usr/lib/python2.7/dist-packages/bzrlib/mutabletree.pyt_add_references
cC@st|jdS(s;Helper function for add - updates the inventory.

        :param files: sequence of pathnames, relative to the tree root
        :param ids: sequence of suggested ids for the files (may be None)
        :param kinds: sequence of  inventory kinds of the files (i.e. may
            contain "tree-reference")
        N(RR#(RR$R%R&((s6/usr/lib/python2.7/dist-packages/bzrlib/mutabletree.pyR#scC@st|jdS(sApply changes to the inventory as an atomic operation.

        :param changes: An inventory delta to apply to the working tree's
            inventory.
        :return None:
        :seealso Inventory.apply_delta: For details on the changes parameter.
        N(Rtapply_inventory_delta(Rtchanges((s6/usr/lib/python2.7/dist-packages/bzrlib/mutabletree.pyR7sc
	O@sddlm}g}|jj||j|jdd|jdd|jdt|}|f|}xt	j
dD]}||qyW|jjd|d|d	|||}t|}	xt	j
d
D]}||	qW|S(Ni(tcommittauthorstauthortlocaltstart_committworking_treetrevpropstpossible_master_transportstpost_commit(tbzrlibR9tCommittupdate_revpropstbranchtpopRtgettFalseRthookstPostCommitHookParams(
RtmessageR?RRR9R@thooktcommitted_idtpost_hook_params((s6/usr/lib/python2.7/dist-packages/bzrlib/mutabletree.pyR9s(		
cC@st|jdS(s4Helper function for add - sets the entries of kinds.N(RR"(RR$R&((s6/usr/lib/python2.7/dist-packages/bzrlib/mutabletree.pyR"scC@st|jdkrtS|dkr7|j}n|j|}y3|j}|ddkrt|j}ntSWntk
rtSXdS(sQuickly check that the tree contains at least one commitable change.

        :param _from_tree: tree to compare against to find changes (default to
            the basis tree and is intended to be used by tests).

        :return: True if a change is found. False otherwise
        iiN(NN(	Rtget_parent_idsRRt
basis_treetiter_changestnextt
StopIterationRH(Rt
_from_treeR8tchange((s6/usr/lib/python2.7/dist-packages/bzrlib/mutabletree.pythas_changess

cC@s|dkr'|jjj|}n|tk	rd}|jrQtj}n'|j|jjkrxtj	}n|dk	r|dkr||d|}t
jd|jq||d|}|qndS(s,Check the tree for uncommitted changes and branch synchronization.

        If strict is None and not set in the config files, a warning is issued.
        If strict is True, an error is raised.
        If strict is False, no checks are done and no warning is issued.

        :param strict: True, False or None, searched in branch config if None.

        :param opt_name: strict option name to search in config file.

        :param more_error: Details about how to avoid the check.

        :param more_warning: Details about what is happening.
        tmores%sN(
RREtget_config_stackRGRHRVRtUncommittedChangest
last_revisiont
OutOfDateTreettracetwarningt_format(Rtstricttopt_namet
more_errortmore_warningt	err_classterr((s6/usr/lib/python2.7/dist-packages/bzrlib/mutabletree.pytcheck_changed_or_out_of_datescC@st|jdS(sReturn the revision id of the last commit performed in this tree.

        In early tree formats the result of last_revision is the same as the
        branch last_revision, but that is no longer the case for modern tree
        formats.

        last_revision returns the left most parent id, or None if there are no
        parents.

        last_revision was deprecated as of 0.11. Please use get_parent_ids
        instead.
        N(RRZ(R((s6/usr/lib/python2.7/dist-packages/bzrlib/mutabletree.pyRZscC@st|jdS(sLock the working tree for write, and the branch for read.

        This is useful for operations which only need to mutate the working
        tree. Taking out branch write locks is a relatively expensive process
        and may fail if the branch is on read only media. So branch write locks
        should only be taken out when we are modifying branch data - such as in
        operations like commit, pull, uncommit and update.
        N(RR(R((s6/usr/lib/python2.7/dist-packages/bzrlib/mutabletree.pyR,s	cC@st|jdS(sLock the tree and its branch. This allows mutating calls to be made.

        Some mutating methods will take out implicit write locks, but in
        general you should always obtain a write lock before calling mutating
        methods on a tree.
        N(Rt
lock_write(R((s6/usr/lib/python2.7/dist-packages/bzrlib/mutabletree.pyRf7scC@st|jdS(sCreate a directory in the tree. if file_id is None, one is assigned.

        :param path: A unicode file path.
        :param file_id: An optional file-id.
        :return: the file id of the new directory.
        N(Rtmkdir(RR'tfile_id((s6/usr/lib/python2.7/dist-packages/bzrlib/mutabletree.pyRg@scC@s|\}}dS(s=Tell the tree we have observed a paths sha1.

        The intent of this function is to allow trees that have a hashcache to
        update the hashcache during commit. If the observed file is too new
        (based on the stat_value) to be safely hash-cached the tree will ignore
        it.

        The default implementation does nothing.

        :param file_id: The file id
        :param path: The file path
        :param sha1: The sha 1 that was observed.
        :param stat_value: A stat result for the file the sha1 was read from.
        :return: None
        N((RRhR't.3tsha1t
stat_value((s6/usr/lib/python2.7/dist-packages/bzrlib/mutabletree.pyt_observed_sha1JscC@st|jdS(sOUpdate the content of a file in the tree.

        Note that the file is written in-place rather than being
        written to a temporary location and renamed. As a consequence,
        readers can potentially see the file half-written.

        :param file_id: file-id of the file
        :param bytes: the new file contents
        N(Rtput_file_bytes_non_atomic(RRhtbytes((s6/usr/lib/python2.7/dist-packages/bzrlib/mutabletree.pyRm[scC@st|jdS(sgSet the parents ids of the working tree.

        :param revision_ids: A list of revision_ids.
        N(Rtset_parent_ids(Rtrevision_idstallow_leftmost_as_ghost((s6/usr/lib/python2.7/dist-packages/bzrlib/mutabletree.pyRohscC@st|jdS(sSet the parents of the working tree.

        :param parents_list: A list of (revision_id, tree) tuples.
            If tree is None, then that element is treated as an unreachable
            parent tree - i.e. a ghost.
        N(Rtset_parent_trees(Rtparents_listRq((s6/usr/lib/python2.7/dist-packages/bzrlib/mutabletree.pyRroscC@st|jdS(sVersion file_list, optionally recursing into directories.

        This is designed more towards DWIM for humans than API clarity.
        For the specific behaviour see the help for cmd_add().

        :param file_list: List of zero or more paths.  *NB: these are 
            interpreted relative to the process cwd, not relative to the 
            tree.*  (Add and most other tree methods use tree-relative
            paths.)
        :param action: A reporter to be called with the inventory, parent_ie,
            path and kind of the path being added. It may return a file_id if
            a specific one should be used.
        :param save: Save the inventory after completing the adds. If False
            this provides dry-run functionality by doing the add and not saving
            the inventory.
        :return: A tuple - files_added, ignored_files. files_added is the count
            of added files, and ignored_files is a dict mapping files that were
            ignored to the rule that caused them to be ignored.
        N(Rt	smart_add(Rt	file_listtrecursetactiontsave((s6/usr/lib/python2.7/dist-packages/bzrlib/mutabletree.pyRtxsN(Rt
__module__RRRR
RR*R,R6R#R7RR9R"RRVReRZRRfRgRlRmRHRoRrRRt(((s6/usr/lib/python2.7/dist-packages/bzrlib/mutabletree.pyR<s2		5			
	
	&					
	tMutableInventoryTreecB@sAeZedZdZeededZdZRS(cC@s1|j|j}|j||j|dS(sApply changes to the inventory as an atomic operation.

        :param changes: An inventory delta to apply to the working tree's
            inventory.
        :return None:
        :seealso Inventory.apply_delta: For details on the changes parameter.
        N(tflushtroot_inventorytapply_deltat_write_inventory(RR8tinv((s6/usr/lib/python2.7/dist-packages/bzrlib/mutabletree.pyR7s	
	
cC@s|js|j|}n|S(s;If our tree isn't case sensitive, return the canonical path(Rtget_canonical_inventory_path(RR'((s6/usr/lib/python2.7/dist-packages/bzrlib/mutabletree.pyt_fix_case_of_inventory_paths	c	C@st|dddk	rNt}x0|jD]}|j|jq.Wnd}t|||}|j|d||r|j}|j	|n|j
|jfS(sVersion file_list, optionally recursing into directories.

        This is designed more towards DWIM for humans than API clarity.
        For the specific behaviour see the help for cmd_add().

        :param file_list: List of zero or more paths.  *NB: these are 
            interpreted relative to the process cwd, not relative to the 
            tree.*  (Add and most other tree methods use tree-relative
            paths.)
        :param action: A reporter to be called with the inventory, parent_ie,
            path and kind of the path being added. It may return a file_id if
            a specific one should be used.
        :param save: Save the inventory after completing the adds. If False
            this provides dry-run functionality by doing the add and not saving
            the inventory.
        :return: A tuple - files_added, ignored_files. files_added is the count
            of added files, and ignored_files is a dict mapping files that were
            ignored to the rule that caused them to be ignored.
        t	conflictsRvN(tgetattrRtsetRtupdatetassociated_filenamest_SmartAddHelperR*tget_inventory_deltaR7taddedtignored(	RRuRvRwRxtconflicts_relatedtctaddertinvdelta((s6/usr/lib/python2.7/dist-packages/bzrlib/mutabletree.pyRts	cC@s|j|kr&|j|gdS|j}|jtj|}|j|j|tj	|j
j||}|j||fgdS(sUpdate the parents of this tree after a commit.

        This gives the tree one parent, with revision id new_revid. The
        inventory delta is applied to the current basis tree to generate the
        inventory for the parent new_revid, and all other parent trees are
        discarded.

        All the changes in the delta should be changes synchronising the basis
        tree with some or all of the working tree, with a change to a directory
        requiring that its contents have been recursively included. That is,
        this is not a general purpose tree modification routine, but a helper
        for commit which is not required to handle situations that do not arise
        outside of commit.

        See the inventory developers documentation for the theory behind
        inventory deltas.

        :param new_revid: The new revision id for the trees parent.
        :param delta: An inventory delta (see apply_inventory_delta) describing
            the changes from the current left most parent revision to new_revid.
        N(
RZRoRPt	lock_readt_mod_inventorytmutable_inventory_from_treeRR}trevisiontreetInventoryRevisionTreeREt
repositoryRr(Rt	new_revidtdeltatbasist	inventorytrev_tree((s6/usr/lib/python2.7/dist-packages/bzrlib/mutabletree.pytupdate_basis_by_deltas


N(	RRyR
R7RRRRtR(((s6/usr/lib/python2.7/dist-packages/bzrlib/mutabletree.pyRzs
	%tMutableTreeHookscB@seZdZdZRS(sWA dictionary mapping a hook name to a list of callables for mutabletree
    hooks.
    cC@sytjj|dd|jddd|jddd|jddd|jddd|jddddS(s#Create the default hooks.

        sbzrlib.mutabletreesMutableTree.hooksR=sCalled before a commit is performed on a tree. The start commit hook is able to change the tree before the commit takes place. start_commit is called with the bzrlib.mutabletree.MutableTree that the commit is being performed on.iiRAsCalled after a commit is performed on a tree. The hook is called with a bzrlib.mutabletree.PostCommitHookParams object. The mutable tree the commit was performed on is available via the mutable_tree attribute of that object.iit
pre_transformszCalled before a tree transform on this tree. The hook is called with the tree that is being transformed and the transform.itpost_build_treescCalled after a completely new tree is built. The hook is called with the tree as its only argument.tpost_transformsCalled after a tree transform has been performed on a tree. The hook is called with the tree that is being transformed and the transform.N(ii(ii(ii(ii(ii(RItHooksRtadd_hook(R((s6/usr/lib/python2.7/dist-packages/bzrlib/mutabletree.pyRs 					(RRyRR(((s6/usr/lib/python2.7/dist-packages/bzrlib/mutabletree.pyRsRJcB@seZdZdZRS(sParameters for the post_commit hook.

    To access the parameters, use the following attributes:

    * mutable_tree - the MutableTree object
    cC@s
||_dS(s/Create the parameters for the post_commit hook.N(tmutable_tree(RR((s6/usr/lib/python2.7/dist-packages/bzrlib/mutabletree.pyR$s(RRyRR(((s6/usr/lib/python2.7/dist-packages/bzrlib/mutabletree.pyRJsRcB@sSeZdZdZdZdZdZdZddZ	e
dZRS(	s!Helper for MutableTree.smart_add.cC@s
|jjS(N(t	_invdeltatvalues(R((s6/usr/lib/python2.7/dist-packages/bzrlib/mutabletree.pyR,scC@sw|jj|}|dk	r&|dS|jj|}|jj|}|dk	rs|jj|gjdSdS(sRetrieve the most up to date inventory entry for a path.

        :param inv_path: Normalized inventory path
        :return: Inventory entry (with possibly invalid .children for
            directories)
        iiN(RRGRttreeRtpath2idtiter_entries_by_dirRR(Rtinv_pathtentryRh((s6/usr/lib/python2.7/dist-packages/bzrlib/mutabletree.pyt_get_ie/scC@s>tj|j|j|j}|||j|f|j|<|S(sConvert an entry to a directory.

        :param this_ie: Inventory entry
        :param inv_path: Normalized path for the inventory entry
        :return: The new inventory entry
        (RtInventoryDirectoryRhtnamet	parent_idR(Rtthis_ieR((s6/usr/lib/python2.7/dist-packages/bzrlib/mutabletree.pyt_convert_to_directory@s
	cC@stj|}tj|\}}|dkrj|j|}|dk	rO|S|jd|d|}n|jdkr|j||}n|j|j	|||}	t
j|||jd|	}
d||
j|
f|j
|<|jj||
S(sAdd a new entry to the inventory and automatically add unversioned parents.

        :param parent_ie: Parent inventory entry if known, or None.  If
            None, the parent is looked up by name and used if present, otherwise it
            is recursively added.
        :param path: 
        :param kind: Kind of new entry (file, directory, etc)
        :param inv_path:
        :return: Inventory entry for path and a list of paths which have been added.
        t	directoryRhN(R tdirnametsplitRRt_add_one_and_parenttkindRRwRRt
make_entryRhRRtappend(Rt	parent_ieR'RRtinv_dirnameRtbasenameRRhR((s6/usr/lib/python2.7/dist-packages/bzrlib/mutabletree.pyROs"		cc@sd}tj}xnt|jdtjdD]K\}\}}|dksb||g|rv|||dfVn|}q1WdS(Ntkeyi(RR tis_inside_or_parent_of_anytsortedt	iteritemstoperatort
itemgetter(Rt	user_dirstprev_dirt	is_insideR'RR((s6/usr/lib/python2.7/dist-packages/bzrlib/mutabletree.pyt_gather_dirs_to_addys	.cC@ss||_|dkr'tj|_n	||_i|_g|_i|_|dkrft|_	n	||_	dS(N(
RRR*t	AddActionRwRRRt	frozensetR(RRRwR((s6/usr/lib/python2.7/dist-packages/bzrlib/mutabletree.pyRs					cC@sddlm}|s"dg}ntjrCttj|}ni}xtj|jj|D]}|jj	|rt
jd|n|jj|}tj
|}tj|\}}	|j|}
|
dkr|jd|||}
n|dkrb||
f||<qbqbW|s(dSt|j|}tjd}x8|D]0\}
}}
}|jj|
}d}|
dkrtj|}tj|j}n	|
j}|jj|j|||rqSn|j|stjd||qSn|j|
r(tjd|qSn|
|j krMtjd	|qSn|dkr|
d
kry)t!j"|}t#j$j%|t&}Wqt
j'k
rt(}qt
j)k
rt&}qXnt(}|
dk	rn1|rtjd|n|j||
||}
|dkrS|rS|
jdkrD|j*|
|}
nx<t+t,j-|D]"}tj|\}}	tj.|
|}|jj	|rtj/d|qZntj.||}|j0j1|}|dk	r|d
}n|
j2j1|}|dk	r&|j3||||
fqZ|jj4|}|dk	rc|j5j6|gj3|qZ|j3||d|
fqZWqSqSWdS(Ni(tInventoryEntryu.RRs[\r\n]s)skipping %s (can't add file of kind '%s')sskipping %r (contains \n or \r)s1skipping %s (generated to help resolve conflicts)tsskipping nested tree %rsskip control directory %ri(7tbzrlib.inventoryRR thas_symlinkstmapt
normalizepathtcanonical_relpathsRR/RRRtabspatht	file_kindtnormalized_filenameRRRtlistRtretcompilet	file_stattfile_kind_from_stat_modetst_modeRRwt	skip_filetversionable_kindR\R]tsearchRt_mod_transporttget_transport_from_patht
controldirtControlDirFormattfind_formatRtNotBranchErrorRHtUnsupportedFormatErrorRRtostlistdirtpathjointmutterRRGtchildrenRt
is_ignoredRt
setdefault(RRuRvRRtfilepathRRRt_Rt
things_to_addtillegalpath_reRRRkt	transportR-tsubftinv_ftsubptsub_invpRtsub_ietignore_glob((s6/usr/lib/python2.7/dist-packages/bzrlib/mutabletree.pyR*s		

	
		
N(RRyRRRRRRRRRR*(((s6/usr/lib/python2.7/dist-packages/bzrlib/mutabletree.pyR)s				*	N(Rt
__future__Rtbzrlib.lazy_importRtglobalstbzrlib.decoratorsRRR
RtTreeRt
InventoryTreeRzRIRRtobjectRJR(((s6/usr/lib/python2.7/dist-packages/bzrlib/mutabletree.pyt<module>s		
Th"

Copyright © 2017 || Recoded By Mr.Bumblebee