~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tree.py

  • Committer: John Arbash Meinel
  • Date: 2009-10-13 18:00:16 UTC
  • mto: This revision was merged to the branch mainline in revision 4755.
  • Revision ID: john@arbash-meinel.com-20091013180016-y9ciypkm8lor58fx
Implement StaticTuple.from_sequence()

This allows casting from something that *might* be a StaticTuple
into something that is definitely a StaticTuple, without having to
create a new instance.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005-2010 Canonical Ltd
 
1
# Copyright (C) 2005, 2009 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
36
36
from bzrlib.inventory import InventoryFile
37
37
from bzrlib.inter import InterObject
38
38
from bzrlib.osutils import fingerprint_file
 
39
import bzrlib.revision
39
40
from bzrlib.symbol_versioning import deprecated_function, deprecated_in
40
41
from bzrlib.trace import note
41
42
 
97
98
    def iter_changes(self, from_tree, include_unchanged=False,
98
99
                     specific_files=None, pb=None, extra_trees=None,
99
100
                     require_versioned=True, want_unversioned=False):
100
 
        """See InterTree.iter_changes"""
101
101
        intertree = InterTree.get(from_tree, self)
102
102
        return intertree.iter_changes(include_unchanged, specific_files, pb,
103
103
            extra_trees, require_versioned, want_unversioned=want_unversioned)
404
404
            bit_iter = iter(path.split("/"))
405
405
            for elt in bit_iter:
406
406
                lelt = elt.lower()
407
 
                new_path = None
408
407
                for child in self.iter_children(cur_id):
409
408
                    try:
410
 
                        # XXX: it seem like if the child is known to be in the
411
 
                        # tree, we shouldn't need to go from its id back to
412
 
                        # its path -- mbp 2010-02-11
413
 
                        #
414
 
                        # XXX: it seems like we could be more efficient
415
 
                        # by just directly looking up the original name and
416
 
                        # only then searching all children; also by not
417
 
                        # chopping paths so much. -- mbp 2010-02-11
418
409
                        child_base = os.path.basename(self.id2path(child))
419
 
                        if (child_base == elt):
420
 
                            # if we found an exact match, we can stop now; if
421
 
                            # we found an approximate match we need to keep
422
 
                            # searching because there might be an exact match
423
 
                            # later.  
 
410
                        if child_base.lower() == lelt:
424
411
                            cur_id = child
425
 
                            new_path = osutils.pathjoin(cur_path, child_base)
 
412
                            cur_path = osutils.pathjoin(cur_path, child_base)
426
413
                            break
427
 
                        elif child_base.lower() == lelt:
428
 
                            cur_id = child
429
 
                            new_path = osutils.pathjoin(cur_path, child_base)
430
414
                    except NoSuchId:
431
415
                        # before a change is committed we can see this error...
432
416
                        continue
433
 
                if new_path:
434
 
                    cur_path = new_path
435
417
                else:
436
418
                    # got to the end of this directory and no entries matched.
437
419
                    # Return what matched so far, plus the rest as specified.
715
697
                for path in path_names:
716
698
                    yield searcher.get_items(path)
717
699
 
 
700
    @needs_read_lock
718
701
    def _get_rules_searcher(self, default_searcher):
719
702
        """Get the RulesSearcher for this tree given the default one."""
720
703
        searcher = default_searcher
869
852
    will pass through to InterTree as appropriate.
870
853
    """
871
854
 
872
 
    # Formats that will be used to test this InterTree. If both are
873
 
    # None, this InterTree will not be tested (e.g. because a complex
874
 
    # setup is required)
875
 
    _matching_from_tree_format = None
876
 
    _matching_to_tree_format = None
877
 
 
878
855
    _optimisers = []
879
856
 
880
857
    def _changes_from_entries(self, source_entry, target_entry,
977
954
            a PathsNotVersionedError will be thrown.
978
955
        :param want_unversioned: Scan for unversioned paths.
979
956
        """
 
957
        # NB: show_status depends on being able to pass in non-versioned files
 
958
        # and report them as unknown
980
959
        trees = (self.source,)
981
960
        if extra_trees is not None:
982
961
            trees = trees + tuple(extra_trees)