~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tree.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2011-04-02 00:59:52 UTC
  • mfrom: (5622.4.4 uninstall-hook)
  • Revision ID: pqm@pqm.ubuntu.com-20110402005952-kxcwbwdk6jagtfwm
(jelmer) Add Hooks.uninstall_named_hook(). (Jelmer Vernooij)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005, 2009 Canonical Ltd
 
1
# Copyright (C) 2005-2010 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
40
39
from bzrlib.symbol_versioning import deprecated_function, deprecated_in
41
40
from bzrlib.trace import note
42
41
 
98
97
    def iter_changes(self, from_tree, include_unchanged=False,
99
98
                     specific_files=None, pb=None, extra_trees=None,
100
99
                     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)
157
157
        """
158
158
        return self.inventory.id2path(file_id)
159
159
 
160
 
    def is_control_filename(self, filename):
161
 
        """True if filename is the name of a control file in this tree.
162
 
 
163
 
        :param filename: A filename within the tree. This is a relative path
164
 
        from the root of this tree.
165
 
 
166
 
        This is true IF and ONLY IF the filename is part of the meta data
167
 
        that bzr controls in this tree. I.E. a random .bzr directory placed
168
 
        on disk will not be a control file for this tree.
169
 
        """
170
 
        return self.bzrdir.is_control_filename(filename)
171
 
 
172
160
    @needs_read_lock
173
161
    def iter_entries_by_dir(self, specific_file_ids=None, yield_parents=False):
174
162
        """Walk the tree in 'by_dir' order.
404
392
            bit_iter = iter(path.split("/"))
405
393
            for elt in bit_iter:
406
394
                lelt = elt.lower()
 
395
                new_path = None
407
396
                for child in self.iter_children(cur_id):
408
397
                    try:
 
398
                        # XXX: it seem like if the child is known to be in the
 
399
                        # tree, we shouldn't need to go from its id back to
 
400
                        # its path -- mbp 2010-02-11
 
401
                        #
 
402
                        # XXX: it seems like we could be more efficient
 
403
                        # by just directly looking up the original name and
 
404
                        # only then searching all children; also by not
 
405
                        # chopping paths so much. -- mbp 2010-02-11
409
406
                        child_base = os.path.basename(self.id2path(child))
410
 
                        if child_base.lower() == lelt:
 
407
                        if (child_base == elt):
 
408
                            # if we found an exact match, we can stop now; if
 
409
                            # we found an approximate match we need to keep
 
410
                            # searching because there might be an exact match
 
411
                            # later.  
411
412
                            cur_id = child
412
 
                            cur_path = osutils.pathjoin(cur_path, child_base)
 
413
                            new_path = osutils.pathjoin(cur_path, child_base)
413
414
                            break
 
415
                        elif child_base.lower() == lelt:
 
416
                            cur_id = child
 
417
                            new_path = osutils.pathjoin(cur_path, child_base)
414
418
                    except NoSuchId:
415
419
                        # before a change is committed we can see this error...
416
420
                        continue
 
421
                if new_path:
 
422
                    cur_path = new_path
417
423
                else:
418
424
                    # got to the end of this directory and no entries matched.
419
425
                    # Return what matched so far, plus the rest as specified.
502
508
            parent_keys = [(file_id, self._file_revision(t, file_id)) for t in
503
509
                self._iter_parent_trees()]
504
510
            vf.add_lines((file_id, last_revision), parent_keys,
505
 
                         self.get_file(file_id).readlines())
 
511
                         self.get_file_lines(file_id))
506
512
            repo = self.branch.repository
507
513
            base_vf = repo.texts
508
514
        else:
564
570
            yield child.file_id
565
571
 
566
572
    def lock_read(self):
 
573
        """Lock this tree for multiple read only operations.
 
574
        
 
575
        :return: A bzrlib.lock.LogicalLockResult.
 
576
        """
567
577
        pass
568
578
 
569
579
    def revision_tree(self, revision_id):
756
766
    return 'wtf?'
757
767
 
758
768
 
759
 
@deprecated_function(deprecated_in((1, 9, 0)))
760
 
def find_renames(old_inv, new_inv):
761
 
    for file_id in old_inv:
762
 
        if file_id not in new_inv:
763
 
            continue
764
 
        old_name = old_inv.id2path(file_id)
765
 
        new_name = new_inv.id2path(file_id)
766
 
        if old_name != new_name:
767
 
            yield (old_name, new_name)
768
 
 
769
 
 
770
769
def find_ids_across_trees(filenames, trees, require_versioned=True):
771
770
    """Find the ids corresponding to specified filenames.
772
771
 
1108
1107
            if file_id in to_paths:
1109
1108
                # already returned
1110
1109
                continue
1111
 
            if file_id not in self.target.all_file_ids():
 
1110
            if not self.target.has_id(file_id):
1112
1111
                # common case - paths we have not emitted are not present in
1113
1112
                # target.
1114
1113
                to_path = None