~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tree.py

  • Committer: Andrew Bennetts
  • Date: 2009-10-08 08:16:35 UTC
  • mfrom: (4732 +trunk)
  • mto: This revision was merged to the branch mainline in revision 4734.
  • Revision ID: andrew.bennetts@canonical.com-20091008081635-hwoh2m0566lkqgqq
MergeĀ lp:bzr

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.
520
502
            parent_keys = [(file_id, self._file_revision(t, file_id)) for t in
521
503
                self._iter_parent_trees()]
522
504
            vf.add_lines((file_id, last_revision), parent_keys,
523
 
                         self.get_file_lines(file_id))
 
505
                         self.get_file(file_id).readlines())
524
506
            repo = self.branch.repository
525
507
            base_vf = repo.texts
526
508
        else:
582
564
            yield child.file_id
583
565
 
584
566
    def lock_read(self):
585
 
        """Lock this tree for multiple read only operations.
586
 
        
587
 
        :return: A bzrlib.lock.LogicalLockResult.
588
 
        """
589
567
        pass
590
568
 
591
569
    def revision_tree(self, revision_id):
719
697
                for path in path_names:
720
698
                    yield searcher.get_items(path)
721
699
 
 
700
    @needs_read_lock
722
701
    def _get_rules_searcher(self, default_searcher):
723
702
        """Get the RulesSearcher for this tree given the default one."""
724
703
        searcher = default_searcher
873
852
    will pass through to InterTree as appropriate.
874
853
    """
875
854
 
876
 
    # Formats that will be used to test this InterTree. If both are
877
 
    # None, this InterTree will not be tested (e.g. because a complex
878
 
    # setup is required)
879
 
    _matching_from_tree_format = None
880
 
    _matching_to_tree_format = None
881
 
 
882
855
    _optimisers = []
883
856
 
884
857
    def _changes_from_entries(self, source_entry, target_entry,
981
954
            a PathsNotVersionedError will be thrown.
982
955
        :param want_unversioned: Scan for unversioned paths.
983
956
        """
 
957
        # NB: show_status depends on being able to pass in non-versioned files
 
958
        # and report them as unknown
984
959
        trees = (self.source,)
985
960
        if extra_trees is not None:
986
961
            trees = trees + tuple(extra_trees)
1130
1105
            if file_id in to_paths:
1131
1106
                # already returned
1132
1107
                continue
1133
 
            if not self.target.has_id(file_id):
 
1108
            if file_id not in self.target.all_file_ids():
1134
1109
                # common case - paths we have not emitted are not present in
1135
1110
                # target.
1136
1111
                to_path = None