~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/mutabletree.py

  • Committer: Samuel Bronson
  • Date: 2012-08-30 20:36:18 UTC
  • mto: (6015.57.3 2.4)
  • mto: This revision was merged to the branch mainline in revision 6558.
  • Revision ID: naesten@gmail.com-20120830203618-y2dzw91nqpvpgxvx
Update INSTALL for switch to Python 2.6 and up.

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
23
22
 
24
23
from bzrlib.lazy_import import lazy_import
25
24
lazy_import(globals(), """
72
71
    conformance tests for - rather we are testing MemoryTree specifically, and
73
72
    interface testing implementations of WorkingTree.
74
73
 
75
 
    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
76
75
    branch and bzrdir attributes.
77
76
    """
78
77
    def __init__(self, *args, **kw):
261
260
        :param more_warning: Details about what is happening.
262
261
        """
263
262
        if strict is None:
264
 
            strict = self.branch.get_config_stack().get(opt_name)
 
263
            strict = self.branch.get_config().get_user_option_as_bool(opt_name)
265
264
        if strict is not False:
266
265
            err_class = None
267
266
            if (self.has_changes()):
520
519
            "called with a bzrlib.mutabletree.PostCommitHookParams object. "
521
520
            "The mutable tree the commit was performed on is available via "
522
521
            "the mutable_tree attribute of that object.", (2, 0))
523
 
        self.add_hook('pre_transform',
524
 
            "Called before a tree transform on this tree. The hook is called "
525
 
            "with the tree that is being transformed and the transform.",
526
 
            (2, 5))
527
 
        self.add_hook('post_build_tree',
528
 
            "Called after a completely new tree is built. The hook is "
529
 
            "called with the tree as its only argument.", (2, 5))
530
 
        self.add_hook('post_transform',
531
 
            "Called after a tree transform has been performed on a tree. "
532
 
            "The hook is called with the tree that is being transformed and "
533
 
            "the transform.",
534
 
            (2, 5))
 
522
 
535
523
 
536
524
# install the default hooks into the MutableTree class.
537
525
MutableTree.hooks = MutableTreeHooks()
594
582
        :param parent_ie: Parent inventory entry if known, or None.  If
595
583
            None, the parent is looked up by name and used if present, otherwise it
596
584
            is recursively added.
597
 
        :param path: 
598
585
        :param kind: Kind of new entry (file, directory, etc)
599
 
        :param inv_path:
 
586
        :param action: callback(tree, parent_ie, path, kind); can return file_id
600
587
        :return: Inventory entry for path and a list of paths which have been added.
601
588
        """
602
589
        # Nothing to do if path is already versioned.
623
610
            # nb: this relies on someone else checking that the path we're using
624
611
            # doesn't contain symlinks.
625
612
            parent_ie = self._convert_to_directory(parent_ie, inv_dirname)
626
 
        file_id = self.action(self.tree, parent_ie, path, kind)
 
613
        file_id = self.action(self.tree.inventory, parent_ie, path, kind)
627
614
        entry = _mod_inventory.make_entry(kind, basename, parent_ie.file_id,
628
615
            file_id=file_id)
629
616
        self._invdelta[inv_path] = (None, inv_path, entry.file_id, entry)
641
628
            if (prev_dir is None or not is_inside([prev_dir], path)):
642
629
                yield (path, inv_path, this_ie, None)
643
630
            prev_dir = path
644
 
        
 
631
 
645
632
    def __init__(self, tree, action, conflicts_related=None):
646
633
        self.tree = tree
647
634
        if action is None:
708
695
 
709
696
            # get the contents of this directory.
710
697
 
711
 
            # find the kind of the path being added, and save stat_value
712
 
            # for reuse
713
 
            stat_value = None
 
698
            # find the kind of the path being added.
714
699
            if this_ie is None:
715
 
                stat_value = osutils.file_stat(abspath)
716
 
                kind = osutils.file_kind_from_stat_mode(stat_value.st_mode)
 
700
                kind = osutils.file_kind(abspath)
717
701
            else:
718
702
                kind = this_ie.kind
719
 
            
720
 
            # allow AddAction to skip this file
721
 
            if self.action.skip_file(self.tree,  abspath,  kind,  stat_value):
722
 
                continue
 
703
 
723
704
            if not InventoryEntry.versionable_kind(kind):
724
705
                trace.warning("skipping %s (can't add file of kind '%s')",
725
706
                              abspath, kind)
737
718
 
738
719
            if kind == 'directory' and directory != '':
739
720
                try:
740
 
                    transport = _mod_transport.get_transport_from_path(abspath)
 
721
                    transport = _mod_transport.get_transport(abspath)
741
722
                    controldir.ControlDirFormat.find_format(transport)
742
723
                    sub_tree = True
743
724
                except errors.NotBranchError:
758
739
                # which is perhaps reasonable: adding a new reference is a
759
740
                # special operation and can have a special behaviour.  mbp
760
741
                # 20070306
761
 
                trace.warning("skipping nested tree %r", abspath)
 
742
                trace.mutter("%r is a nested bzr tree", abspath)
762
743
            else:
763
 
                this_ie = self._add_one_and_parent(parent_ie, directory, kind,
764
 
                    inv_path)
 
744
                this_ie = self._add_one_and_parent(parent_ie, directory, kind, inv_path)
765
745
 
766
746
            if kind == 'directory' and not sub_tree:
767
747
                if this_ie.kind != 'directory':
789
769
                        # recurse into this already versioned subdir.
790
770
                        things_to_add.append((subp, sub_invp, sub_ie, this_ie))
791
771
                    else:
792
 
                        # user selection overrides ignores
 
772
                        # user selection overrides ignoes
793
773
                        # ignore while selecting files - if we globbed in the
794
774
                        # outer loop we would ignore user files.
795
775
                        ignore_glob = self.tree.is_ignored(subp)