~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/mutabletree.py

  • Committer: Patch Queue Manager
  • Date: 2016-02-01 19:13:13 UTC
  • mfrom: (6614.2.2 trunk)
  • Revision ID: pqm@pqm.ubuntu.com-20160201191313-wdfvmfff1djde6oq
(vila) Release 2.7.0 (Vincent Ladeuil)

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):
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()):
407
408
        :seealso Inventory.apply_delta: For details on the changes parameter.
408
409
        """
409
410
        self.flush()
410
 
        inv = self.inventory
 
411
        inv = self.root_inventory
411
412
        inv.apply_delta(changes)
412
413
        self._write_inventory(inv)
413
414
 
519
520
            "called with a bzrlib.mutabletree.PostCommitHookParams object. "
520
521
            "The mutable tree the commit was performed on is available via "
521
522
            "the mutable_tree attribute of that object.", (2, 0))
522
 
 
 
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))
523
535
 
524
536
# install the default hooks into the MutableTree class.
525
537
MutableTree.hooks = MutableTreeHooks()
582
594
        :param parent_ie: Parent inventory entry if known, or None.  If
583
595
            None, the parent is looked up by name and used if present, otherwise it
584
596
            is recursively added.
 
597
        :param path: 
585
598
        :param kind: Kind of new entry (file, directory, etc)
586
 
        :param action: callback(tree, parent_ie, path, kind); can return file_id
 
599
        :param inv_path:
587
600
        :return: Inventory entry for path and a list of paths which have been added.
588
601
        """
589
602
        # Nothing to do if path is already versioned.
610
623
            # nb: this relies on someone else checking that the path we're using
611
624
            # doesn't contain symlinks.
612
625
            parent_ie = self._convert_to_directory(parent_ie, inv_dirname)
613
 
        file_id = self.action(self.tree.inventory, parent_ie, path, kind)
 
626
        file_id = self.action(self.tree, parent_ie, path, kind)
614
627
        entry = _mod_inventory.make_entry(kind, basename, parent_ie.file_id,
615
628
            file_id=file_id)
616
629
        self._invdelta[inv_path] = (None, inv_path, entry.file_id, entry)
628
641
            if (prev_dir is None or not is_inside([prev_dir], path)):
629
642
                yield (path, inv_path, this_ie, None)
630
643
            prev_dir = path
631
 
 
 
644
        
632
645
    def __init__(self, tree, action, conflicts_related=None):
633
646
        self.tree = tree
634
647
        if action is None:
695
708
 
696
709
            # get the contents of this directory.
697
710
 
698
 
            # find the kind of the path being added.
 
711
            # find the kind of the path being added, and save stat_value
 
712
            # for reuse
 
713
            stat_value = None
699
714
            if this_ie is None:
700
 
                kind = osutils.file_kind(abspath)
 
715
                stat_value = osutils.file_stat(abspath)
 
716
                kind = osutils.file_kind_from_stat_mode(stat_value.st_mode)
701
717
            else:
702
718
                kind = this_ie.kind
703
 
 
 
719
            
 
720
            # allow AddAction to skip this file
 
721
            if self.action.skip_file(self.tree,  abspath,  kind,  stat_value):
 
722
                continue
704
723
            if not InventoryEntry.versionable_kind(kind):
705
724
                trace.warning("skipping %s (can't add file of kind '%s')",
706
725
                              abspath, kind)
739
758
                # which is perhaps reasonable: adding a new reference is a
740
759
                # special operation and can have a special behaviour.  mbp
741
760
                # 20070306
742
 
                trace.mutter("%r is a nested bzr tree", abspath)
 
761
                trace.warning("skipping nested tree %r", abspath)
743
762
            else:
744
 
                this_ie = self._add_one_and_parent(parent_ie, directory, kind, inv_path)
 
763
                this_ie = self._add_one_and_parent(parent_ie, directory, kind,
 
764
                    inv_path)
745
765
 
746
766
            if kind == 'directory' and not sub_tree:
747
767
                if this_ie.kind != 'directory':
769
789
                        # recurse into this already versioned subdir.
770
790
                        things_to_add.append((subp, sub_invp, sub_ie, this_ie))
771
791
                    else:
772
 
                        # user selection overrides ignoes
 
792
                        # user selection overrides ignores
773
793
                        # ignore while selecting files - if we globbed in the
774
794
                        # outer loop we would ignore user files.
775
795
                        ignore_glob = self.tree.is_ignored(subp)