~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/workingtree.py

  • Committer: Robert Collins
  • Date: 2006-07-29 03:57:49 UTC
  • mto: (1852.14.2 status-benchmarks)
  • mto: This revision was merged to the branch mainline in revision 2322.
  • Revision ID: robertc@robertcollins.net-20060729035749-f4d52d3fcc448fd9
Add a first-cut Tree.walkdirs method.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1480
1480
                             file_id=self.path2id(conflicted)))
1481
1481
        return conflicts
1482
1482
 
 
1483
    def walkdirs(self, prefix=""):
 
1484
        _directory = 'directory'
 
1485
        pending = [('', '', _directory, None, '', None, None)]
 
1486
        inv = self.inventory
 
1487
        while pending:
 
1488
            dirblock = []
 
1489
            currentdir = pending.pop()
 
1490
            # 0 - relpath, 1- basename, 2- kind, 3- stat, 4-toppath
 
1491
            top = currentdir[4]
 
1492
            if currentdir[0]:
 
1493
                relroot = currentdir[0] + '/'
 
1494
            else:
 
1495
                relroot = ""
 
1496
            # FIXME: stash the node in pending
 
1497
            entry = inv[inv.path2id(top)]
 
1498
            for name, child in entry.sorted_children():
 
1499
                toppath = relroot + name
 
1500
                dirblock.append((toppath, name, child.kind, None, toppath,
 
1501
                    child.file_id, child.kind
 
1502
                    ))
 
1503
            yield (currentdir[0], top, entry.file_id), dirblock
 
1504
            # push the user specified dirs from dirblock
 
1505
            for dir in reversed(dirblock):
 
1506
                if dir[2] == _directory:
 
1507
                    pending.append(dir)
 
1508
 
1483
1509
 
1484
1510
class WorkingTree2(WorkingTree):
1485
1511
    """This is the Format 2 working tree.