~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/mutabletree.py

  • Committer: Jelmer Vernooij
  • Date: 2011-06-16 11:57:36 UTC
  • mto: This revision was merged to the branch mainline in revision 5987.
  • Revision ID: jelmer@samba.org-20110616115736-5xuzwdf87qb81su4
Use iter_ancestry rather than get_ancestry.

Show diffs side-by-side

added added

removed removed

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