~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tree.py

Indentation and documentation fixes

Show diffs side-by-side

added added

removed removed

Lines of Context:
345
345
    at least one tree.
346
346
    :return: a set of file ids for the specified filenames
347
347
    """
 
348
    if not filenames:
 
349
        return None
348
350
    not_versioned = []
349
 
    if not filenames:
350
 
        interesting_ids = None
351
 
    else:
352
 
        interesting_ids = set()
353
 
        for tree_path in filenames:
354
 
            not_found = True
 
351
    interesting_ids = set()
 
352
    for tree_path in filenames:
 
353
        not_found = True
 
354
        for tree in trees:
 
355
            file_id = tree.inventory.path2id(tree_path)
 
356
            if file_id is not None:
 
357
                interesting_ids.add(file_id)
 
358
                not_found = False
 
359
        if not_found:
 
360
            not_versioned.append(tree_path)
 
361
    
 
362
    pending = interesting_ids
 
363
    # now handle children of interesting ids
 
364
    # we loop so that we handle all children of each id in both trees
 
365
    while len(pending) > 0:
 
366
        new_pending = set()
 
367
        for file_id in pending:
355
368
            for tree in trees:
356
 
                file_id = tree.inventory.path2id(tree_path)
357
 
                if file_id is not None:
358
 
                    interesting_ids.add(file_id)
359
 
                    not_found = False
360
 
            if not_found:
361
 
                not_versioned.append(tree_path)
362
 
        
363
 
        pending = interesting_ids
364
 
        # now handle children of interesting ids
365
 
        # we loop so that we handle all children of each id in both trees
366
 
        while len(pending) > 0:
367
 
            new_pending = set()
368
 
            for file_id in pending:
369
 
                for tree in trees:
370
 
                    if file_id not in tree:
371
 
                        continue
372
 
                    entry = tree.inventory[file_id]
373
 
                    for child in getattr(entry, 'children', {}).itervalues():
374
 
                        if child.file_id not in interesting_ids:
375
 
                            new_pending.add(child.file_id)
376
 
            interesting_ids.update(new_pending)
377
 
            pending = new_pending
378
 
        if len(not_versioned) > 0 and require_versioned:
379
 
            raise errors.PathsNotVersionedError(not_versioned)
 
369
                if file_id not in tree:
 
370
                    continue
 
371
                entry = tree.inventory[file_id]
 
372
                for child in getattr(entry, 'children', {}).itervalues():
 
373
                    if child.file_id not in interesting_ids:
 
374
                        new_pending.add(child.file_id)
 
375
        interesting_ids.update(new_pending)
 
376
        pending = new_pending
 
377
    if len(not_versioned) > 0 and require_versioned:
 
378
        raise errors.PathsNotVersionedError(not_versioned)
380
379
    return interesting_ids