~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/inventory.py

  • Committer: Martin Pool
  • Date: 2005-05-25 03:48:09 UTC
  • Revision ID: mbp@sourcefrog.net-20050525034809-2bc563d3013b7321
- New Inventory.entries() method

Show diffs side-by-side

added added

removed removed

Lines of Context:
329
329
            if ie.kind == 'directory':
330
330
                for cn, cie in self.iter_entries(from_dir=ie.file_id):
331
331
                    yield os.path.join(name, cn), cie
332
 
                    
 
332
 
 
333
 
 
334
    def entries(self):
 
335
        """Return list of (path, ie) for all entries except the root.
 
336
 
 
337
        This may be faster than iter_entries.
 
338
        """
 
339
        def accum(self, dir_ie, dir_path, a):
 
340
            kids = from_dir.children.items()
 
341
            kids.sort()
 
342
            for name, ie in kids:
 
343
                child_path = os.path.join(dir_path, name)
 
344
                a.append((child_path, ie))
 
345
                if ie.kind == 'directory':
 
346
                    accum(ie, ie, child_path, a)
 
347
 
 
348
        a = []
 
349
        accumt(self, self.root, a)
 
350
        return a
333
351
 
334
352
 
335
353
    def directories(self):