~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/mutabletree.py

(gz) Remove bzrlib/util/elementtree/ package (Martin Packman)

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
See MutableTree for more details.
20
20
"""
21
21
 
 
22
from __future__ import absolute_import
22
23
 
23
24
from bzrlib.lazy_import import lazy_import
24
25
lazy_import(globals(), """
71
72
    conformance tests for - rather we are testing MemoryTree specifically, and
72
73
    interface testing implementations of WorkingTree.
73
74
 
74
 
    A mutable tree always has an associated Branch and BzrDir object - the
 
75
    A mutable tree always has an associated Branch and ControlDir object - the
75
76
    branch and bzrdir attributes.
76
77
    """
77
78
    def __init__(self, *args, **kw):
162
163
        if sub_tree_id == self.get_root_id():
163
164
            raise errors.BadReferenceTarget(self, sub_tree,
164
165
                                     'Trees have the same root id.')
165
 
        if sub_tree_id in self:
 
166
        if self.has_id(sub_tree_id):
166
167
            raise errors.BadReferenceTarget(self, sub_tree,
167
168
                                            'Root id already present in tree')
168
169
        self._add([sub_tree_path], [sub_tree_id], ['tree-reference'])
260
261
        :param more_warning: Details about what is happening.
261
262
        """
262
263
        if strict is None:
263
 
            strict = self.branch.get_config().get_user_option_as_bool(opt_name)
 
264
            strict = self.branch.get_config_stack().get(opt_name)
264
265
        if strict is not False:
265
266
            err_class = None
266
267
            if (self.has_changes()):
554
555
        entry = self._invdelta.get(inv_path)
555
556
        if entry is not None:
556
557
            return entry[3]
 
558
        # Find a 'best fit' match if the filesystem is case-insensitive
 
559
        inv_path = self.tree._fix_case_of_inventory_path(inv_path)
557
560
        file_id = self.tree.path2id(inv_path)
558
561
        if file_id is not None:
559
562
            return self.tree.iter_entries_by_dir([file_id]).next()[1]
580
583
        :param parent_ie: Parent inventory entry if known, or None.  If
581
584
            None, the parent is looked up by name and used if present, otherwise it
582
585
            is recursively added.
 
586
        :param path: 
583
587
        :param kind: Kind of new entry (file, directory, etc)
584
 
        :param action: callback(tree, parent_ie, path, kind); can return file_id
 
588
        :param inv_path:
585
589
        :return: Inventory entry for path and a list of paths which have been added.
586
590
        """
587
591
        # Nothing to do if path is already versioned.
626
630
            if (prev_dir is None or not is_inside([prev_dir], path)):
627
631
                yield (path, inv_path, this_ie, None)
628
632
            prev_dir = path
629
 
 
 
633
        
630
634
    def __init__(self, tree, action, conflicts_related=None):
631
635
        self.tree = tree
632
636
        if action is None:
693
697
 
694
698
            # get the contents of this directory.
695
699
 
696
 
            # find the kind of the path being added.
 
700
            # find the kind of the path being added, and save stat_value
 
701
            # for reuse
 
702
            stat_value = None
697
703
            if this_ie is None:
698
 
                kind = osutils.file_kind(abspath)
 
704
                stat_value = osutils.file_stat(abspath)
 
705
                kind = osutils.file_kind_from_stat_mode(stat_value.st_mode)
699
706
            else:
700
707
                kind = this_ie.kind
701
 
 
 
708
            
 
709
            # allow AddAction to skip this file
 
710
            if self.action.skip_file(self.tree,  abspath,  kind,  stat_value):
 
711
                continue
702
712
            if not InventoryEntry.versionable_kind(kind):
703
713
                trace.warning("skipping %s (can't add file of kind '%s')",
704
714
                              abspath, kind)
716
726
 
717
727
            if kind == 'directory' and directory != '':
718
728
                try:
719
 
                    transport = _mod_transport.get_transport(abspath)
 
729
                    transport = _mod_transport.get_transport_from_path(abspath)
720
730
                    controldir.ControlDirFormat.find_format(transport)
721
731
                    sub_tree = True
722
732
                except errors.NotBranchError:
737
747
                # which is perhaps reasonable: adding a new reference is a
738
748
                # special operation and can have a special behaviour.  mbp
739
749
                # 20070306
740
 
                trace.mutter("%r is a nested bzr tree", abspath)
 
750
                trace.warning("skipping nested tree %r", abspath)
741
751
            else:
742
 
                this_ie = self._add_one_and_parent(parent_ie, directory, kind, inv_path)
 
752
                this_ie = self._add_one_and_parent(parent_ie, directory, kind,
 
753
                    inv_path)
743
754
 
744
755
            if kind == 'directory' and not sub_tree:
745
756
                if this_ie.kind != 'directory':
767
778
                        # recurse into this already versioned subdir.
768
779
                        things_to_add.append((subp, sub_invp, sub_ie, this_ie))
769
780
                    else:
770
 
                        # user selection overrides ignoes
 
781
                        # user selection overrides ignores
771
782
                        # ignore while selecting files - if we globbed in the
772
783
                        # outer loop we would ignore user files.
773
784
                        ignore_glob = self.tree.is_ignored(subp)