~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/inventory.py

  • Committer: Jelmer Vernooij
  • Date: 2011-11-27 17:42:25 UTC
  • mto: This revision was merged to the branch mainline in revision 6311.
  • Revision ID: jelmer@samba.org-20111127174225-tspfeewl0gwxxumt
Add possible_transports in a couple more places.

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
# But those depend on its position within a particular inventory, and
24
24
# it would be nice not to need to hold the backpointer here.
25
25
 
26
 
from __future__ import absolute_import
27
 
 
28
26
# This should really be an id randomly assigned when the tree is
29
27
# created, but it's not for now.
30
28
ROOT_ID = "TREE_ROOT"
850
848
            descend(self.root, u'')
851
849
        return accum
852
850
 
 
851
    def directories(self):
 
852
        """Return (path, entry) pairs for all directories, including the root.
 
853
        """
 
854
        accum = []
 
855
        def descend(parent_ie, parent_path):
 
856
            accum.append((parent_path, parent_ie))
 
857
 
 
858
            kids = [(ie.name, ie) for ie in parent_ie.children.itervalues() if ie.kind == 'directory']
 
859
            kids.sort()
 
860
 
 
861
            for name, child_ie in kids:
 
862
                child_path = osutils.pathjoin(parent_path, name)
 
863
                descend(child_ie, child_path)
 
864
        descend(self.root, u'')
 
865
        return accum
 
866
 
853
867
    def path2id(self, relpath):
854
868
        """Walk down through directories to return entry of last component.
855
869